@vaadin/text-area 22.0.0-alpha10

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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2021 Vaadin Ltd.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @vaadin/text-area
2
+
3
+ An input field component for multi-line text input.
4
+
5
+ [Live Demo ↗](https://vaadin.com/docs/latest/ds/components/text-area)
6
+
7
+ ```html
8
+ <vaadin-text-area label="Comment"></vaadin-text-area>
9
+ ```
10
+
11
+ ## Installation
12
+
13
+ Install the component:
14
+
15
+ ```sh
16
+ npm i @vaadin/text-area --save
17
+ ```
18
+
19
+ Once installed, import the component in your application:
20
+
21
+ ```js
22
+ import '@vaadin/text-area';
23
+ ```
24
+
25
+ ## Themes
26
+
27
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes),
28
+ Lumo and Material. The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/text-area/vaadin-text-area.js)
29
+ of the package uses Lumo theme.
30
+
31
+ To use the Material theme, import the component from the `theme/material` folder:
32
+
33
+ ```js
34
+ import '@vaadin/text-area/theme/material/vaadin-text-area.js';
35
+ ```
36
+
37
+ You can also import the Lumo version of the component explicitly:
38
+
39
+ ```js
40
+ import '@vaadin/text-area/theme/lumo/vaadin-text-area.js';
41
+ ```
42
+
43
+ Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
44
+
45
+ ```js
46
+ import '@vaadin/text-area/src/vaadin-text-area.js';
47
+ ```
48
+
49
+ ## License
50
+
51
+ Apache License 2.0
52
+
53
+ Vaadin collects development time usage statistics to improve this product.
54
+ For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@vaadin/text-area",
3
+ "version": "22.0.0-alpha10",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "vaadin-text-area",
8
+ "license": "Apache-2.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/text-area"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/components",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/web-components/issues"
18
+ },
19
+ "main": "vaadin-text-area.js",
20
+ "module": "vaadin-text-area.js",
21
+ "files": [
22
+ "src",
23
+ "theme",
24
+ "vaadin-*.d.ts",
25
+ "vaadin-*.js"
26
+ ],
27
+ "keywords": [
28
+ "Vaadin",
29
+ "input",
30
+ "web-components",
31
+ "web-component"
32
+ ],
33
+ "dependencies": {
34
+ "@polymer/polymer": "^3.0.0",
35
+ "@vaadin/component-base": "22.0.0-alpha10",
36
+ "@vaadin/field-base": "22.0.0-alpha10",
37
+ "@vaadin/input-container": "22.0.0-alpha10",
38
+ "@vaadin/vaadin-lumo-styles": "22.0.0-alpha10",
39
+ "@vaadin/vaadin-material-styles": "22.0.0-alpha10",
40
+ "@vaadin/vaadin-themable-mixin": "22.0.0-alpha10"
41
+ },
42
+ "devDependencies": {
43
+ "@esm-bundle/chai": "^4.3.4",
44
+ "@vaadin/testing-helpers": "^0.3.0",
45
+ "sinon": "^9.2.1"
46
+ },
47
+ "gitHead": "6d3055383b9c3c8306ea34c6f2e2087e63c49348"
48
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
+ import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
8
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+
10
+ /**
11
+ * Fired when the `invalid` property changes.
12
+ */
13
+ export type TextAreaInvalidChangedEvent = CustomEvent<{ value: boolean }>;
14
+
15
+ /**
16
+ * Fired when the `value` property changes.
17
+ */
18
+ export type TextAreaValueChangedEvent = CustomEvent<{ value: string }>;
19
+
20
+ export interface TextAreaCustomEventMap {
21
+ 'invalid-changed': TextAreaInvalidChangedEvent;
22
+
23
+ 'value-changed': TextAreaValueChangedEvent;
24
+ }
25
+
26
+ export interface TextAreaEventMap extends HTMLElementEventMap, TextAreaCustomEventMap {}
27
+
28
+ /**
29
+ * `<vaadin-text-area>` is a web component for multi-line text input.
30
+ *
31
+ * ```html
32
+ * <vaadin-text-area label="Comment"></vaadin-text-area>
33
+ * ```
34
+ *
35
+ * ### Prefixes and suffixes
36
+ *
37
+ * These are child elements of a `<vaadin-text-area>` that are displayed
38
+ * inline with the input, before or after.
39
+ * In order for an element to be considered as a prefix, it must have the slot
40
+ * attribute set to `prefix` (and similarly for `suffix`).
41
+ *
42
+ * ```html
43
+ * <vaadin-text-area label="Description">
44
+ * <div slot="prefix">Details:</div>
45
+ * <div slot="suffix">The end!</div>
46
+ * </vaadin-text-area>
47
+ * ```
48
+ *
49
+ * ### Styling
50
+ *
51
+ * The following custom properties are available for styling:
52
+ *
53
+ * Custom property | Description | Default
54
+ * -------------------------------|----------------------------|---------
55
+ * `--vaadin-field-default-width` | Default width of the field | `12em`
56
+ *
57
+ * The following shadow DOM parts are available for styling:
58
+ *
59
+ * Part name | Description
60
+ * ----------------|----------------
61
+ * `label` | The label element wrapper
62
+ * `input-field` | The element that wraps prefix, textarea and suffix
63
+ * `error-message` | The error message element wrapper
64
+ * `helper-text` | The helper text element wrapper
65
+ *
66
+ * The following state attributes are available for styling:
67
+ *
68
+ * Attribute | Description | Part name
69
+ * --------------------|-------------------------------------------|----------
70
+ * `disabled` | Set when the element is disabled | :host
71
+ * `has-value` | Set when the element has a value | :host
72
+ * `has-label` | Set when the element has a label | :host
73
+ * `has-helper` | Set when the element has helper text | :host
74
+ * `has-error-message` | Set when the element has an error message | :host
75
+ * `invalid` | Set when the element is invalid | :host
76
+ * `focused` | Set when the element is focused | :host
77
+ * `focus-ring` | Set when the element is keyboard focused | :host
78
+ * `readonly` | Set when the element is readonly | :host
79
+ *
80
+ * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
81
+ *
82
+ * @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
83
+ * @fires {Event} change - Fired when the user commits a value change.
84
+ * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
85
+ * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
86
+ */
87
+ declare class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(HTMLElement))) {
88
+ /**
89
+ * Maximum number of characters (in Unicode code points) that the user can enter.
90
+ */
91
+ maxlength: number | null | undefined;
92
+
93
+ /**
94
+ * Minimum number of characters (in Unicode code points) that the user can enter.
95
+ */
96
+ minlength: number | null | undefined;
97
+
98
+ addEventListener<K extends keyof TextAreaEventMap>(
99
+ type: K,
100
+ listener: (this: TextArea, ev: TextAreaEventMap[K]) => void,
101
+ options?: boolean | AddEventListenerOptions
102
+ ): void;
103
+
104
+ removeEventListener<K extends keyof TextAreaEventMap>(
105
+ type: K,
106
+ listener: (this: TextArea, ev: TextAreaEventMap[K]) => void,
107
+ options?: boolean | EventListenerOptions
108
+ ): void;
109
+ }
110
+
111
+ declare global {
112
+ interface HTMLElementTagNameMap {
113
+ 'vaadin-text-area': TextArea;
114
+ }
115
+ }
116
+
117
+ export { TextArea };
@@ -0,0 +1,300 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { PolymerElement, html } from '@polymer/polymer';
7
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
+ import { AriaLabelController } from '@vaadin/field-base/src/aria-label-controller.js';
9
+ import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
10
+ import { TextAreaController } from '@vaadin/field-base/src/text-area-controller.js';
11
+ import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
12
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
+ import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
14
+ import '@vaadin/input-container/src/vaadin-input-container.js';
15
+
16
+ registerStyles('vaadin-text-area', inputFieldShared, { moduleId: 'vaadin-text-area-styles' });
17
+
18
+ /**
19
+ * `<vaadin-text-area>` is a web component for multi-line text input.
20
+ *
21
+ * ```html
22
+ * <vaadin-text-area label="Comment"></vaadin-text-area>
23
+ * ```
24
+ *
25
+ * ### Prefixes and suffixes
26
+ *
27
+ * These are child elements of a `<vaadin-text-area>` that are displayed
28
+ * inline with the input, before or after.
29
+ * In order for an element to be considered as a prefix, it must have the slot
30
+ * attribute set to `prefix` (and similarly for `suffix`).
31
+ *
32
+ * ```html
33
+ * <vaadin-text-area label="Description">
34
+ * <div slot="prefix">Details:</div>
35
+ * <div slot="suffix">The end!</div>
36
+ * </vaadin-text-area>
37
+ * ```
38
+ *
39
+ * ### Styling
40
+ *
41
+ * The following custom properties are available for styling:
42
+ *
43
+ * Custom property | Description | Default
44
+ * -------------------------------|----------------------------|---------
45
+ * `--vaadin-field-default-width` | Default width of the field | `12em`
46
+ *
47
+ * The following shadow DOM parts are available for styling:
48
+ *
49
+ * Part name | Description
50
+ * ----------------|----------------
51
+ * `label` | The label element wrapper
52
+ * `input-field` | The element that wraps prefix, textarea and suffix
53
+ * `error-message` | The error message element wrapper
54
+ * `helper-text` | The helper text element wrapper
55
+ *
56
+ * The following state attributes are available for styling:
57
+ *
58
+ * Attribute | Description | Part name
59
+ * --------------------|-------------------------------------------|----------
60
+ * `disabled` | Set when the element is disabled | :host
61
+ * `has-value` | Set when the element has a value | :host
62
+ * `has-label` | Set when the element has a label | :host
63
+ * `has-helper` | Set when the element has helper text | :host
64
+ * `has-error-message` | Set when the element has an error message | :host
65
+ * `invalid` | Set when the element is invalid | :host
66
+ * `focused` | Set when the element is focused | :host
67
+ * `focus-ring` | Set when the element is keyboard focused | :host
68
+ * `readonly` | Set when the element is readonly | :host
69
+ *
70
+ * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
71
+ *
72
+ * @fires {Event} input - Fired when the value is changed by the user: on every typing keystroke, and the value is cleared using the clear button.
73
+ * @fires {Event} change - Fired when the user commits a value change.
74
+ * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
75
+ * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
76
+ *
77
+ * @extends HTMLElement
78
+ * @mixes InputFieldMixin
79
+ * @mixes ElementMixin
80
+ * @mixes ThemableMixin
81
+ */
82
+ export class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement))) {
83
+ static get is() {
84
+ return 'vaadin-text-area';
85
+ }
86
+
87
+ static get template() {
88
+ return html`
89
+ <style>
90
+ :host {
91
+ animation: 1ms vaadin-text-area-appear;
92
+ }
93
+
94
+ .vaadin-text-area-container {
95
+ flex: auto;
96
+ }
97
+
98
+ /* The label, helper text and the error message should neither grow nor shrink. */
99
+ [part='label'],
100
+ [part='helper-text'],
101
+ [part='error-message'] {
102
+ flex: none;
103
+ }
104
+
105
+ [part='input-field'] {
106
+ flex: auto;
107
+ overflow: auto;
108
+ -webkit-overflow-scrolling: touch;
109
+ }
110
+
111
+ ::slotted(textarea) {
112
+ -webkit-appearance: none;
113
+ -moz-appearance: none;
114
+ flex: auto;
115
+ overflow: hidden;
116
+ width: 100%;
117
+ height: 100%;
118
+ outline: none;
119
+ resize: none;
120
+ margin: 0;
121
+ padding: 0 0.25em;
122
+ border: 0;
123
+ border-radius: 0;
124
+ min-width: 0;
125
+ font: inherit;
126
+ font-size: 1em;
127
+ line-height: normal;
128
+ color: inherit;
129
+ background-color: transparent;
130
+ /* Disable default invalid style in Firefox */
131
+ box-shadow: none;
132
+ }
133
+
134
+ [part='input-field'] ::slotted(*) {
135
+ align-self: flex-start;
136
+ }
137
+
138
+ @keyframes vaadin-text-area-appear {
139
+ to {
140
+ opacity: 1;
141
+ }
142
+ }
143
+ </style>
144
+
145
+ <div class="vaadin-text-area-container">
146
+ <div part="label">
147
+ <slot name="label"></slot>
148
+ <span part="required-indicator" aria-hidden="true"></span>
149
+ </div>
150
+
151
+ <vaadin-input-container
152
+ part="input-field"
153
+ readonly="[[readonly]]"
154
+ disabled="[[disabled]]"
155
+ invalid="[[invalid]]"
156
+ theme$="[[theme]]"
157
+ >
158
+ <slot name="prefix" slot="prefix"></slot>
159
+ <slot name="textarea"></slot>
160
+ <slot name="suffix" slot="suffix"></slot>
161
+ <div id="clearButton" part="clear-button" slot="suffix"></div>
162
+ </vaadin-input-container>
163
+
164
+ <div part="helper-text">
165
+ <slot name="helper"></slot>
166
+ </div>
167
+
168
+ <div part="error-message">
169
+ <slot name="error-message"></slot>
170
+ </div>
171
+ </div>
172
+ `;
173
+ }
174
+
175
+ static get properties() {
176
+ return {
177
+ /**
178
+ * Maximum number of characters (in Unicode code points) that the user can enter.
179
+ */
180
+ maxlength: {
181
+ type: Number
182
+ },
183
+
184
+ /**
185
+ * Minimum number of characters (in Unicode code points) that the user can enter.
186
+ */
187
+ minlength: {
188
+ type: Number
189
+ }
190
+ };
191
+ }
192
+
193
+ static get delegateAttrs() {
194
+ return [...super.delegateAttrs, 'maxlength', 'minlength'];
195
+ }
196
+
197
+ static get constraints() {
198
+ return [...super.constraints, 'maxlength', 'minlength'];
199
+ }
200
+
201
+ /**
202
+ * Used by `ClearButtonMixin` as a reference to the clear button element.
203
+ * @protected
204
+ */
205
+ get clearElement() {
206
+ return this.$.clearButton;
207
+ }
208
+
209
+ /** @protected */
210
+ connectedCallback() {
211
+ super.connectedCallback();
212
+
213
+ this._inputField = this.shadowRoot.querySelector('[part=input-field]');
214
+ this._updateHeight();
215
+ }
216
+
217
+ /** @protected */
218
+ ready() {
219
+ super.ready();
220
+
221
+ this.addController(
222
+ new TextAreaController(this, (input) => {
223
+ this._setInputElement(input);
224
+ this._setFocusElement(input);
225
+ this.stateTarget = input;
226
+ this.ariaTarget = input;
227
+ })
228
+ );
229
+ this.addController(new AriaLabelController(this, this.inputElement, this._labelNode));
230
+ this.addEventListener('animationend', this._onAnimationEnd);
231
+ }
232
+
233
+ /** @private */
234
+ _onAnimationEnd(e) {
235
+ if (e.animationName.indexOf('vaadin-text-area-appear') === 0) {
236
+ this._updateHeight();
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @param {unknown} newVal
242
+ * @param {unknown} oldVal
243
+ * @protected
244
+ * @override
245
+ */
246
+ _valueChanged(newVal, oldVal) {
247
+ super._valueChanged(newVal, oldVal);
248
+
249
+ this._updateHeight();
250
+ }
251
+
252
+ /** @private */
253
+ _updateHeight() {
254
+ const input = this.inputElement;
255
+ const inputField = this._inputField;
256
+
257
+ if (!input || !inputField) {
258
+ return;
259
+ }
260
+
261
+ const scrollTop = inputField.scrollTop;
262
+
263
+ // Only clear the height when the content shortens to minimize scrollbar flickering.
264
+ const valueLength = this.value ? this.value.length : 0;
265
+
266
+ if (this._oldValueLength >= valueLength) {
267
+ const inputFieldHeight = getComputedStyle(inputField).height;
268
+ const inputWidth = getComputedStyle(input).width;
269
+
270
+ // Temporarily fix the height of the wrapping input field container to prevent changing the browsers scroll
271
+ // position while resetting the textareas height. If the textarea had a large height, then removing its height
272
+ // will reset its height to the default of two rows. That might reduce the height of the page, and the
273
+ // browser might adjust the scroll position before we can restore the measured height of the textarea.
274
+ inputField.style.display = 'block';
275
+ inputField.style.height = inputFieldHeight;
276
+
277
+ // Fix the input element width so its scroll height isn't affected by host's disappearing scrollbars
278
+ input.style.maxWidth = inputWidth;
279
+
280
+ // Clear the height of the textarea to allow measuring a reduced scroll height
281
+ input.style.height = 'auto';
282
+ }
283
+ this._oldValueLength = valueLength;
284
+
285
+ const inputHeight = input.scrollHeight;
286
+ if (inputHeight > input.clientHeight) {
287
+ input.style.height = inputHeight + 'px';
288
+ }
289
+
290
+ // Restore
291
+ input.style.removeProperty('max-width');
292
+ inputField.style.removeProperty('display');
293
+ inputField.style.removeProperty('height');
294
+ inputField.scrollTop = scrollTop;
295
+
296
+ this._dispatchIronResizeEventIfNeeded('InputHeight', inputHeight);
297
+ }
298
+ }
299
+
300
+ customElements.define(TextArea.is, TextArea);
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
7
+ import '@vaadin/vaadin-lumo-styles/color.js';
8
+ import '@vaadin/vaadin-lumo-styles/sizing.js';
9
+ import '@vaadin/vaadin-lumo-styles/typography.js';
10
+ import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-shared.js';
11
+
12
+ const textArea = css`
13
+ [part='input-field'],
14
+ [part='input-field'] ::slotted(textarea) {
15
+ height: auto;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ [part='input-field'] {
20
+ /* Equal to the implicit padding in vaadin-text-field */
21
+ padding-top: calc((var(--lumo-text-field-size) - 1em * var(--lumo-line-height-s)) / 2);
22
+ padding-bottom: calc((var(--lumo-text-field-size) - 1em * var(--lumo-line-height-s)) / 2);
23
+ transition: background-color 0.1s;
24
+ line-height: var(--lumo-line-height-s);
25
+ }
26
+
27
+ :host(:not([readonly])) [part='input-field']::after {
28
+ display: none;
29
+ }
30
+
31
+ :host([readonly]) [part='input-field'] {
32
+ border: 1px dashed var(--lumo-contrast-30pct);
33
+ }
34
+
35
+ :host([readonly]) [part='input-field']::after {
36
+ border: none;
37
+ }
38
+
39
+ :host(:hover:not([readonly]):not([focused]):not([invalid])) [part='input-field'] {
40
+ background-color: var(--lumo-contrast-20pct);
41
+ }
42
+
43
+ @media (pointer: coarse) {
44
+ :host(:hover:not([readonly]):not([focused]):not([invalid])) [part='input-field'] {
45
+ background-color: var(--lumo-contrast-10pct);
46
+ }
47
+
48
+ :host(:active:not([readonly]):not([focused])) [part='input-field'] {
49
+ background-color: var(--lumo-contrast-20pct);
50
+ }
51
+ }
52
+
53
+ [part='input-field'] ::slotted(textarea) {
54
+ white-space: pre-wrap; /* override "nowrap" from <vaadin-text-field> */
55
+ align-self: stretch; /* override "baseline" from <vaadin-text-field> */
56
+ line-height: inherit;
57
+ --_lumo-text-field-overflow-mask-image: none;
58
+ }
59
+
60
+ /* Vertically align icon prefix/suffix with the first line of text */
61
+ [part='input-field'] ::slotted(iron-icon),
62
+ [part='input-field'] ::slotted(vaadin-icon) {
63
+ margin-top: calc((var(--lumo-icon-size-m) - 1em * var(--lumo-line-height-s)) / -2);
64
+ }
65
+ `;
66
+
67
+ registerStyles('vaadin-text-area', [inputFieldShared, textArea], {
68
+ moduleId: 'lumo-text-area'
69
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/input-container/theme/lumo/vaadin-input-container.js';
7
+ import './vaadin-text-area-styles.js';
8
+ import '../../src/vaadin-text-area.js';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
7
+ import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-field-shared.js';
8
+
9
+ const textArea = css`
10
+ [part='input-field'] {
11
+ height: auto;
12
+ box-sizing: border-box;
13
+ }
14
+
15
+ [part='input-field'] ::slotted(textarea) {
16
+ padding-top: 0;
17
+ margin-top: 4px;
18
+ }
19
+
20
+ [part='input-field'] ::slotted(textarea) {
21
+ white-space: pre-wrap; /* override "nowrap" from <vaadin-text-field> */
22
+ align-self: stretch; /* override "baseline" from <vaadin-text-field> */
23
+ }
24
+ `;
25
+
26
+ registerStyles('vaadin-text-area', [inputFieldShared, textArea], { moduleId: 'material-text-area' });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/input-container/theme/material/vaadin-input-container.js';
7
+ import './vaadin-text-area-styles.js';
8
+ import '../../src/vaadin-text-area.js';
@@ -0,0 +1 @@
1
+ export * from './src/vaadin-text-area.js';
@@ -0,0 +1,3 @@
1
+ import './theme/lumo/vaadin-text-area.js';
2
+
3
+ export * from './src/vaadin-text-area.js';