@xsolla/xui-uploader 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 +35 -0
- package/native/index.d.ts +35 -0
- package/native/index.js +623 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +590 -0
- package/native/index.mjs.map +1 -0
- package/package.json +47 -0
- package/web/index.d.mts +35 -0
- package/web/index.d.ts +35 -0
- package/web/index.js +611 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +574 -0
- package/web/index.mjs.map +1 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface UploaderProps {
|
|
4
|
+
/**
|
|
5
|
+
* Label for the uploader
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder text when no files are selected
|
|
10
|
+
*/
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Accepted file types (e.g., ".jpg,.png")
|
|
14
|
+
*/
|
|
15
|
+
accept?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether multiple files can be selected
|
|
18
|
+
*/
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when files are selected
|
|
22
|
+
*/
|
|
23
|
+
onFilesChange?: (files: File[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Property for disabling the control
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Size of the button
|
|
30
|
+
*/
|
|
31
|
+
size?: "xl" | "l" | "m" | "s" | "xs";
|
|
32
|
+
}
|
|
33
|
+
declare const Uploader: React.ForwardRefExoticComponent<UploaderProps & React.RefAttributes<HTMLInputElement>>;
|
|
34
|
+
|
|
35
|
+
export { Uploader, type UploaderProps };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface UploaderProps {
|
|
4
|
+
/**
|
|
5
|
+
* Label for the uploader
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder text when no files are selected
|
|
10
|
+
*/
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Accepted file types (e.g., ".jpg,.png")
|
|
14
|
+
*/
|
|
15
|
+
accept?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether multiple files can be selected
|
|
18
|
+
*/
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when files are selected
|
|
22
|
+
*/
|
|
23
|
+
onFilesChange?: (files: File[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Property for disabling the control
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Size of the button
|
|
30
|
+
*/
|
|
31
|
+
size?: "xl" | "l" | "m" | "s" | "xs";
|
|
32
|
+
}
|
|
33
|
+
declare const Uploader: React.ForwardRefExoticComponent<UploaderProps & React.RefAttributes<HTMLInputElement>>;
|
|
34
|
+
|
|
35
|
+
export { Uploader, type UploaderProps };
|
package/native/index.js
ADDED
|
@@ -0,0 +1,623 @@
|
|
|
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
|
+
Uploader: () => Uploader
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/Uploader.tsx
|
|
38
|
+
var import_react4 = __toESM(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/Uploader.tsx
|
|
501
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
502
|
+
var import_xui_button = require("@xsolla/xui-button");
|
|
503
|
+
var import_xui_icons = require("@xsolla/xui-icons");
|
|
504
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
505
|
+
var Uploader = (0, import_react4.forwardRef)(
|
|
506
|
+
({
|
|
507
|
+
label,
|
|
508
|
+
placeholder = "Select files to upload",
|
|
509
|
+
accept,
|
|
510
|
+
multiple = false,
|
|
511
|
+
onFilesChange,
|
|
512
|
+
disabled = false,
|
|
513
|
+
size = "m"
|
|
514
|
+
}, ref) => {
|
|
515
|
+
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
516
|
+
const fileInputRef = (0, import_react4.useRef)(null);
|
|
517
|
+
const [selectedFiles, setSelectedFiles] = (0, import_react4.useState)([]);
|
|
518
|
+
import_react4.default.useImperativeHandle(
|
|
519
|
+
ref,
|
|
520
|
+
() => fileInputRef.current,
|
|
521
|
+
[]
|
|
522
|
+
);
|
|
523
|
+
const handleButtonClick = () => {
|
|
524
|
+
fileInputRef.current?.click();
|
|
525
|
+
};
|
|
526
|
+
const handleFileChange = (e) => {
|
|
527
|
+
if (e.target.files) {
|
|
528
|
+
const newFiles = Array.from(e.target.files);
|
|
529
|
+
const updatedFiles = multiple ? [...selectedFiles, ...newFiles] : newFiles;
|
|
530
|
+
setSelectedFiles(updatedFiles);
|
|
531
|
+
onFilesChange?.(updatedFiles);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const removeFile = (index) => {
|
|
535
|
+
const updatedFiles = selectedFiles.filter((_, i) => i !== index);
|
|
536
|
+
setSelectedFiles(updatedFiles);
|
|
537
|
+
onFilesChange?.(updatedFiles);
|
|
538
|
+
};
|
|
539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "column", gap: 8, width: "100%", children: [
|
|
540
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
541
|
+
Text,
|
|
542
|
+
{
|
|
543
|
+
color: theme.colors.content.secondary,
|
|
544
|
+
fontSize: 14,
|
|
545
|
+
fontWeight: "500",
|
|
546
|
+
children: label
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
550
|
+
"input",
|
|
551
|
+
{
|
|
552
|
+
type: "file",
|
|
553
|
+
ref: fileInputRef,
|
|
554
|
+
accept,
|
|
555
|
+
multiple,
|
|
556
|
+
onChange: handleFileChange,
|
|
557
|
+
style: { display: "none" },
|
|
558
|
+
disabled
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
562
|
+
import_xui_button.Button,
|
|
563
|
+
{
|
|
564
|
+
variant: "primary",
|
|
565
|
+
tone: "brand",
|
|
566
|
+
size,
|
|
567
|
+
disabled,
|
|
568
|
+
onPress: handleButtonClick,
|
|
569
|
+
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_xui_icons.Upload, {}),
|
|
570
|
+
fullWidth: true,
|
|
571
|
+
children: placeholder
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
selectedFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flexDirection: "column", gap: 4, marginTop: 4, children: selectedFiles.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
575
|
+
Box,
|
|
576
|
+
{
|
|
577
|
+
flexDirection: "row",
|
|
578
|
+
alignItems: "center",
|
|
579
|
+
justifyContent: "space-between",
|
|
580
|
+
backgroundColor: theme.colors.background.secondary,
|
|
581
|
+
padding: 8,
|
|
582
|
+
borderRadius: 4,
|
|
583
|
+
gap: 8,
|
|
584
|
+
children: [
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "row", alignItems: "center", gap: 8, flex: 1, children: [
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_xui_icons.File, { size: 16, color: theme.colors.content.secondary }),
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
588
|
+
Text,
|
|
589
|
+
{
|
|
590
|
+
fontSize: 13,
|
|
591
|
+
color: theme.colors.content.primary,
|
|
592
|
+
numberOfLines: 1,
|
|
593
|
+
children: file.name
|
|
594
|
+
}
|
|
595
|
+
)
|
|
596
|
+
] }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
598
|
+
Box,
|
|
599
|
+
{
|
|
600
|
+
as: "button",
|
|
601
|
+
onPress: () => removeFile(index),
|
|
602
|
+
style: {
|
|
603
|
+
border: "none",
|
|
604
|
+
background: "transparent",
|
|
605
|
+
cursor: "pointer",
|
|
606
|
+
padding: 4
|
|
607
|
+
},
|
|
608
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_xui_icons.X, { size: 14, color: theme.colors.content.alert.primary })
|
|
609
|
+
}
|
|
610
|
+
)
|
|
611
|
+
]
|
|
612
|
+
},
|
|
613
|
+
`${file.name}-${index}`
|
|
614
|
+
)) })
|
|
615
|
+
] });
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
Uploader.displayName = "Uploader";
|
|
619
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
620
|
+
0 && (module.exports = {
|
|
621
|
+
Uploader
|
|
622
|
+
});
|
|
623
|
+
//# sourceMappingURL=index.js.map
|