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