@c2n/textarea 0.0.6
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 +21 -0
- package/README.md +19 -0
- package/dist/textarea.js +170 -0
- package/package.json +61 -0
- package/types/src/textarea.d.ts +102 -0
- package/types/src/textarea.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nguyen Thai Vinh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @c2n/textarea
|
|
2
|
+
|
|
3
|
+
Multiline Lit input with native resizing, helper and error text, character counting, and CSS custom properties.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @c2n/textarea
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import '@c2n/textarea'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<c2-textarea label="Message" name="message" rows="4" maxlength="500" placeholder="Write a message…"></c2-textarea>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Read `value` on `input` or `change`; set the property to update text. Use `disabled`, `readonly`, `required`, `minlength`, `maxlength`, and `resize="none|vertical|horizontal|both"`. `help` and the `supporting-text` slot provide guidance; `error` with `error-text` displays feedback. Call `focus()`, `blur()`, `select()`, `setSelectionRange()`, `reset()`, `checkValidity()`, `reportValidity()`, or `setCustomValidity()` as needed. Await `updateComplete` after property changes before calling native methods.
|
|
18
|
+
|
|
19
|
+
This component does not automatically participate in enclosing form submission or reset. Read its value and reset it explicitly in your form handlers.
|
package/dist/textarea.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { LitElement, html, nothing, unsafeCSS } from "lit";
|
|
2
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
3
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
4
|
+
import { live } from "lit/directives/live.js";
|
|
5
|
+
import { redispatchEvent } from "@c2n/core/dom-helper.js";
|
|
6
|
+
//#region src/textarea.scss?inline
|
|
7
|
+
var textarea_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n flex-direction: column;\n vertical-align: middle;\n max-width: 100%;\n}\n\n:host([hidden]) {\n display: none;\n}\n\ntextarea {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n margin: 0;\n resize: vertical;\n text-align: inherit;\n min-height: var(--c2-textarea__container--min-height,80px);\n padding: var(--c2-textarea__container--padding,10px 12px);\n border: var(--c2-textarea__container--border,1px solid #bcbcc6);\n border-radius: var(--c2-textarea__container--border-radius,6px);\n background: var(--c2-textarea__container--background,#ffffff);\n color: var(--c2-textarea__container--color,#18181b);\n font-family: var(--c2-textarea__container--font-family,inherit);\n font-size: var(--c2-textarea__container--font-size,14px);\n line-height: var(--c2-textarea__container--line-height,20px);\n}\ntextarea::placeholder {\n color: var(--c2-textarea__placeholder--color,#71717a);\n opacity: 1;\n}\ntextarea:hover:not(:disabled) {\n border: var(--c2-textarea__container__hover--border,1px solid #a1a1aa);\n}\ntextarea:focus {\n border: var(--c2-textarea__container__focus--border,1px solid #476ef9);\n outline: var(--c2-textarea__container__focus--outline,3px solid rgba(71, 110, 249, 0.2));\n}\ntextarea:read-only {\n background: var(--c2-textarea__container__read-only--background,#fafafa);\n}\ntextarea:disabled {\n cursor: not-allowed;\n opacity: var(--c2-textarea__container__disabled--opacity,0.38);\n}\n\n:host([resize=none]) textarea {\n resize: none;\n}\n\n:host([resize=horizontal]) textarea {\n resize: horizontal;\n}\n\n:host([resize=both]) textarea {\n resize: both;\n}\n\n:host([error]:not([disabled])) textarea {\n border: var(--c2-textarea__container__error--border,1px solid #dc2626);\n}\n:host([error]:not([disabled])) textarea:focus {\n outline: var(--c2-textarea__container__error__focus--outline,3px solid rgba(220, 38, 38, 0.2));\n}\n:host([error]:not([disabled])) .supporting-text {\n color: var(--c2-textarea__supporting-text__error--color,#dc2626);\n}\n\n.supporting-text {\n display: flex;\n justify-content: space-between;\n gap: var(--c2-textarea__supporting-text--gap,4px);\n margin-top: var(--c2-textarea__supporting-text--gap,4px);\n font-size: var(--c2-textarea__supporting-text--font-size,12px);\n line-height: var(--c2-textarea__supporting-text--line-height,16px);\n color: var(--c2-textarea__supporting-text--color,#71717a);\n}\n\n[hidden] {\n display: none;\n}\n\n.message {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.counter {\n flex: none;\n font-variant-numeric: tabular-nums;\n margin-inline-start: auto;\n}";
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
|
|
10
|
+
function __decorate(decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/textarea.ts
|
|
18
|
+
var Textarea = class Textarea extends LitElement {
|
|
19
|
+
constructor(..._args) {
|
|
20
|
+
super(..._args);
|
|
21
|
+
this.value = "";
|
|
22
|
+
this.name = "";
|
|
23
|
+
this.label = "";
|
|
24
|
+
this.ariaLabel = null;
|
|
25
|
+
this.placeholder = "";
|
|
26
|
+
this.rows = 3;
|
|
27
|
+
this.cols = 20;
|
|
28
|
+
this.resize = "vertical";
|
|
29
|
+
this.wrap = "soft";
|
|
30
|
+
this.autocomplete = "";
|
|
31
|
+
this.disabled = false;
|
|
32
|
+
this.readOnly = false;
|
|
33
|
+
this.required = false;
|
|
34
|
+
this.maxLength = -1;
|
|
35
|
+
this.minLength = -1;
|
|
36
|
+
this.error = false;
|
|
37
|
+
this.errorText = "";
|
|
38
|
+
this.help = "";
|
|
39
|
+
this.dirty = false;
|
|
40
|
+
this.hasSupportingSlot = false;
|
|
41
|
+
}
|
|
42
|
+
static {
|
|
43
|
+
this.styles = unsafeCSS(textarea_default);
|
|
44
|
+
}
|
|
45
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
46
|
+
if (name === "value" && this.dirty) return;
|
|
47
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
48
|
+
}
|
|
49
|
+
/** Focuses the native textarea. */
|
|
50
|
+
focus(options) {
|
|
51
|
+
this.input?.focus(options);
|
|
52
|
+
}
|
|
53
|
+
blur() {
|
|
54
|
+
this.input?.blur();
|
|
55
|
+
}
|
|
56
|
+
/** Selects all text. */
|
|
57
|
+
select() {
|
|
58
|
+
this.input?.select();
|
|
59
|
+
}
|
|
60
|
+
/** Selects a range of text using native UTF-16 character offsets. */
|
|
61
|
+
setSelectionRange(start, end, direction) {
|
|
62
|
+
this.input?.setSelectionRange(start, end, direction);
|
|
63
|
+
}
|
|
64
|
+
/** Whether the user has edited the value since the last reset. */
|
|
65
|
+
isDirty() {
|
|
66
|
+
return this.dirty;
|
|
67
|
+
}
|
|
68
|
+
/** Restores the value attribute and clears the error state. */
|
|
69
|
+
reset() {
|
|
70
|
+
this.dirty = false;
|
|
71
|
+
this.value = this.getAttribute("value") ?? "";
|
|
72
|
+
this.error = false;
|
|
73
|
+
}
|
|
74
|
+
/** Checks the native textarea constraints. Await updateComplete after changing properties. */
|
|
75
|
+
checkValidity() {
|
|
76
|
+
return this.input?.checkValidity() ?? true;
|
|
77
|
+
}
|
|
78
|
+
/** Shows the browser's validation feedback. */
|
|
79
|
+
reportValidity() {
|
|
80
|
+
return this.input?.reportValidity() ?? true;
|
|
81
|
+
}
|
|
82
|
+
/** Sets or clears the native validation message. */
|
|
83
|
+
setCustomValidity(message) {
|
|
84
|
+
this.input?.setCustomValidity(message);
|
|
85
|
+
}
|
|
86
|
+
handleInput(event) {
|
|
87
|
+
this.dirty = true;
|
|
88
|
+
this.value = event.target.value;
|
|
89
|
+
redispatchEvent(this, event);
|
|
90
|
+
}
|
|
91
|
+
handleChange(event) {
|
|
92
|
+
this.value = event.target.value;
|
|
93
|
+
redispatchEvent(this, event);
|
|
94
|
+
}
|
|
95
|
+
handleSelect(event) {
|
|
96
|
+
redispatchEvent(this, event);
|
|
97
|
+
}
|
|
98
|
+
handleSlotChange(event) {
|
|
99
|
+
this.hasSupportingSlot = event.target.assignedNodes({ flatten: true }).length > 0;
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
const invalid = this.error && !this.disabled;
|
|
103
|
+
const showError = invalid && !!this.errorText;
|
|
104
|
+
const supporting = !!this.help || this.hasSupportingSlot || showError || this.maxLength >= 0;
|
|
105
|
+
return html` <textarea
|
|
106
|
+
part="textarea"
|
|
107
|
+
name=${ifDefined(this.name || void 0)}
|
|
108
|
+
aria-label=${ifDefined(this.label || this.ariaLabel || void 0)}
|
|
109
|
+
aria-describedby=${supporting ? "supporting-text" : nothing}
|
|
110
|
+
aria-invalid=${invalid ? "true" : nothing}
|
|
111
|
+
placeholder=${this.placeholder}
|
|
112
|
+
rows=${this.rows > 0 ? this.rows : 3}
|
|
113
|
+
cols=${this.cols > 0 ? this.cols : 20}
|
|
114
|
+
wrap=${this.wrap}
|
|
115
|
+
autocomplete=${ifDefined(this.autocomplete || void 0)}
|
|
116
|
+
maxlength=${ifDefined(this.maxLength >= 0 ? this.maxLength : void 0)}
|
|
117
|
+
minlength=${ifDefined(this.minLength >= 0 ? this.minLength : void 0)}
|
|
118
|
+
?disabled=${this.disabled}
|
|
119
|
+
?readonly=${this.readOnly}
|
|
120
|
+
?required=${this.required}
|
|
121
|
+
.value=${live(this.value)}
|
|
122
|
+
@input=${this.handleInput}
|
|
123
|
+
@change=${this.handleChange}
|
|
124
|
+
@select=${this.handleSelect}
|
|
125
|
+
></textarea>
|
|
126
|
+
<div id="supporting-text" part="supporting-text" class="supporting-text" ?hidden=${!supporting}>
|
|
127
|
+
<span class="message">
|
|
128
|
+
<slot name="supporting-text" ?hidden=${showError} @slotchange=${this.handleSlotChange}>${this.help}</slot>
|
|
129
|
+
${showError ? html`<span role="alert">${this.errorText}</span>` : nothing}
|
|
130
|
+
</span>
|
|
131
|
+
${this.maxLength >= 0 ? html`<span class="counter">${this.value.length} / ${this.maxLength}</span>` : nothing}
|
|
132
|
+
</div>`;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
__decorate([property()], Textarea.prototype, "value", void 0);
|
|
136
|
+
__decorate([property()], Textarea.prototype, "name", void 0);
|
|
137
|
+
__decorate([property()], Textarea.prototype, "label", void 0);
|
|
138
|
+
__decorate([property({ attribute: "aria-label" })], Textarea.prototype, "ariaLabel", void 0);
|
|
139
|
+
__decorate([property()], Textarea.prototype, "placeholder", void 0);
|
|
140
|
+
__decorate([property({ type: Number })], Textarea.prototype, "rows", void 0);
|
|
141
|
+
__decorate([property({ type: Number })], Textarea.prototype, "cols", void 0);
|
|
142
|
+
__decorate([property({ reflect: true })], Textarea.prototype, "resize", void 0);
|
|
143
|
+
__decorate([property()], Textarea.prototype, "wrap", void 0);
|
|
144
|
+
__decorate([property()], Textarea.prototype, "autocomplete", void 0);
|
|
145
|
+
__decorate([property({
|
|
146
|
+
type: Boolean,
|
|
147
|
+
reflect: true
|
|
148
|
+
})], Textarea.prototype, "disabled", void 0);
|
|
149
|
+
__decorate([property({
|
|
150
|
+
type: Boolean,
|
|
151
|
+
reflect: true
|
|
152
|
+
})], Textarea.prototype, "readOnly", void 0);
|
|
153
|
+
__decorate([property({
|
|
154
|
+
type: Boolean,
|
|
155
|
+
reflect: true
|
|
156
|
+
})], Textarea.prototype, "required", void 0);
|
|
157
|
+
__decorate([property({ type: Number })], Textarea.prototype, "maxLength", void 0);
|
|
158
|
+
__decorate([property({ type: Number })], Textarea.prototype, "minLength", void 0);
|
|
159
|
+
__decorate([property({
|
|
160
|
+
type: Boolean,
|
|
161
|
+
reflect: true
|
|
162
|
+
})], Textarea.prototype, "error", void 0);
|
|
163
|
+
__decorate([property({ attribute: "error-text" })], Textarea.prototype, "errorText", void 0);
|
|
164
|
+
__decorate([property()], Textarea.prototype, "help", void 0);
|
|
165
|
+
__decorate([state()], Textarea.prototype, "dirty", void 0);
|
|
166
|
+
__decorate([state()], Textarea.prototype, "hasSupportingSlot", void 0);
|
|
167
|
+
__decorate([query("textarea")], Textarea.prototype, "input", void 0);
|
|
168
|
+
Textarea = __decorate([customElement("c2-textarea")], Textarea);
|
|
169
|
+
//#endregion
|
|
170
|
+
export { Textarea };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@c2n/textarea",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/textarea.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"default": "./dist/textarea.js",
|
|
9
|
+
"types": "./types/src/textarea.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./custom-elements.json": "./custom-elements.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"types"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"textarea",
|
|
19
|
+
"web component",
|
|
20
|
+
"lit"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "code2nguyen@gmail.com",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"registry": "https://registry.npmjs.org",
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/code2nguyen/web-components.git"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"build": "wireit",
|
|
35
|
+
"build:only": "vite build",
|
|
36
|
+
"type-check": "wireit"
|
|
37
|
+
},
|
|
38
|
+
"wireit": {
|
|
39
|
+
"type-check": {
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"../../core:build"
|
|
42
|
+
],
|
|
43
|
+
"command": "tsc -p tsconfig.lib.json --composite false"
|
|
44
|
+
},
|
|
45
|
+
"build": {
|
|
46
|
+
"dependencies": [
|
|
47
|
+
"type-check"
|
|
48
|
+
],
|
|
49
|
+
"command": "vite build"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@c2n/core": "0.0.6",
|
|
54
|
+
"lit": "3.3.3"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@c2n/config": "*"
|
|
58
|
+
},
|
|
59
|
+
"customElements": "custom-elements.json",
|
|
60
|
+
"gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
|
|
61
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Multiline text input with native resizing, helper text, error feedback and a character counter.
|
|
4
|
+
* @tag c2-textarea
|
|
5
|
+
* @slot supporting-text - Rich helper content below the field; error-text takes precedence when invalid.
|
|
6
|
+
* @event {InputEvent} input - Fired on each edit, after value is updated.
|
|
7
|
+
* @event {Event} change - Fired when an edit is committed.
|
|
8
|
+
* @event {Event} select - Fired when text is selected.
|
|
9
|
+
* @cssproperty {pixel} [--c2-textarea__container--min-height=80px]
|
|
10
|
+
* @cssproperty {padding} [--c2-textarea__container--padding=10px 12px]
|
|
11
|
+
* @cssproperty {border} [--c2-textarea__container--border=1px solid #bcbcc6]
|
|
12
|
+
* @cssproperty {border-radius} [--c2-textarea__container--border-radius=6px]
|
|
13
|
+
* @cssproperty {color} [--c2-textarea__container--background=#ffffff]
|
|
14
|
+
* @cssproperty {color} [--c2-textarea__container--color=#18181b]
|
|
15
|
+
* @cssproperty {font-family} [--c2-textarea__container--font-family=inherit]
|
|
16
|
+
* @cssproperty {font-size} [--c2-textarea__container--font-size=14px]
|
|
17
|
+
* @cssproperty {pixel} [--c2-textarea__container--line-height=20px]
|
|
18
|
+
* @cssproperty {border} [--c2-textarea__container__hover--border=1px solid #a1a1aa]
|
|
19
|
+
* @cssproperty {border} [--c2-textarea__container__focus--border=1px solid #476ef9]
|
|
20
|
+
* @cssproperty {outline} [--c2-textarea__container__focus--outline=3px solid rgba(71, 110, 249, 0.2)]
|
|
21
|
+
* @cssproperty {border} [--c2-textarea__container__error--border=1px solid #dc2626]
|
|
22
|
+
* @cssproperty {outline} [--c2-textarea__container__error__focus--outline=3px solid rgba(220, 38, 38, 0.2)]
|
|
23
|
+
* @cssproperty {color} [--c2-textarea__container__read-only--background=#fafafa]
|
|
24
|
+
* @cssproperty {opacity} [--c2-textarea__container__disabled--opacity=0.38]
|
|
25
|
+
* @cssproperty {color} [--c2-textarea__placeholder--color=#71717a]
|
|
26
|
+
* @cssproperty {pixel} [--c2-textarea__supporting-text--gap=4px]
|
|
27
|
+
* @cssproperty {font-size} [--c2-textarea__supporting-text--font-size=12px]
|
|
28
|
+
* @cssproperty {pixel} [--c2-textarea__supporting-text--line-height=16px]
|
|
29
|
+
* @cssproperty {color} [--c2-textarea__supporting-text--color=#71717a]
|
|
30
|
+
* @cssproperty {color} [--c2-textarea__supporting-text__error--color=#dc2626]
|
|
31
|
+
*/
|
|
32
|
+
export declare class Textarea extends LitElement {
|
|
33
|
+
static styles: import("lit").CSSResult;
|
|
34
|
+
/** Current text. Set this property to update the value programmatically. */
|
|
35
|
+
value: string;
|
|
36
|
+
/** Name forwarded to the native control. */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Accessible name for the native textarea. */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Accessible name forwarded from the host. */
|
|
41
|
+
ariaLabel: string | null;
|
|
42
|
+
/** Hint shown when empty. */
|
|
43
|
+
placeholder: string;
|
|
44
|
+
/** Visible number of text lines. */
|
|
45
|
+
rows: number;
|
|
46
|
+
/** Native width hint, used when no CSS width is set. */
|
|
47
|
+
cols: number;
|
|
48
|
+
/** Allowed user resize directions. */
|
|
49
|
+
resize: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
50
|
+
/** Native line wrapping mode. */
|
|
51
|
+
wrap: 'soft' | 'hard' | 'off';
|
|
52
|
+
/** Browser autocomplete hint. */
|
|
53
|
+
autocomplete: string;
|
|
54
|
+
/** Prevents editing and removes the control from keyboard navigation. */
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
/** Prevents editing while allowing selection. */
|
|
57
|
+
readOnly: boolean;
|
|
58
|
+
/** Requires a nonempty value for native validation. */
|
|
59
|
+
required: boolean;
|
|
60
|
+
/** Maximum character count; -1 means unlimited. */
|
|
61
|
+
maxLength: number;
|
|
62
|
+
/** Minimum character count; -1 means no minimum. */
|
|
63
|
+
minLength: number;
|
|
64
|
+
/** Displays the error border and error text. */
|
|
65
|
+
error: boolean;
|
|
66
|
+
/** Message displayed when error is true. */
|
|
67
|
+
errorText: string;
|
|
68
|
+
/** Helper text below the control. */
|
|
69
|
+
help: string;
|
|
70
|
+
private dirty;
|
|
71
|
+
private hasSupportingSlot;
|
|
72
|
+
private input?;
|
|
73
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
74
|
+
/** Focuses the native textarea. */
|
|
75
|
+
focus(options?: FocusOptions): void;
|
|
76
|
+
blur(): void;
|
|
77
|
+
/** Selects all text. */
|
|
78
|
+
select(): void;
|
|
79
|
+
/** Selects a range of text using native UTF-16 character offsets. */
|
|
80
|
+
setSelectionRange(start: number, end: number, direction?: 'forward' | 'backward' | 'none'): void;
|
|
81
|
+
/** Whether the user has edited the value since the last reset. */
|
|
82
|
+
isDirty(): boolean;
|
|
83
|
+
/** Restores the value attribute and clears the error state. */
|
|
84
|
+
reset(): void;
|
|
85
|
+
/** Checks the native textarea constraints. Await updateComplete after changing properties. */
|
|
86
|
+
checkValidity(): boolean;
|
|
87
|
+
/** Shows the browser's validation feedback. */
|
|
88
|
+
reportValidity(): boolean;
|
|
89
|
+
/** Sets or clears the native validation message. */
|
|
90
|
+
setCustomValidity(message: string): void;
|
|
91
|
+
private handleInput;
|
|
92
|
+
private handleChange;
|
|
93
|
+
private handleSelect;
|
|
94
|
+
private handleSlotChange;
|
|
95
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
96
|
+
}
|
|
97
|
+
declare global {
|
|
98
|
+
interface HTMLElementTagNameMap {
|
|
99
|
+
'c2-textarea': Textarea;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -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