uni-textarea-field 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paul
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,237 @@
1
+ # uni-textarea-field
2
+
3
+ [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/uni-input-field) [![DeepScan grade](https://deepscan.io/api/teams/16372/projects/31962/branches/1038048/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=16372&pid=31962&bid=1038048)
4
+
5
+ <uni-textarea-field /> is an encapsulated Web Component built upon the foundation of the uniopen design language.
6
+
7
+ Implementation is straightforward: simply slot a standard textarea element inside <uni-textarea-field />. The component instantly applies a user interface that aligns seamlessly with the uniopen design language guidelines. Furthermore, its visual styles can be dynamically adapted via native HTML attributes or JavaScript properties.
8
+
9
+ The component also exposes comprehensive character count and textarea length metadata, providing users with a clear and intuitive understanding of predefined character constraints.
10
+
11
+ ![<uni-textarea-field />](https://blog.lalacube.com/mei/img/preview/uni-textarea-field.png)
12
+
13
+ ## Basic Usage
14
+
15
+ &lt;uni-textarea-field /> is a web component. All we need to do is put the required script into your HTML document. Then follow &lt;uni-textarea-field />'s html structure and everything will be all set.
16
+
17
+ - Required Script
18
+
19
+ ```html
20
+ <script
21
+ type="module"
22
+ src="https://unpkg.com/uni-textarea-field/mjs/wc-uni-textarea-field.js">
23
+ </script>
24
+ ```
25
+
26
+ - Structure
27
+
28
+ Put &lt;uni-textarea-field /> into HTML document. It will have different functions and looks with attribute mutation.
29
+
30
+ ```html
31
+ <uni-textarea-field subject="Subject" message="Supporting text">
32
+ <textarea
33
+ slot="textarea"
34
+ placeholder="placeholder"
35
+ required
36
+ maxlength="30"
37
+ ></textarea>
38
+ </uni-textarea-field>
39
+ ```
40
+
41
+ &lt;uni-textarea-field /> dynamically adjusts its user interface and core functionality by strictly adhering to the attributes of the encapsulated `textarea` element. Developers can leverage these capabilities and observe the corresponding behavioral shifts by modifying standard attributes—such as `readonly`, `disabled`, `required`, and `maxlength`—directly on the textarea element.
42
+
43
+ ```html
44
+ <uni-textarea-field>
45
+ <textarea
46
+ slot="textarea"
47
+ readonly
48
+ required
49
+ ><textarea>
50
+ </uni-textarea-field>
51
+ ```
52
+
53
+ ## JavaScript Instantiation
54
+
55
+ &lt;uni-textarea-field /> could also use JavaScript to create DOM element. Here comes some examples.
56
+
57
+ ```html
58
+ <script type="module">
59
+ import { UniTextareaField } from 'https://unpkg.com/uni-textarea-field/mjs/wc-uni-textarea-field.js';
60
+
61
+ const textareaTemplate = document.querySelector('.my-textarea-template');
62
+
63
+ // use DOM api
64
+ const nodeA = document.createElement('uni-textarea-field');
65
+ nodeA.appendChild(textareaTemplate.content.cloneNode(true));
66
+ document.body.appendChild(nodeA);
67
+
68
+ // new instance with Class
69
+ const nodeB = new UniTextareaField();
70
+ nodeB.appendChild(textareaTemplate.content.cloneNode(true));
71
+ document.body.appendChild(nodeB);
72
+ </script>
73
+ ```
74
+
75
+ ## Style Customization
76
+
77
+ Developers could apply styles to decorate &lt;uni-textarea-field />'s looking.
78
+
79
+ ```html
80
+ <style>
81
+ uni-textarea-field {
82
+ --uni-textarea-field-border-color-normal: transparent;
83
+ --uni-textarea-field-border-color-readonly: var(--ct_input-general_dim_container_default);
84
+ --uni-textarea-field-border-color-disabled: var(--ct_input-general_dim_container_default);
85
+ --uni-textarea-field-border-color-valid: var(--ct_text_success_general);
86
+ --uni-textarea-field-border-color-invalid: var(--ct_text_danger_general);
87
+ --uni-textarea-field-border-color-outline: var(--ct_input-general_main_stroke_default);
88
+
89
+ --uni-textarea-field-background-color-normal: var(--ct_input-general_dim_container_default);
90
+ --uni-textarea-field-background-color-readonly: var(--ct_input-general_dim_container_default);
91
+ --uni-textarea-field-background-color-disabled: var(--ct_input-general_dim_container_default);
92
+
93
+ --uni-textarea-field-placeholder-color-normal: var(--ct_text_main_subtlest);
94
+ --uni-textarea-field-placeholder-color-readonly: var(--ct_text_main_subtlest);
95
+ --uni-textarea-field-placeholder-color-disabled: var(--ct_text_main_subtlest);
96
+
97
+ --uni-textarea-field-text-color-normal: var(--ct_text_main_general);
98
+ --uni-textarea-field-text-color-readonly: var(--ct_text_main_general);
99
+ --uni-textarea-field-text-color-disabled: var(--ct_text_main_pale);
100
+ --uni-textarea-field-text-color-invalid: var(--ct_text_danger_general);
101
+
102
+ --uni-textarea-field-message-color-normal: var(--ct_text_main_subtle);
103
+ --uni-textarea-field-message-color-valid: var(--ct_text_success_general);
104
+ --uni-textarea-field-message-color-invalid: var(--ct_text_danger_general);
105
+
106
+ --uni-textarea-field-subject-color: var(--ct_text_main_subtle);
107
+ --uni-textarea-field-counter-color: var(--ct_text_main_subtle);
108
+ --uni-textarea-field-caret-color: var(--ct_input-caret_main_general);
109
+
110
+ --uni-textarea-field-min-block-size: 100px;
111
+ }
112
+ </style>
113
+ ```
114
+
115
+ &lt;uni-textarea-field /> also leverages the CSS ::part() selector, enabling developers to directly customize and style the icon.
116
+
117
+ ```html
118
+ <style>
119
+ uni-textarea-field {
120
+ &::part(icon-subject) {
121
+ ...
122
+ }
123
+ }
124
+ </style>
125
+ ```
126
+
127
+ Alternatively, developers can utilize the `data-hide-counter` data attribute to suppress the character counter.
128
+
129
+ ```html
130
+ <uni-textarea-field data-hide-counter>
131
+ <textarea>
132
+ slot="textarea"
133
+ placeholder="placeholder"
134
+ required
135
+ maxlength="30"
136
+ ><textarea>
137
+ </uni-textarea-field>
138
+ ```
139
+
140
+ ## Attributes
141
+
142
+ &lt;uni-textarea-field /> component exposes a curated set of attributes, enabling developers to dynamically adjust the user interface. This provides the flexibility to tailor the component’s appearance to seamlessly adapt to any given context.
143
+
144
+ - **size**
145
+
146
+ The `size` attribute configures the overall dimensions of &lt;uni-textarea-field />. The component currently supports three standard options: `large`, `medium`, and `small`, defaulting to `medium`.
147
+
148
+ ```html
149
+ <uni-textarea-field
150
+ size="large"
151
+ >
152
+ <textarea
153
+ slot="textarea"
154
+ maxlength="200"
155
+ ><textarea>
156
+ </uni-textarea-field>
157
+ ```
158
+
159
+ - **subject**
160
+
161
+ The `subject` attribute controls the dynamic rendering of the subject content on &lt;uni-textarea-field />. By default, it is set to an empty string, meaning no content will be displayed.
162
+
163
+ ```html
164
+ <uni-textarea-field
165
+ subject="Your subject"
166
+ >
167
+ <textarea
168
+ slot="textarea"
169
+ maxlength="200"
170
+ ><textarea>
171
+ </uni-textarea-field>
172
+ ```
173
+
174
+ - **message**
175
+
176
+ The `message` attribute controls the dynamic rendering of the message content on &lt;uni-textarea-field />. By default, it is set to an empty string, meaning no content will be displayed.
177
+
178
+ ```html
179
+ <uni-textarea-field
180
+ message="Your message content"
181
+ >
182
+ <textarea
183
+ slot="textarea"
184
+ maxlength="200"
185
+ required
186
+ ><textarea>
187
+ </uni-textarea-field>
188
+ ```
189
+
190
+ - **stat**
191
+
192
+ Through variations in the `stat` attribute, &lt;uni-textarea-field /> can dynamically transition between `valid` and `invalid` visual states, providing users with clear feedback on input correctness. By default, it is set to an empty string, which represents the standard, neutral state.
193
+
194
+ ```html
195
+ <uni-textarea-field
196
+ stat="invalid"
197
+ >
198
+ <textarea
199
+ slot="textarea"
200
+ maxlength="200"
201
+ ><textarea>
202
+ </uni-textarea-field>
203
+ ```
204
+
205
+ - **appearance**
206
+
207
+ Currently, &lt;uni-textarea-field /> supports two distinct visual variants: `filled` and `outlined`. Developers can utilize the appearance attribute to configure the desired layout, which defaults to `filled`.
208
+
209
+ ```html
210
+ <uni-textarea-field
211
+ appearance="outlined"
212
+ >
213
+ <textarea
214
+ slot="textarea"
215
+ maxlength="200"
216
+ readonly
217
+ ><textarea>
218
+ </uni-textarea-field>
219
+ ```
220
+
221
+ ## Properties
222
+
223
+ | Property Name | Type | Description |
224
+ | ----------- | ----------- | ----------- |
225
+ | size | String | Getter / Setter size. `size` configures the overall dimensions of &lt;uni-textarea-field />. The component currently supports three standard options: `large`, `medium`, and `small`, defaulting to `medium`. |
226
+ | subject| String | Getter / Setter subject. `subject` controls the dynamic rendering of the subject content on &lt;uni-textarea-field />. By default, it is set to an empty string, meaning no content will be displayed. |
227
+ | message| String | Getter / Setter message. `message` controls the dynamic rendering of the message content on &lt;uni-textarea-field />. By default, it is set to an empty string, meaning no content will be displayed. |
228
+ | stat| String | Getter / Setter stat. `stat` can dynamically transition between `valid` and `invalid` visual states, providing users with clear feedback on input correctness. By default, it is set to an empty string, which represents the standard, neutral state. |
229
+ | appearance| String | Getter / Setter appearance. `appearance` supports two distinct visual variants: `filled` and `outlined`. Developers can utilize the appearance attribute to configure the desired layout, which defaults to `filled`. |
230
+
231
+ ## Method
232
+ | Mathod Signature | Description |
233
+ | ----------- | ----------- |
234
+ | refresh() | Force a UI refresh on &lt;uni-textarea-field />. |
235
+
236
+ ## Reference
237
+ - [&lt;uni-textarea-field /> demo](https://blog.lalacube.com/mei/webComponent_uni-textarea-field.html)