@xsolla/xui-textarea 0.148.0 → 0.148.2

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.
Files changed (2) hide show
  1. package/README.md +221 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # Textarea
2
+
3
+ A cross-platform React textarea component for multi-line text input. Includes error state and validation message support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-textarea
9
+ # or
10
+ yarn add @xsolla/xui-textarea
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Basic Textarea
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { TextArea } from '@xsolla/xui-textarea';
20
+
21
+ export default function BasicTextarea() {
22
+ const [value, setValue] = React.useState('');
23
+
24
+ return (
25
+ <TextArea
26
+ value={value}
27
+ onChangeText={setValue}
28
+ placeholder="Enter your message..."
29
+ />
30
+ );
31
+ }
32
+ ```
33
+
34
+ ### Textarea Sizes
35
+
36
+ ```tsx
37
+ import * as React from 'react';
38
+ import { TextArea } from '@xsolla/xui-textarea';
39
+
40
+ export default function TextareaSizes() {
41
+ return (
42
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
43
+ <TextArea size="xs" placeholder="Extra Small" />
44
+ <TextArea size="sm" placeholder="Small" />
45
+ <TextArea size="md" placeholder="Medium (default)" />
46
+ <TextArea size="lg" placeholder="Large" />
47
+ <TextArea size="xl" placeholder="Extra Large" />
48
+ </div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ### Textarea with Error
54
+
55
+ ```tsx
56
+ import * as React from 'react';
57
+ import { TextArea } from '@xsolla/xui-textarea';
58
+
59
+ export default function TextareaWithError() {
60
+ const [value, setValue] = React.useState('');
61
+ const maxLength = 100;
62
+
63
+ return (
64
+ <TextArea
65
+ value={value}
66
+ onChangeText={setValue}
67
+ placeholder="Enter description..."
68
+ errorMessage={value.length > maxLength ? `Maximum ${maxLength} characters allowed` : ''}
69
+ />
70
+ );
71
+ }
72
+ ```
73
+
74
+ ## Anatomy
75
+
76
+ Import the component and use it directly:
77
+
78
+ ```jsx
79
+ import { TextArea } from '@xsolla/xui-textarea';
80
+
81
+ <TextArea
82
+ value={text} // Controlled value
83
+ onChangeText={setText} // Value change handler
84
+ placeholder="Placeholder" // Placeholder text
85
+ size="md" // Size variant
86
+ disabled={false} // Disabled state
87
+ errorMessage="Error text" // Error message below textarea
88
+ />
89
+ ```
90
+
91
+ ## Examples
92
+
93
+ ### Comment Form
94
+
95
+ ```tsx
96
+ import * as React from 'react';
97
+ import { TextArea } from '@xsolla/xui-textarea';
98
+ import { Button } from '@xsolla/xui-button';
99
+
100
+ export default function CommentForm() {
101
+ const [comment, setComment] = React.useState('');
102
+
103
+ const handleSubmit = () => {
104
+ console.log('Comment:', comment);
105
+ setComment('');
106
+ };
107
+
108
+ return (
109
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
110
+ <TextArea
111
+ value={comment}
112
+ onChangeText={setComment}
113
+ placeholder="Write a comment..."
114
+ size="md"
115
+ />
116
+ <Button onPress={handleSubmit} disabled={!comment.trim()}>
117
+ Post Comment
118
+ </Button>
119
+ </div>
120
+ );
121
+ }
122
+ ```
123
+
124
+ ### Disabled Textarea
125
+
126
+ ```tsx
127
+ import * as React from 'react';
128
+ import { TextArea } from '@xsolla/xui-textarea';
129
+
130
+ export default function DisabledTextarea() {
131
+ return (
132
+ <TextArea
133
+ value="This content cannot be edited"
134
+ disabled
135
+ placeholder="Disabled textarea"
136
+ />
137
+ );
138
+ }
139
+ ```
140
+
141
+ ### Character Counter
142
+
143
+ ```tsx
144
+ import * as React from 'react';
145
+ import { TextArea } from '@xsolla/xui-textarea';
146
+
147
+ export default function TextareaWithCounter() {
148
+ const [value, setValue] = React.useState('');
149
+ const maxLength = 500;
150
+
151
+ return (
152
+ <div>
153
+ <TextArea
154
+ value={value}
155
+ onChangeText={setValue}
156
+ placeholder="Enter your bio..."
157
+ errorMessage={value.length > maxLength ? 'Character limit exceeded' : ''}
158
+ />
159
+ <div style={{ textAlign: 'right', fontSize: 12, color: value.length > maxLength ? 'red' : 'gray' }}>
160
+ {value.length}/{maxLength}
161
+ </div>
162
+ </div>
163
+ );
164
+ }
165
+ ```
166
+
167
+ ## API Reference
168
+
169
+ ### TextArea
170
+
171
+ A multi-line text input component.
172
+
173
+ **TextArea Props:**
174
+
175
+ | Prop | Type | Default | Description |
176
+ | :--- | :--- | :------ | :---------- |
177
+ | value | `string` | - | The controlled value of the textarea. |
178
+ | placeholder | `string` | - | Placeholder text when empty. |
179
+ | onChangeText | `(text: string) => void` | - | Callback when text changes. |
180
+ | size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Size of the textarea. |
181
+ | disabled | `boolean` | `false` | Whether the textarea is disabled. |
182
+ | errorMessage | `string` | - | Error message displayed below. |
183
+ | aria-label | `string` | - | Accessible label. |
184
+ | aria-describedby | `string` | - | ID of description element. |
185
+ | id | `string` | - | HTML id attribute. |
186
+ | testID | `string` | - | Test identifier. |
187
+
188
+ **Padding by Size:**
189
+
190
+ | Size | Padding |
191
+ | :--- | :------ |
192
+ | xl | 16px |
193
+ | lg | 14px |
194
+ | md | 12px |
195
+ | sm | 10px |
196
+ | xs | 10px |
197
+
198
+ ## Theming
199
+
200
+ TextArea uses the design system theme for colors:
201
+
202
+ ```typescript
203
+ // Colors accessed via theme
204
+ theme.colors.control.input.bg // Background color
205
+ theme.colors.control.input.bgFocus // Focus background
206
+ theme.colors.control.input.border // Border color
207
+ theme.colors.control.input.borderFocus // Focus border
208
+ theme.colors.control.input.borderError // Error border
209
+ theme.colors.control.input.text // Text color
210
+ theme.colors.control.input.placeholder // Placeholder color
211
+ theme.colors.content.error // Error message color
212
+ ```
213
+
214
+ ## Accessibility
215
+
216
+ - Uses native `<textarea>` element
217
+ - `aria-invalid` set when error message present
218
+ - `aria-disabled` for disabled state
219
+ - `aria-describedby` links to error message
220
+ - Error message has `role="alert"` for announcements
221
+ - Focus indicator follows WCAG guidelines
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-textarea",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -13,8 +13,8 @@
13
13
  "test:coverage": "vitest run --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@xsolla/xui-core": "0.148.0",
17
- "@xsolla/xui-primitives-core": "0.148.0"
16
+ "@xsolla/xui-core": "0.148.2",
17
+ "@xsolla/xui-primitives-core": "0.148.2"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "react": ">=16.8.0",