@xsolla/xui-textarea 0.64.0-pr56.1768440195
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/native/index.d.mts +42 -0
- package/native/index.d.ts +42 -0
- package/native/index.js +628 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +595 -0
- package/native/index.mjs.map +1 -0
- package/package.json +46 -0
- package/web/index.d.mts +42 -0
- package/web/index.d.ts +42 -0
- package/web/index.js +616 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +579 -0
- package/web/index.mjs.map +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface TextAreaProps {
|
|
4
|
+
/** Current value of the textarea */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Placeholder text when empty */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Event handler when the text changes */
|
|
9
|
+
onChangeText?: (text: string) => void;
|
|
10
|
+
/** Size of the textarea */
|
|
11
|
+
size?: "xl" | "l" | "m" | "s" | "xs";
|
|
12
|
+
/** Whether the textarea is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Error message displayed below the textarea */
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
/** Accessible label for screen readers */
|
|
17
|
+
"aria-label"?: string;
|
|
18
|
+
/** ID of element that describes this textarea */
|
|
19
|
+
"aria-describedby"?: string;
|
|
20
|
+
/** Unique identifier for the textarea element */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** Test ID for testing frameworks */
|
|
23
|
+
testID?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* TextArea - An accessible multi-line text input component
|
|
27
|
+
*
|
|
28
|
+
* Renders as a semantic `<textarea>` element with full ARIA support.
|
|
29
|
+
* Supports labels, error states, and various sizes.
|
|
30
|
+
*
|
|
31
|
+
* ## Accessibility Features
|
|
32
|
+
*
|
|
33
|
+
* - **Semantic HTML**: Renders as a native `<textarea>` element
|
|
34
|
+
* - **Keyboard Navigation**: Focusable via Tab
|
|
35
|
+
* - **ARIA States**: Properly announces disabled and error states
|
|
36
|
+
* - **Error Announcements**: Error messages use `role="alert"` for immediate announcement
|
|
37
|
+
* - **Focus Indicator**: Visible focus ring for keyboard navigation
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
41
|
+
|
|
42
|
+
export { TextArea, type TextAreaProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface TextAreaProps {
|
|
4
|
+
/** Current value of the textarea */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Placeholder text when empty */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Event handler when the text changes */
|
|
9
|
+
onChangeText?: (text: string) => void;
|
|
10
|
+
/** Size of the textarea */
|
|
11
|
+
size?: "xl" | "l" | "m" | "s" | "xs";
|
|
12
|
+
/** Whether the textarea is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Error message displayed below the textarea */
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
/** Accessible label for screen readers */
|
|
17
|
+
"aria-label"?: string;
|
|
18
|
+
/** ID of element that describes this textarea */
|
|
19
|
+
"aria-describedby"?: string;
|
|
20
|
+
/** Unique identifier for the textarea element */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** Test ID for testing frameworks */
|
|
23
|
+
testID?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* TextArea - An accessible multi-line text input component
|
|
27
|
+
*
|
|
28
|
+
* Renders as a semantic `<textarea>` element with full ARIA support.
|
|
29
|
+
* Supports labels, error states, and various sizes.
|
|
30
|
+
*
|
|
31
|
+
* ## Accessibility Features
|
|
32
|
+
*
|
|
33
|
+
* - **Semantic HTML**: Renders as a native `<textarea>` element
|
|
34
|
+
* - **Keyboard Navigation**: Focusable via Tab
|
|
35
|
+
* - **ARIA States**: Properly announces disabled and error states
|
|
36
|
+
* - **Error Announcements**: Error messages use `role="alert"` for immediate announcement
|
|
37
|
+
* - **Focus Indicator**: Visible focus ring for keyboard navigation
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
41
|
+
|
|
42
|
+
export { TextArea, type TextAreaProps };
|
package/native/index.js
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
TextArea: () => TextArea
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/TextArea.tsx
|
|
38
|
+
var import_react4 = require("react");
|
|
39
|
+
|
|
40
|
+
// ../primitives-native/src/Box.tsx
|
|
41
|
+
var import_react_native = require("react-native");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var Box = ({
|
|
44
|
+
children,
|
|
45
|
+
onPress,
|
|
46
|
+
onLayout,
|
|
47
|
+
onMoveShouldSetResponder,
|
|
48
|
+
onResponderGrant,
|
|
49
|
+
onResponderMove,
|
|
50
|
+
onResponderRelease,
|
|
51
|
+
onResponderTerminate,
|
|
52
|
+
backgroundColor,
|
|
53
|
+
borderColor,
|
|
54
|
+
borderWidth,
|
|
55
|
+
borderBottomWidth,
|
|
56
|
+
borderBottomColor,
|
|
57
|
+
borderTopWidth,
|
|
58
|
+
borderTopColor,
|
|
59
|
+
borderLeftWidth,
|
|
60
|
+
borderLeftColor,
|
|
61
|
+
borderRightWidth,
|
|
62
|
+
borderRightColor,
|
|
63
|
+
borderRadius,
|
|
64
|
+
borderStyle,
|
|
65
|
+
height,
|
|
66
|
+
padding,
|
|
67
|
+
paddingHorizontal,
|
|
68
|
+
paddingVertical,
|
|
69
|
+
margin,
|
|
70
|
+
marginTop,
|
|
71
|
+
marginBottom,
|
|
72
|
+
marginLeft,
|
|
73
|
+
marginRight,
|
|
74
|
+
flexDirection,
|
|
75
|
+
alignItems,
|
|
76
|
+
justifyContent,
|
|
77
|
+
position,
|
|
78
|
+
top,
|
|
79
|
+
bottom,
|
|
80
|
+
left,
|
|
81
|
+
right,
|
|
82
|
+
width,
|
|
83
|
+
flex,
|
|
84
|
+
overflow,
|
|
85
|
+
zIndex,
|
|
86
|
+
hoverStyle,
|
|
87
|
+
pressStyle,
|
|
88
|
+
style,
|
|
89
|
+
"data-testid": dataTestId,
|
|
90
|
+
testID,
|
|
91
|
+
as,
|
|
92
|
+
src,
|
|
93
|
+
alt,
|
|
94
|
+
...rest
|
|
95
|
+
}) => {
|
|
96
|
+
const getContainerStyle = (pressed) => ({
|
|
97
|
+
backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
|
|
98
|
+
borderColor,
|
|
99
|
+
borderWidth,
|
|
100
|
+
borderBottomWidth,
|
|
101
|
+
borderBottomColor,
|
|
102
|
+
borderTopWidth,
|
|
103
|
+
borderTopColor,
|
|
104
|
+
borderLeftWidth,
|
|
105
|
+
borderLeftColor,
|
|
106
|
+
borderRightWidth,
|
|
107
|
+
borderRightColor,
|
|
108
|
+
borderRadius,
|
|
109
|
+
borderStyle,
|
|
110
|
+
overflow,
|
|
111
|
+
zIndex,
|
|
112
|
+
height,
|
|
113
|
+
width,
|
|
114
|
+
padding,
|
|
115
|
+
paddingHorizontal,
|
|
116
|
+
paddingVertical,
|
|
117
|
+
margin,
|
|
118
|
+
marginTop,
|
|
119
|
+
marginBottom,
|
|
120
|
+
marginLeft,
|
|
121
|
+
marginRight,
|
|
122
|
+
flexDirection,
|
|
123
|
+
alignItems,
|
|
124
|
+
justifyContent,
|
|
125
|
+
position,
|
|
126
|
+
top,
|
|
127
|
+
bottom,
|
|
128
|
+
left,
|
|
129
|
+
right,
|
|
130
|
+
flex,
|
|
131
|
+
...style
|
|
132
|
+
});
|
|
133
|
+
const finalTestID = dataTestId || testID;
|
|
134
|
+
const {
|
|
135
|
+
role,
|
|
136
|
+
tabIndex,
|
|
137
|
+
onKeyDown,
|
|
138
|
+
onKeyUp,
|
|
139
|
+
"aria-label": _ariaLabel,
|
|
140
|
+
"aria-labelledby": _ariaLabelledBy,
|
|
141
|
+
"aria-current": _ariaCurrent,
|
|
142
|
+
"aria-disabled": _ariaDisabled,
|
|
143
|
+
"aria-live": _ariaLive,
|
|
144
|
+
className,
|
|
145
|
+
"data-testid": _dataTestId,
|
|
146
|
+
...nativeRest
|
|
147
|
+
} = rest;
|
|
148
|
+
if (as === "img" && src) {
|
|
149
|
+
const imageStyle = {
|
|
150
|
+
width,
|
|
151
|
+
height,
|
|
152
|
+
borderRadius,
|
|
153
|
+
position,
|
|
154
|
+
top,
|
|
155
|
+
bottom,
|
|
156
|
+
left,
|
|
157
|
+
right,
|
|
158
|
+
...style
|
|
159
|
+
};
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
+
import_react_native.Image,
|
|
162
|
+
{
|
|
163
|
+
source: { uri: src },
|
|
164
|
+
style: imageStyle,
|
|
165
|
+
testID: finalTestID,
|
|
166
|
+
resizeMode: "cover",
|
|
167
|
+
...nativeRest
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
if (onPress) {
|
|
172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
173
|
+
import_react_native.Pressable,
|
|
174
|
+
{
|
|
175
|
+
onPress,
|
|
176
|
+
onLayout,
|
|
177
|
+
onMoveShouldSetResponder,
|
|
178
|
+
onResponderGrant,
|
|
179
|
+
onResponderMove,
|
|
180
|
+
onResponderRelease,
|
|
181
|
+
onResponderTerminate,
|
|
182
|
+
style: ({ pressed }) => getContainerStyle(pressed),
|
|
183
|
+
testID: finalTestID,
|
|
184
|
+
...nativeRest,
|
|
185
|
+
children
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
190
|
+
import_react_native.View,
|
|
191
|
+
{
|
|
192
|
+
style: getContainerStyle(),
|
|
193
|
+
testID: finalTestID,
|
|
194
|
+
onLayout,
|
|
195
|
+
onMoveShouldSetResponder,
|
|
196
|
+
onResponderGrant,
|
|
197
|
+
onResponderMove,
|
|
198
|
+
onResponderRelease,
|
|
199
|
+
onResponderTerminate,
|
|
200
|
+
...nativeRest,
|
|
201
|
+
children
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// ../primitives-native/src/Text.tsx
|
|
207
|
+
var import_react_native2 = require("react-native");
|
|
208
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
209
|
+
var roleMap = {
|
|
210
|
+
alert: "alert",
|
|
211
|
+
heading: "header",
|
|
212
|
+
button: "button",
|
|
213
|
+
link: "link",
|
|
214
|
+
text: "text"
|
|
215
|
+
};
|
|
216
|
+
var Text = ({
|
|
217
|
+
children,
|
|
218
|
+
color,
|
|
219
|
+
fontSize,
|
|
220
|
+
fontWeight,
|
|
221
|
+
fontFamily,
|
|
222
|
+
id,
|
|
223
|
+
role,
|
|
224
|
+
...props
|
|
225
|
+
}) => {
|
|
226
|
+
let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
|
|
227
|
+
if (resolvedFontFamily === "Pilat Wide Bold") {
|
|
228
|
+
resolvedFontFamily = void 0;
|
|
229
|
+
}
|
|
230
|
+
const style = {
|
|
231
|
+
color,
|
|
232
|
+
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
233
|
+
fontWeight,
|
|
234
|
+
fontFamily: resolvedFontFamily,
|
|
235
|
+
textDecorationLine: props.textDecoration
|
|
236
|
+
};
|
|
237
|
+
const accessibilityRole = role ? roleMap[role] : void 0;
|
|
238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// ../primitives-native/src/Spinner.tsx
|
|
242
|
+
var import_react_native3 = require("react-native");
|
|
243
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
244
|
+
var Spinner = ({
|
|
245
|
+
color,
|
|
246
|
+
size,
|
|
247
|
+
role,
|
|
248
|
+
"aria-label": ariaLabel,
|
|
249
|
+
"aria-live": ariaLive,
|
|
250
|
+
"aria-describedby": ariaDescribedBy,
|
|
251
|
+
testID
|
|
252
|
+
}) => {
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
254
|
+
import_react_native3.View,
|
|
255
|
+
{
|
|
256
|
+
accessible: true,
|
|
257
|
+
accessibilityRole: role === "status" ? "none" : void 0,
|
|
258
|
+
accessibilityLabel: ariaLabel,
|
|
259
|
+
accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
|
|
260
|
+
testID,
|
|
261
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
262
|
+
import_react_native3.ActivityIndicator,
|
|
263
|
+
{
|
|
264
|
+
color,
|
|
265
|
+
size: typeof size === "number" ? size : "small"
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
Spinner.displayName = "Spinner";
|
|
272
|
+
|
|
273
|
+
// ../primitives-native/src/Icon.tsx
|
|
274
|
+
var import_react = __toESM(require("react"));
|
|
275
|
+
var import_react_native4 = require("react-native");
|
|
276
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
277
|
+
|
|
278
|
+
// ../primitives-native/src/Divider.tsx
|
|
279
|
+
var import_react_native5 = require("react-native");
|
|
280
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
281
|
+
|
|
282
|
+
// ../primitives-native/src/Input.tsx
|
|
283
|
+
var import_react2 = require("react");
|
|
284
|
+
var import_react_native6 = require("react-native");
|
|
285
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
286
|
+
var keyboardTypeMap = {
|
|
287
|
+
text: "default",
|
|
288
|
+
number: "numeric",
|
|
289
|
+
email: "email-address",
|
|
290
|
+
tel: "phone-pad",
|
|
291
|
+
url: "url",
|
|
292
|
+
decimal: "decimal-pad"
|
|
293
|
+
};
|
|
294
|
+
var inputModeToKeyboardType = {
|
|
295
|
+
none: "default",
|
|
296
|
+
text: "default",
|
|
297
|
+
decimal: "decimal-pad",
|
|
298
|
+
numeric: "number-pad",
|
|
299
|
+
tel: "phone-pad",
|
|
300
|
+
search: "default",
|
|
301
|
+
email: "email-address",
|
|
302
|
+
url: "url"
|
|
303
|
+
};
|
|
304
|
+
var autoCompleteToTextContentType = {
|
|
305
|
+
"one-time-code": "oneTimeCode",
|
|
306
|
+
email: "emailAddress",
|
|
307
|
+
username: "username",
|
|
308
|
+
password: "password",
|
|
309
|
+
"new-password": "newPassword",
|
|
310
|
+
tel: "telephoneNumber",
|
|
311
|
+
"postal-code": "postalCode",
|
|
312
|
+
name: "name"
|
|
313
|
+
};
|
|
314
|
+
var InputPrimitive = (0, import_react2.forwardRef)(
|
|
315
|
+
({
|
|
316
|
+
value,
|
|
317
|
+
placeholder,
|
|
318
|
+
onChange,
|
|
319
|
+
onChangeText,
|
|
320
|
+
onFocus,
|
|
321
|
+
onBlur,
|
|
322
|
+
onKeyDown,
|
|
323
|
+
disabled,
|
|
324
|
+
secureTextEntry,
|
|
325
|
+
style,
|
|
326
|
+
color,
|
|
327
|
+
fontSize,
|
|
328
|
+
placeholderTextColor,
|
|
329
|
+
maxLength,
|
|
330
|
+
name,
|
|
331
|
+
type,
|
|
332
|
+
inputMode,
|
|
333
|
+
autoComplete,
|
|
334
|
+
id,
|
|
335
|
+
"aria-invalid": ariaInvalid,
|
|
336
|
+
"aria-describedby": ariaDescribedBy,
|
|
337
|
+
"aria-labelledby": ariaLabelledBy,
|
|
338
|
+
"aria-label": ariaLabel,
|
|
339
|
+
"aria-disabled": ariaDisabled,
|
|
340
|
+
"data-testid": dataTestId
|
|
341
|
+
}, ref) => {
|
|
342
|
+
const handleChangeText = (text) => {
|
|
343
|
+
onChangeText?.(text);
|
|
344
|
+
if (onChange) {
|
|
345
|
+
const syntheticEvent = {
|
|
346
|
+
target: { value: text },
|
|
347
|
+
currentTarget: { value: text },
|
|
348
|
+
type: "change",
|
|
349
|
+
nativeEvent: { text },
|
|
350
|
+
preventDefault: () => {
|
|
351
|
+
},
|
|
352
|
+
stopPropagation: () => {
|
|
353
|
+
},
|
|
354
|
+
isTrusted: false
|
|
355
|
+
};
|
|
356
|
+
onChange(syntheticEvent);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
|
|
360
|
+
const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
|
|
361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
362
|
+
import_react_native6.TextInput,
|
|
363
|
+
{
|
|
364
|
+
ref,
|
|
365
|
+
value,
|
|
366
|
+
placeholder,
|
|
367
|
+
onChangeText: handleChangeText,
|
|
368
|
+
onFocus,
|
|
369
|
+
onBlur,
|
|
370
|
+
onKeyPress: (e) => {
|
|
371
|
+
if (onKeyDown) {
|
|
372
|
+
onKeyDown({
|
|
373
|
+
key: e.nativeEvent.key,
|
|
374
|
+
preventDefault: () => {
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
editable: !disabled,
|
|
380
|
+
secureTextEntry: secureTextEntry || type === "password",
|
|
381
|
+
keyboardType,
|
|
382
|
+
textContentType,
|
|
383
|
+
style: [
|
|
384
|
+
{
|
|
385
|
+
color,
|
|
386
|
+
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
387
|
+
flex: 1,
|
|
388
|
+
padding: 0,
|
|
389
|
+
textAlign: style?.textAlign || "left"
|
|
390
|
+
},
|
|
391
|
+
style
|
|
392
|
+
],
|
|
393
|
+
placeholderTextColor,
|
|
394
|
+
maxLength,
|
|
395
|
+
testID: dataTestId || id,
|
|
396
|
+
accessibilityLabel: ariaLabel,
|
|
397
|
+
accessibilityHint: ariaDescribedBy,
|
|
398
|
+
accessibilityState: {
|
|
399
|
+
disabled: disabled || ariaDisabled
|
|
400
|
+
},
|
|
401
|
+
accessible: true
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
InputPrimitive.displayName = "InputPrimitive";
|
|
407
|
+
|
|
408
|
+
// ../primitives-native/src/TextArea.tsx
|
|
409
|
+
var import_react3 = require("react");
|
|
410
|
+
var import_react_native7 = require("react-native");
|
|
411
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
412
|
+
var TextAreaPrimitive = (0, import_react3.forwardRef)(
|
|
413
|
+
({
|
|
414
|
+
value,
|
|
415
|
+
placeholder,
|
|
416
|
+
onChange,
|
|
417
|
+
onChangeText,
|
|
418
|
+
onFocus,
|
|
419
|
+
onBlur,
|
|
420
|
+
onKeyDown,
|
|
421
|
+
disabled,
|
|
422
|
+
style,
|
|
423
|
+
color,
|
|
424
|
+
fontSize,
|
|
425
|
+
placeholderTextColor,
|
|
426
|
+
maxLength,
|
|
427
|
+
rows,
|
|
428
|
+
id,
|
|
429
|
+
"aria-invalid": ariaInvalid,
|
|
430
|
+
"aria-describedby": ariaDescribedBy,
|
|
431
|
+
"aria-labelledby": ariaLabelledBy,
|
|
432
|
+
"aria-label": ariaLabel,
|
|
433
|
+
"aria-disabled": ariaDisabled,
|
|
434
|
+
"data-testid": dataTestId
|
|
435
|
+
}, ref) => {
|
|
436
|
+
const handleChangeText = (text) => {
|
|
437
|
+
onChangeText?.(text);
|
|
438
|
+
if (onChange) {
|
|
439
|
+
const syntheticEvent = {
|
|
440
|
+
target: { value: text },
|
|
441
|
+
currentTarget: { value: text },
|
|
442
|
+
type: "change",
|
|
443
|
+
nativeEvent: { text },
|
|
444
|
+
preventDefault: () => {
|
|
445
|
+
},
|
|
446
|
+
stopPropagation: () => {
|
|
447
|
+
},
|
|
448
|
+
isTrusted: false
|
|
449
|
+
};
|
|
450
|
+
onChange(syntheticEvent);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
454
|
+
import_react_native7.TextInput,
|
|
455
|
+
{
|
|
456
|
+
ref,
|
|
457
|
+
value,
|
|
458
|
+
placeholder,
|
|
459
|
+
onChangeText: handleChangeText,
|
|
460
|
+
onFocus,
|
|
461
|
+
onBlur,
|
|
462
|
+
onKeyPress: (e) => {
|
|
463
|
+
if (onKeyDown) {
|
|
464
|
+
onKeyDown({
|
|
465
|
+
key: e.nativeEvent.key,
|
|
466
|
+
preventDefault: () => {
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
editable: !disabled,
|
|
472
|
+
multiline: true,
|
|
473
|
+
numberOfLines: rows || 4,
|
|
474
|
+
style: [
|
|
475
|
+
{
|
|
476
|
+
color,
|
|
477
|
+
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
478
|
+
flex: 1,
|
|
479
|
+
padding: 0,
|
|
480
|
+
textAlignVertical: "top",
|
|
481
|
+
textAlign: style?.textAlign || "left"
|
|
482
|
+
},
|
|
483
|
+
style
|
|
484
|
+
],
|
|
485
|
+
placeholderTextColor,
|
|
486
|
+
maxLength,
|
|
487
|
+
testID: dataTestId || id,
|
|
488
|
+
accessibilityLabel: ariaLabel,
|
|
489
|
+
accessibilityHint: ariaDescribedBy,
|
|
490
|
+
accessibilityState: {
|
|
491
|
+
disabled: disabled || ariaDisabled
|
|
492
|
+
},
|
|
493
|
+
accessible: true
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
);
|
|
498
|
+
TextAreaPrimitive.displayName = "TextAreaPrimitive";
|
|
499
|
+
|
|
500
|
+
// src/TextArea.tsx
|
|
501
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
502
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
503
|
+
var paddingMap = {
|
|
504
|
+
xl: 16,
|
|
505
|
+
l: 14,
|
|
506
|
+
m: 12,
|
|
507
|
+
s: 10,
|
|
508
|
+
xs: 10
|
|
509
|
+
};
|
|
510
|
+
var TextArea = (0, import_react4.forwardRef)(
|
|
511
|
+
({
|
|
512
|
+
value,
|
|
513
|
+
placeholder,
|
|
514
|
+
onChangeText,
|
|
515
|
+
size = "m",
|
|
516
|
+
disabled = false,
|
|
517
|
+
errorMessage,
|
|
518
|
+
"aria-label": ariaLabel,
|
|
519
|
+
"aria-describedby": ariaDescribedBy,
|
|
520
|
+
id: externalId,
|
|
521
|
+
testID
|
|
522
|
+
}, ref) => {
|
|
523
|
+
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
524
|
+
const [isFocused, setIsFocused] = (0, import_react4.useState)(false);
|
|
525
|
+
const generatedId = (0, import_xui_core.useId)();
|
|
526
|
+
const textareaId = externalId || generatedId;
|
|
527
|
+
const errorId = `${textareaId}-error`;
|
|
528
|
+
const isError = !!errorMessage;
|
|
529
|
+
const sizeStyles = theme.sizing.textarea(size);
|
|
530
|
+
const inputColors = theme.colors.control.input;
|
|
531
|
+
const handleFocus = () => {
|
|
532
|
+
if (!disabled) {
|
|
533
|
+
setIsFocused(true);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
const handleBlur = () => {
|
|
537
|
+
if (!disabled) {
|
|
538
|
+
setIsFocused(false);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
let backgroundColor = inputColors.bg;
|
|
542
|
+
let borderColor = inputColors.border;
|
|
543
|
+
if (disabled) {
|
|
544
|
+
backgroundColor = inputColors.bgDisable;
|
|
545
|
+
borderColor = inputColors.borderDisable;
|
|
546
|
+
} else if (isError) {
|
|
547
|
+
borderColor = theme.colors.border.alert;
|
|
548
|
+
} else if (isFocused) {
|
|
549
|
+
backgroundColor = theme.colors.control.focus.bg;
|
|
550
|
+
borderColor = inputColors.borderHover;
|
|
551
|
+
}
|
|
552
|
+
const textColor = disabled ? inputColors.textDisable : inputColors.text;
|
|
553
|
+
const placeholderColor = inputColors.placeholder;
|
|
554
|
+
const describedByIds = [];
|
|
555
|
+
if (isError) {
|
|
556
|
+
describedByIds.push(errorId);
|
|
557
|
+
}
|
|
558
|
+
if (ariaDescribedBy) {
|
|
559
|
+
describedByIds.push(ariaDescribedBy);
|
|
560
|
+
}
|
|
561
|
+
const computedDescribedBy = describedByIds.length > 0 ? describedByIds.join(" ") : void 0;
|
|
562
|
+
const outlineColor = isFocused && !disabled ? theme.colors.border.brand : void 0;
|
|
563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "column", gap: 8, width: "100%", children: [
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
565
|
+
Box,
|
|
566
|
+
{
|
|
567
|
+
backgroundColor,
|
|
568
|
+
borderColor,
|
|
569
|
+
borderWidth: borderColor !== "transparent" ? 1 : 0,
|
|
570
|
+
borderRadius: theme.radius.button,
|
|
571
|
+
height: sizeStyles.height,
|
|
572
|
+
padding: paddingMap[size],
|
|
573
|
+
flexDirection: "row",
|
|
574
|
+
alignItems: "flex-start",
|
|
575
|
+
gap: 12,
|
|
576
|
+
position: "relative",
|
|
577
|
+
cursor: disabled ? "not-allowed" : "text",
|
|
578
|
+
style: {
|
|
579
|
+
...outlineColor ? {
|
|
580
|
+
outline: `2px solid ${outlineColor}`,
|
|
581
|
+
outlineOffset: "-2px"
|
|
582
|
+
} : {}
|
|
583
|
+
},
|
|
584
|
+
hoverStyle: !disabled && !isFocused && !isError ? {
|
|
585
|
+
backgroundColor: inputColors.bgHover
|
|
586
|
+
} : void 0,
|
|
587
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1, height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
588
|
+
TextAreaPrimitive,
|
|
589
|
+
{
|
|
590
|
+
ref,
|
|
591
|
+
id: textareaId,
|
|
592
|
+
value,
|
|
593
|
+
placeholder,
|
|
594
|
+
onChangeText,
|
|
595
|
+
onFocus: handleFocus,
|
|
596
|
+
onBlur: handleBlur,
|
|
597
|
+
disabled,
|
|
598
|
+
color: textColor,
|
|
599
|
+
fontSize: sizeStyles.fontSize,
|
|
600
|
+
placeholderTextColor: placeholderColor,
|
|
601
|
+
"aria-label": ariaLabel,
|
|
602
|
+
"aria-invalid": isError || void 0,
|
|
603
|
+
"aria-disabled": disabled || void 0,
|
|
604
|
+
"aria-describedby": computedDescribedBy,
|
|
605
|
+
"data-testid": testID
|
|
606
|
+
}
|
|
607
|
+
) })
|
|
608
|
+
}
|
|
609
|
+
),
|
|
610
|
+
isError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
611
|
+
Text,
|
|
612
|
+
{
|
|
613
|
+
id: errorId,
|
|
614
|
+
role: "alert",
|
|
615
|
+
color: theme.colors.content.alert.primary,
|
|
616
|
+
fontSize: sizeStyles.fontSize - 2,
|
|
617
|
+
children: errorMessage
|
|
618
|
+
}
|
|
619
|
+
)
|
|
620
|
+
] });
|
|
621
|
+
}
|
|
622
|
+
);
|
|
623
|
+
TextArea.displayName = "TextArea";
|
|
624
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
625
|
+
0 && (module.exports = {
|
|
626
|
+
TextArea
|
|
627
|
+
});
|
|
628
|
+
//# sourceMappingURL=index.js.map
|