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