@xsolla/xui-button 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,1272 @@
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
+ Button: () => Button,
34
+ ButtonGroup: () => ButtonGroup,
35
+ FlexButton: () => FlexButton,
36
+ IconButton: () => IconButton
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/Button.tsx
41
+ var import_react4 = require("react");
42
+
43
+ // ../primitives-native/src/Box.tsx
44
+ var import_react_native = require("react-native");
45
+ var import_jsx_runtime = require("react/jsx-runtime");
46
+ var Box = ({
47
+ children,
48
+ onPress,
49
+ onLayout,
50
+ onMoveShouldSetResponder,
51
+ onResponderGrant,
52
+ onResponderMove,
53
+ onResponderRelease,
54
+ onResponderTerminate,
55
+ backgroundColor,
56
+ borderColor,
57
+ borderWidth,
58
+ borderBottomWidth,
59
+ borderBottomColor,
60
+ borderTopWidth,
61
+ borderTopColor,
62
+ borderLeftWidth,
63
+ borderLeftColor,
64
+ borderRightWidth,
65
+ borderRightColor,
66
+ borderRadius,
67
+ borderStyle,
68
+ height,
69
+ padding,
70
+ paddingHorizontal,
71
+ paddingVertical,
72
+ margin,
73
+ marginTop,
74
+ marginBottom,
75
+ marginLeft,
76
+ marginRight,
77
+ flexDirection,
78
+ alignItems,
79
+ justifyContent,
80
+ position,
81
+ top,
82
+ bottom,
83
+ left,
84
+ right,
85
+ width,
86
+ flex,
87
+ overflow,
88
+ zIndex,
89
+ hoverStyle,
90
+ pressStyle,
91
+ style,
92
+ "data-testid": dataTestId,
93
+ testID,
94
+ as,
95
+ src,
96
+ alt,
97
+ ...rest
98
+ }) => {
99
+ const getContainerStyle = (pressed) => ({
100
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
101
+ borderColor,
102
+ borderWidth,
103
+ borderBottomWidth,
104
+ borderBottomColor,
105
+ borderTopWidth,
106
+ borderTopColor,
107
+ borderLeftWidth,
108
+ borderLeftColor,
109
+ borderRightWidth,
110
+ borderRightColor,
111
+ borderRadius,
112
+ borderStyle,
113
+ overflow,
114
+ zIndex,
115
+ height,
116
+ width,
117
+ padding,
118
+ paddingHorizontal,
119
+ paddingVertical,
120
+ margin,
121
+ marginTop,
122
+ marginBottom,
123
+ marginLeft,
124
+ marginRight,
125
+ flexDirection,
126
+ alignItems,
127
+ justifyContent,
128
+ position,
129
+ top,
130
+ bottom,
131
+ left,
132
+ right,
133
+ flex,
134
+ ...style
135
+ });
136
+ const finalTestID = dataTestId || testID;
137
+ const {
138
+ role,
139
+ tabIndex,
140
+ onKeyDown,
141
+ onKeyUp,
142
+ "aria-label": _ariaLabel,
143
+ "aria-labelledby": _ariaLabelledBy,
144
+ "aria-current": _ariaCurrent,
145
+ "aria-disabled": _ariaDisabled,
146
+ "aria-live": _ariaLive,
147
+ className,
148
+ "data-testid": _dataTestId,
149
+ ...nativeRest
150
+ } = rest;
151
+ if (as === "img" && src) {
152
+ const imageStyle = {
153
+ width,
154
+ height,
155
+ borderRadius,
156
+ position,
157
+ top,
158
+ bottom,
159
+ left,
160
+ right,
161
+ ...style
162
+ };
163
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
+ import_react_native.Image,
165
+ {
166
+ source: { uri: src },
167
+ style: imageStyle,
168
+ testID: finalTestID,
169
+ resizeMode: "cover",
170
+ ...nativeRest
171
+ }
172
+ );
173
+ }
174
+ if (onPress) {
175
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
176
+ import_react_native.Pressable,
177
+ {
178
+ onPress,
179
+ onLayout,
180
+ onMoveShouldSetResponder,
181
+ onResponderGrant,
182
+ onResponderMove,
183
+ onResponderRelease,
184
+ onResponderTerminate,
185
+ style: ({ pressed }) => getContainerStyle(pressed),
186
+ testID: finalTestID,
187
+ ...nativeRest,
188
+ children
189
+ }
190
+ );
191
+ }
192
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
+ import_react_native.View,
194
+ {
195
+ style: getContainerStyle(),
196
+ testID: finalTestID,
197
+ onLayout,
198
+ onMoveShouldSetResponder,
199
+ onResponderGrant,
200
+ onResponderMove,
201
+ onResponderRelease,
202
+ onResponderTerminate,
203
+ ...nativeRest,
204
+ children
205
+ }
206
+ );
207
+ };
208
+
209
+ // ../primitives-native/src/Text.tsx
210
+ var import_react_native2 = require("react-native");
211
+ var import_jsx_runtime2 = require("react/jsx-runtime");
212
+ var roleMap = {
213
+ alert: "alert",
214
+ heading: "header",
215
+ button: "button",
216
+ link: "link",
217
+ text: "text"
218
+ };
219
+ var Text = ({
220
+ children,
221
+ color,
222
+ fontSize,
223
+ fontWeight,
224
+ fontFamily,
225
+ id,
226
+ role,
227
+ ...props
228
+ }) => {
229
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
230
+ if (resolvedFontFamily === "Pilat Wide Bold") {
231
+ resolvedFontFamily = void 0;
232
+ }
233
+ const style = {
234
+ color,
235
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
236
+ fontWeight,
237
+ fontFamily: resolvedFontFamily,
238
+ textDecorationLine: props.textDecoration
239
+ };
240
+ const accessibilityRole = role ? roleMap[role] : void 0;
241
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
242
+ };
243
+
244
+ // ../primitives-native/src/Spinner.tsx
245
+ var import_react_native3 = require("react-native");
246
+ var import_jsx_runtime3 = require("react/jsx-runtime");
247
+ var Spinner = ({
248
+ color,
249
+ size,
250
+ role,
251
+ "aria-label": ariaLabel,
252
+ "aria-live": ariaLive,
253
+ "aria-describedby": ariaDescribedBy,
254
+ testID
255
+ }) => {
256
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
257
+ import_react_native3.View,
258
+ {
259
+ accessible: true,
260
+ accessibilityRole: role === "status" ? "none" : void 0,
261
+ accessibilityLabel: ariaLabel,
262
+ accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
263
+ testID,
264
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
265
+ import_react_native3.ActivityIndicator,
266
+ {
267
+ color,
268
+ size: typeof size === "number" ? size : "small"
269
+ }
270
+ )
271
+ }
272
+ );
273
+ };
274
+ Spinner.displayName = "Spinner";
275
+
276
+ // ../primitives-native/src/Icon.tsx
277
+ var import_react = __toESM(require("react"));
278
+ var import_react_native4 = require("react-native");
279
+ var import_jsx_runtime4 = require("react/jsx-runtime");
280
+ var Icon = ({ children, color, size }) => {
281
+ const style = {
282
+ width: typeof size === "number" ? size : void 0,
283
+ height: typeof size === "number" ? size : void 0,
284
+ alignItems: "center",
285
+ justifyContent: "center"
286
+ };
287
+ const childrenWithProps = import_react.default.Children.map(children, (child) => {
288
+ if (import_react.default.isValidElement(child)) {
289
+ return import_react.default.cloneElement(child, {
290
+ color: child.props.color || color,
291
+ // Also pass size if child seems to be an icon that needs it
292
+ size: child.props.size || size
293
+ });
294
+ }
295
+ return child;
296
+ });
297
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { style, children: childrenWithProps });
298
+ };
299
+
300
+ // ../primitives-native/src/Divider.tsx
301
+ var import_react_native5 = require("react-native");
302
+ var import_jsx_runtime5 = require("react/jsx-runtime");
303
+ var Divider = ({
304
+ color,
305
+ height,
306
+ width,
307
+ vertical,
308
+ dashStroke
309
+ }) => {
310
+ const style = {
311
+ backgroundColor: dashStroke ? "transparent" : color || "rgba(255, 255, 255, 0.15)",
312
+ width: vertical ? typeof width === "number" ? width : 1 : "100%",
313
+ height: vertical ? "100%" : typeof height === "number" ? height : 1,
314
+ ...dashStroke && {
315
+ borderStyle: "dashed",
316
+ borderColor: color || "rgba(255, 255, 255, 0.15)",
317
+ borderWidth: 0,
318
+ ...vertical ? { borderLeftWidth: typeof width === "number" ? width : 1 } : { borderTopWidth: typeof height === "number" ? height : 1 }
319
+ }
320
+ };
321
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.View, { style });
322
+ };
323
+
324
+ // ../primitives-native/src/Input.tsx
325
+ var import_react2 = require("react");
326
+ var import_react_native6 = require("react-native");
327
+ var import_jsx_runtime6 = require("react/jsx-runtime");
328
+ var keyboardTypeMap = {
329
+ text: "default",
330
+ number: "numeric",
331
+ email: "email-address",
332
+ tel: "phone-pad",
333
+ url: "url",
334
+ decimal: "decimal-pad"
335
+ };
336
+ var inputModeToKeyboardType = {
337
+ none: "default",
338
+ text: "default",
339
+ decimal: "decimal-pad",
340
+ numeric: "number-pad",
341
+ tel: "phone-pad",
342
+ search: "default",
343
+ email: "email-address",
344
+ url: "url"
345
+ };
346
+ var autoCompleteToTextContentType = {
347
+ "one-time-code": "oneTimeCode",
348
+ email: "emailAddress",
349
+ username: "username",
350
+ password: "password",
351
+ "new-password": "newPassword",
352
+ tel: "telephoneNumber",
353
+ "postal-code": "postalCode",
354
+ name: "name"
355
+ };
356
+ var InputPrimitive = (0, import_react2.forwardRef)(
357
+ ({
358
+ value,
359
+ placeholder,
360
+ onChange,
361
+ onChangeText,
362
+ onFocus,
363
+ onBlur,
364
+ onKeyDown,
365
+ disabled,
366
+ secureTextEntry,
367
+ style,
368
+ color,
369
+ fontSize,
370
+ placeholderTextColor,
371
+ maxLength,
372
+ name,
373
+ type,
374
+ inputMode,
375
+ autoComplete,
376
+ id,
377
+ "aria-invalid": ariaInvalid,
378
+ "aria-describedby": ariaDescribedBy,
379
+ "aria-labelledby": ariaLabelledBy,
380
+ "aria-label": ariaLabel,
381
+ "aria-disabled": ariaDisabled,
382
+ "data-testid": dataTestId
383
+ }, ref) => {
384
+ const handleChangeText = (text) => {
385
+ onChangeText?.(text);
386
+ if (onChange) {
387
+ const syntheticEvent = {
388
+ target: { value: text },
389
+ currentTarget: { value: text },
390
+ type: "change",
391
+ nativeEvent: { text },
392
+ preventDefault: () => {
393
+ },
394
+ stopPropagation: () => {
395
+ },
396
+ isTrusted: false
397
+ };
398
+ onChange(syntheticEvent);
399
+ }
400
+ };
401
+ const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
402
+ const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
403
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
404
+ import_react_native6.TextInput,
405
+ {
406
+ ref,
407
+ value,
408
+ placeholder,
409
+ onChangeText: handleChangeText,
410
+ onFocus,
411
+ onBlur,
412
+ onKeyPress: (e) => {
413
+ if (onKeyDown) {
414
+ onKeyDown({
415
+ key: e.nativeEvent.key,
416
+ preventDefault: () => {
417
+ }
418
+ });
419
+ }
420
+ },
421
+ editable: !disabled,
422
+ secureTextEntry: secureTextEntry || type === "password",
423
+ keyboardType,
424
+ textContentType,
425
+ style: [
426
+ {
427
+ color,
428
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
429
+ flex: 1,
430
+ padding: 0,
431
+ textAlign: style?.textAlign || "left"
432
+ },
433
+ style
434
+ ],
435
+ placeholderTextColor,
436
+ maxLength,
437
+ testID: dataTestId || id,
438
+ accessibilityLabel: ariaLabel,
439
+ accessibilityHint: ariaDescribedBy,
440
+ accessibilityState: {
441
+ disabled: disabled || ariaDisabled
442
+ },
443
+ accessible: true
444
+ }
445
+ );
446
+ }
447
+ );
448
+ InputPrimitive.displayName = "InputPrimitive";
449
+
450
+ // ../primitives-native/src/TextArea.tsx
451
+ var import_react3 = require("react");
452
+ var import_react_native7 = require("react-native");
453
+ var import_jsx_runtime7 = require("react/jsx-runtime");
454
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
455
+ ({
456
+ value,
457
+ placeholder,
458
+ onChange,
459
+ onChangeText,
460
+ onFocus,
461
+ onBlur,
462
+ onKeyDown,
463
+ disabled,
464
+ style,
465
+ color,
466
+ fontSize,
467
+ placeholderTextColor,
468
+ maxLength,
469
+ rows,
470
+ id,
471
+ "aria-invalid": ariaInvalid,
472
+ "aria-describedby": ariaDescribedBy,
473
+ "aria-labelledby": ariaLabelledBy,
474
+ "aria-label": ariaLabel,
475
+ "aria-disabled": ariaDisabled,
476
+ "data-testid": dataTestId
477
+ }, ref) => {
478
+ const handleChangeText = (text) => {
479
+ onChangeText?.(text);
480
+ if (onChange) {
481
+ const syntheticEvent = {
482
+ target: { value: text },
483
+ currentTarget: { value: text },
484
+ type: "change",
485
+ nativeEvent: { text },
486
+ preventDefault: () => {
487
+ },
488
+ stopPropagation: () => {
489
+ },
490
+ isTrusted: false
491
+ };
492
+ onChange(syntheticEvent);
493
+ }
494
+ };
495
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
496
+ import_react_native7.TextInput,
497
+ {
498
+ ref,
499
+ value,
500
+ placeholder,
501
+ onChangeText: handleChangeText,
502
+ onFocus,
503
+ onBlur,
504
+ onKeyPress: (e) => {
505
+ if (onKeyDown) {
506
+ onKeyDown({
507
+ key: e.nativeEvent.key,
508
+ preventDefault: () => {
509
+ }
510
+ });
511
+ }
512
+ },
513
+ editable: !disabled,
514
+ multiline: true,
515
+ numberOfLines: rows || 4,
516
+ style: [
517
+ {
518
+ color,
519
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
520
+ flex: 1,
521
+ padding: 0,
522
+ textAlignVertical: "top",
523
+ textAlign: style?.textAlign || "left"
524
+ },
525
+ style
526
+ ],
527
+ placeholderTextColor,
528
+ maxLength,
529
+ testID: dataTestId || id,
530
+ accessibilityLabel: ariaLabel,
531
+ accessibilityHint: ariaDescribedBy,
532
+ accessibilityState: {
533
+ disabled: disabled || ariaDisabled
534
+ },
535
+ accessible: true
536
+ }
537
+ );
538
+ }
539
+ );
540
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
541
+
542
+ // src/Button.tsx
543
+ var import_xui_core = require("@xsolla/xui-core");
544
+ var import_jsx_runtime8 = require("react/jsx-runtime");
545
+ var Button = ({
546
+ variant = "primary",
547
+ tone = "brand",
548
+ size = "m",
549
+ disabled = false,
550
+ loading = false,
551
+ children,
552
+ onPress,
553
+ iconLeft,
554
+ iconRight,
555
+ "aria-label": ariaLabel,
556
+ "aria-describedby": ariaDescribedBy,
557
+ "aria-expanded": ariaExpanded,
558
+ "aria-haspopup": ariaHasPopup,
559
+ "aria-pressed": ariaPressed,
560
+ "aria-controls": ariaControls,
561
+ testID,
562
+ id,
563
+ type = "button",
564
+ fullWidth = false
565
+ }) => {
566
+ const { theme } = (0, import_xui_core.useDesignSystem)();
567
+ const [isKeyboardPressed, setIsKeyboardPressed] = (0, import_react4.useState)(false);
568
+ const isDisabled = disabled || loading;
569
+ const sizeStyles = theme.sizing.button(size);
570
+ const variantStyles = theme?.colors?.control?.[tone]?.[variant] || theme?.colors?.control?.brand?.primary || {
571
+ bg: "transparent",
572
+ text: { primary: "#000" }
573
+ };
574
+ const handlePress = () => {
575
+ if (!isDisabled && onPress) {
576
+ onPress();
577
+ }
578
+ };
579
+ const handleKeyDown = (e) => {
580
+ if (isDisabled) return;
581
+ if (e.key === "Enter" || e.key === " ") {
582
+ e.preventDefault();
583
+ setIsKeyboardPressed(true);
584
+ }
585
+ };
586
+ const handleKeyUp = (e) => {
587
+ if (isDisabled) return;
588
+ if (e.key === "Enter" || e.key === " ") {
589
+ e.preventDefault();
590
+ setIsKeyboardPressed(false);
591
+ if (onPress) {
592
+ onPress();
593
+ }
594
+ }
595
+ };
596
+ const styles = variantStyles;
597
+ let backgroundColor = styles.bg;
598
+ if (disabled) {
599
+ backgroundColor = styles.bgDisable || styles.bg;
600
+ } else if (isKeyboardPressed) {
601
+ backgroundColor = styles.bgPress || styles.bg;
602
+ }
603
+ const borderColor = disabled ? styles.borderDisable || styles.border : styles.border;
604
+ const textColor = disabled ? styles.text?.disable || styles.text?.primary : styles.text?.primary;
605
+ const isDarkText = textColor === "#000000" || textColor === "black" || textColor.startsWith("rgba(0, 0, 0");
606
+ const dividerColor = isDarkText ? "rgba(0, 0, 0, 0.2)" : "rgba(255, 255, 255, 0.2)";
607
+ const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
608
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
609
+ Box,
610
+ {
611
+ as: "button",
612
+ type,
613
+ id,
614
+ onPress: handlePress,
615
+ onKeyDown: handleKeyDown,
616
+ onKeyUp: handleKeyUp,
617
+ disabled: isDisabled,
618
+ "aria-label": computedAriaLabel,
619
+ "aria-disabled": isDisabled || void 0,
620
+ "aria-busy": loading || void 0,
621
+ "aria-describedby": ariaDescribedBy,
622
+ "aria-expanded": ariaExpanded,
623
+ "aria-haspopup": ariaHasPopup,
624
+ "aria-pressed": ariaPressed,
625
+ "aria-controls": ariaControls,
626
+ testID,
627
+ backgroundColor,
628
+ borderColor,
629
+ borderWidth: borderColor !== "transparent" && borderColor !== "rgba(255, 255, 255, 0)" ? 1 : 0,
630
+ borderRadius: theme.radius.button,
631
+ height: sizeStyles.height,
632
+ width: fullWidth ? "100%" : void 0,
633
+ padding: 0,
634
+ flexDirection: "row",
635
+ alignItems: "center",
636
+ justifyContent: "center",
637
+ position: "relative",
638
+ cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
639
+ opacity: disabled ? 0.6 : 1,
640
+ hoverStyle: !isDisabled ? {
641
+ backgroundColor: variantStyles?.bgHover
642
+ } : void 0,
643
+ pressStyle: !isDisabled ? {
644
+ backgroundColor: variantStyles?.bgPress
645
+ } : void 0,
646
+ focusStyle: {
647
+ outlineColor: theme.colors.border.brand,
648
+ outlineWidth: 2,
649
+ outlineOffset: 2,
650
+ outlineStyle: "solid"
651
+ },
652
+ children: [
653
+ !loading && iconLeft && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
654
+ Box,
655
+ {
656
+ height: "100%",
657
+ flexDirection: "row",
658
+ alignItems: "center",
659
+ justifyContent: "center",
660
+ "aria-hidden": true,
661
+ children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
663
+ Box,
664
+ {
665
+ alignItems: "center",
666
+ justifyContent: "center",
667
+ paddingHorizontal: sizeStyles.iconPadding,
668
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, children: iconLeft })
669
+ }
670
+ ),
671
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Divider, { vertical: true, color: dividerColor, height: "100%" })
672
+ ]
673
+ }
674
+ ),
675
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
676
+ Box,
677
+ {
678
+ flex: fullWidth ? 1 : void 0,
679
+ flexDirection: "row",
680
+ alignItems: "center",
681
+ justifyContent: "center",
682
+ paddingHorizontal: loading ? sizeStyles.loadingPadding : sizeStyles.padding,
683
+ height: "100%",
684
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
685
+ Spinner,
686
+ {
687
+ color: textColor,
688
+ size: sizeStyles.spinnerSize,
689
+ "aria-hidden": true
690
+ }
691
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
692
+ Text,
693
+ {
694
+ color: textColor,
695
+ fontSize: sizeStyles.fontSize,
696
+ fontWeight: "500",
697
+ "aria-hidden": computedAriaLabel ? true : void 0,
698
+ children
699
+ }
700
+ )
701
+ }
702
+ ),
703
+ !loading && iconRight && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
704
+ Box,
705
+ {
706
+ height: "100%",
707
+ flexDirection: "row",
708
+ alignItems: "center",
709
+ justifyContent: "center",
710
+ "aria-hidden": true,
711
+ children: [
712
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Divider, { vertical: true, color: dividerColor, height: "100%" }),
713
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
714
+ Box,
715
+ {
716
+ alignItems: "center",
717
+ justifyContent: "center",
718
+ paddingHorizontal: sizeStyles.iconPadding,
719
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, children: iconRight })
720
+ }
721
+ )
722
+ ]
723
+ }
724
+ )
725
+ ]
726
+ }
727
+ );
728
+ };
729
+ Button.displayName = "Button";
730
+
731
+ // src/IconButton.tsx
732
+ var import_react5 = require("react");
733
+ var import_xui_core2 = require("@xsolla/xui-core");
734
+ var import_jsx_runtime9 = require("react/jsx-runtime");
735
+ var IconButton = ({
736
+ variant = "primary",
737
+ tone = "brand",
738
+ size = "m",
739
+ disabled = false,
740
+ loading = false,
741
+ icon,
742
+ onPress,
743
+ "aria-label": ariaLabel,
744
+ "aria-describedby": ariaDescribedBy,
745
+ "aria-expanded": ariaExpanded,
746
+ "aria-haspopup": ariaHasPopup,
747
+ "aria-pressed": ariaPressed,
748
+ "aria-controls": ariaControls,
749
+ testID,
750
+ id,
751
+ type = "button"
752
+ }) => {
753
+ const { theme } = (0, import_xui_core2.useDesignSystem)();
754
+ const [isKeyboardPressed, setIsKeyboardPressed] = (0, import_react5.useState)(false);
755
+ const isDisabled = disabled || loading;
756
+ const sizeStyles = theme.sizing.button(size);
757
+ const variantStyles = theme?.colors?.control?.[tone]?.[variant] || theme?.colors?.control?.brand?.primary || {
758
+ bg: "transparent",
759
+ text: { primary: "#000" }
760
+ };
761
+ const handlePress = () => {
762
+ if (!isDisabled && onPress) {
763
+ onPress();
764
+ }
765
+ };
766
+ const handleKeyDown = (e) => {
767
+ if (isDisabled) return;
768
+ if (e.key === "Enter" || e.key === " ") {
769
+ e.preventDefault();
770
+ setIsKeyboardPressed(true);
771
+ }
772
+ };
773
+ const handleKeyUp = (e) => {
774
+ if (isDisabled) return;
775
+ if (e.key === "Enter" || e.key === " ") {
776
+ e.preventDefault();
777
+ setIsKeyboardPressed(false);
778
+ if (onPress) {
779
+ onPress();
780
+ }
781
+ }
782
+ };
783
+ const styles = variantStyles;
784
+ let backgroundColor = styles.bg;
785
+ if (disabled) {
786
+ backgroundColor = styles.bgDisable || styles.bg;
787
+ } else if (isKeyboardPressed) {
788
+ backgroundColor = styles.bgPress || styles.bg;
789
+ }
790
+ const borderColor = disabled ? styles.borderDisable || styles.border : styles.border;
791
+ const textColor = disabled ? styles.text?.disable || styles.text?.primary : styles.text?.primary;
792
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
793
+ Box,
794
+ {
795
+ as: "button",
796
+ type,
797
+ id,
798
+ onPress: handlePress,
799
+ onKeyDown: handleKeyDown,
800
+ onKeyUp: handleKeyUp,
801
+ disabled: isDisabled,
802
+ "aria-label": ariaLabel,
803
+ "aria-disabled": isDisabled || void 0,
804
+ "aria-busy": loading || void 0,
805
+ "aria-describedby": ariaDescribedBy,
806
+ "aria-expanded": ariaExpanded,
807
+ "aria-haspopup": ariaHasPopup,
808
+ "aria-pressed": ariaPressed,
809
+ "aria-controls": ariaControls,
810
+ testID,
811
+ backgroundColor,
812
+ borderColor,
813
+ borderWidth: borderColor !== "transparent" && borderColor !== "rgba(255, 255, 255, 0)" ? 1 : 0,
814
+ borderRadius: theme.radius.button,
815
+ height: sizeStyles.height,
816
+ width: sizeStyles.height,
817
+ padding: 0,
818
+ flexDirection: "row",
819
+ alignItems: "center",
820
+ justifyContent: "center",
821
+ position: "relative",
822
+ cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
823
+ opacity: disabled ? 0.6 : 1,
824
+ hoverStyle: !isDisabled ? {
825
+ backgroundColor: styles.bgHover
826
+ } : void 0,
827
+ pressStyle: !isDisabled ? {
828
+ backgroundColor: styles.bgPress
829
+ } : void 0,
830
+ focusStyle: {
831
+ outlineColor: theme.colors.border.brand,
832
+ outlineWidth: 2,
833
+ outlineOffset: 2,
834
+ outlineStyle: "solid"
835
+ },
836
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
837
+ Spinner,
838
+ {
839
+ color: textColor,
840
+ size: sizeStyles.spinnerSize,
841
+ "aria-hidden": true
842
+ }
843
+ ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: icon })
844
+ }
845
+ );
846
+ };
847
+ IconButton.displayName = "IconButton";
848
+
849
+ // src/FlexButton.tsx
850
+ var import_react6 = require("react");
851
+ var import_xui_core3 = require("@xsolla/xui-core");
852
+ var import_jsx_runtime10 = require("react/jsx-runtime");
853
+ var ICON_SIZES = {
854
+ xs: 12,
855
+ s: 14,
856
+ m: 16,
857
+ l: 18,
858
+ xl: 20
859
+ };
860
+ var SPINNER_SIZES = {
861
+ xs: 12,
862
+ s: 14,
863
+ m: 16,
864
+ l: 18,
865
+ xl: 20
866
+ };
867
+ var LINE_HEIGHTS = {
868
+ xs: "14px",
869
+ s: "16px",
870
+ m: "18px",
871
+ l: "20px",
872
+ xl: "22px"
873
+ };
874
+ var FONT_SIZES = {
875
+ xs: 12,
876
+ s: 14,
877
+ m: 14,
878
+ l: 16,
879
+ xl: 18
880
+ };
881
+ var BORDER_RADIUS = {
882
+ xl: 4,
883
+ l: 4,
884
+ m: 2,
885
+ s: 2,
886
+ xs: 2
887
+ };
888
+ var FlexButton = ({
889
+ children,
890
+ variant = "brand",
891
+ size = "m",
892
+ background = false,
893
+ disabled = false,
894
+ loading = false,
895
+ iconLeft,
896
+ iconRight,
897
+ onPress,
898
+ onClick,
899
+ className,
900
+ type = "button",
901
+ "aria-label": ariaLabel,
902
+ "aria-describedby": ariaDescribedBy,
903
+ "aria-expanded": ariaExpanded,
904
+ "aria-haspopup": ariaHasPopup,
905
+ "aria-pressed": ariaPressed,
906
+ "aria-controls": ariaControls,
907
+ testID,
908
+ tabIndex = 0,
909
+ ...buttonProps
910
+ }) => {
911
+ const { theme } = (0, import_xui_core3.useDesignSystem)();
912
+ const [state, setState] = (0, import_react6.useState)("default");
913
+ const [isFocused, setIsFocused] = (0, import_react6.useState)(false);
914
+ const isMouseOverRef = (0, import_react6.useRef)(false);
915
+ const isDisabled = disabled || loading;
916
+ const getVariantColors = (currentState) => {
917
+ if (isDisabled) {
918
+ return {
919
+ bg: background ? theme.colors.overlay.mono : "transparent",
920
+ text: theme.colors.control.text.disable,
921
+ border: void 0
922
+ };
923
+ }
924
+ const effectiveBackground = loading ? false : background;
925
+ switch (variant) {
926
+ case "brand":
927
+ if (effectiveBackground) {
928
+ return {
929
+ bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
930
+ text: theme.colors.content.on.brand,
931
+ border: void 0
932
+ };
933
+ }
934
+ return {
935
+ bg: currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
936
+ text: currentState === "press" ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
937
+ border: void 0
938
+ };
939
+ case "primary":
940
+ if (effectiveBackground) {
941
+ return {
942
+ bg: theme.colors.background.primary,
943
+ text: theme.colors.content.primary,
944
+ border: currentState === "press" ? theme.colors.border.primary : void 0
945
+ };
946
+ }
947
+ return {
948
+ bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
949
+ text: theme.colors.content.primary,
950
+ border: currentState === "press" ? theme.colors.border.primary : void 0
951
+ };
952
+ case "secondary":
953
+ if (effectiveBackground) {
954
+ return {
955
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
956
+ text: theme.colors.content.secondary,
957
+ border: void 0
958
+ };
959
+ }
960
+ return {
961
+ bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
962
+ text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
963
+ border: void 0
964
+ };
965
+ case "tertiary":
966
+ if (effectiveBackground) {
967
+ return {
968
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
969
+ text: theme.colors.content.tertiary,
970
+ border: void 0
971
+ };
972
+ }
973
+ return {
974
+ bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
975
+ text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
976
+ border: void 0
977
+ };
978
+ case "brandExtra":
979
+ if (effectiveBackground) {
980
+ return {
981
+ bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
982
+ text: theme.colors.content.on.brandExtra,
983
+ border: void 0
984
+ };
985
+ }
986
+ return {
987
+ bg: currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
988
+ text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
989
+ border: void 0
990
+ };
991
+ case "inverse":
992
+ if (effectiveBackground) {
993
+ return {
994
+ bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
995
+ text: theme.colors.content.inverse,
996
+ border: void 0
997
+ };
998
+ }
999
+ return {
1000
+ bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1001
+ text: theme.colors.content.inverse,
1002
+ border: void 0
1003
+ };
1004
+ default:
1005
+ return {
1006
+ bg: "transparent",
1007
+ text: theme.colors.content.primary,
1008
+ border: void 0
1009
+ };
1010
+ }
1011
+ };
1012
+ const getFocusRingColor = () => {
1013
+ switch (variant) {
1014
+ case "brand":
1015
+ return theme.colors.overlay.brand;
1016
+ case "brandExtra":
1017
+ return theme.colors.overlay.brandExtra;
1018
+ case "inverse":
1019
+ return "rgba(255, 255, 255, 0.3)";
1020
+ default:
1021
+ return theme.colors.overlay.mono;
1022
+ }
1023
+ };
1024
+ const getSpinnerColor = () => {
1025
+ switch (variant) {
1026
+ case "brand":
1027
+ return theme.colors.content.brand.primary;
1028
+ case "primary":
1029
+ return theme.colors.content.primary;
1030
+ case "secondary":
1031
+ return theme.colors.content.secondary;
1032
+ case "tertiary":
1033
+ return theme.colors.content.tertiary;
1034
+ case "brandExtra":
1035
+ return theme.colors.content.brandExtra.secondary;
1036
+ case "inverse":
1037
+ return theme.colors.content.inverse;
1038
+ default:
1039
+ return theme.colors.content.brand.primary;
1040
+ }
1041
+ };
1042
+ const colors = getVariantColors(state);
1043
+ const focusRingColor = getFocusRingColor();
1044
+ const spinnerColor = getSpinnerColor();
1045
+ const iconSize = ICON_SIZES[size];
1046
+ const spinnerSize = SPINNER_SIZES[size];
1047
+ const fontSize = FONT_SIZES[size];
1048
+ const borderRadius = BORDER_RADIUS[size];
1049
+ const lineHeight = LINE_HEIGHTS[size];
1050
+ const handleMouseEnter = () => {
1051
+ if (!isDisabled) {
1052
+ isMouseOverRef.current = true;
1053
+ setState("hover");
1054
+ }
1055
+ };
1056
+ const handleMouseLeave = () => {
1057
+ if (!isDisabled) {
1058
+ isMouseOverRef.current = false;
1059
+ setState("default");
1060
+ }
1061
+ };
1062
+ const handleMouseDown = () => {
1063
+ if (!isDisabled) {
1064
+ setState("press");
1065
+ }
1066
+ };
1067
+ const handleMouseUp = () => {
1068
+ if (!isDisabled) {
1069
+ setState(isMouseOverRef.current ? "hover" : "default");
1070
+ }
1071
+ };
1072
+ const handleFocus = () => {
1073
+ if (!isDisabled) {
1074
+ setIsFocused(true);
1075
+ }
1076
+ };
1077
+ const handleBlur = () => {
1078
+ setIsFocused(false);
1079
+ };
1080
+ const handleClick = (event) => {
1081
+ if (isDisabled) return;
1082
+ if (onPress) {
1083
+ onPress();
1084
+ }
1085
+ if (onClick) {
1086
+ onClick(event);
1087
+ }
1088
+ };
1089
+ const handleKeyDown = (event) => {
1090
+ if (isDisabled) return;
1091
+ if (event.key === "Enter" || event.key === " ") {
1092
+ event.preventDefault();
1093
+ setState("press");
1094
+ }
1095
+ };
1096
+ const handleKeyUp = (event) => {
1097
+ if (isDisabled) return;
1098
+ if (event.key === "Enter" || event.key === " ") {
1099
+ event.preventDefault();
1100
+ setState(isMouseOverRef.current ? "hover" : "default");
1101
+ if (onPress) {
1102
+ onPress();
1103
+ }
1104
+ }
1105
+ };
1106
+ const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1107
+ const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1108
+ const boxShadows = [];
1109
+ if (borderShadow) boxShadows.push(borderShadow);
1110
+ if (focusShadow) boxShadows.push(focusShadow);
1111
+ const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1112
+ const buttonStyle = {
1113
+ display: "inline-flex",
1114
+ alignItems: "center",
1115
+ justifyContent: "center",
1116
+ gap: "2px",
1117
+ padding: "4px",
1118
+ backgroundColor: loading ? "transparent" : colors.bg,
1119
+ color: colors.text,
1120
+ border: "none",
1121
+ borderWidth: "0px",
1122
+ borderRadius: `${borderRadius}px`,
1123
+ cursor: isDisabled ? "not-allowed" : "pointer",
1124
+ fontSize: `${fontSize}px`,
1125
+ fontWeight: 500,
1126
+ lineHeight,
1127
+ fontFamily: "inherit",
1128
+ transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1129
+ outline: "none",
1130
+ boxShadow: combinedBoxShadow,
1131
+ opacity: isDisabled && !loading ? 0.6 : 1
1132
+ };
1133
+ const contentStyle = {
1134
+ display: "flex",
1135
+ alignItems: "center",
1136
+ justifyContent: "center",
1137
+ gap: "2px"
1138
+ };
1139
+ const spinnerStyle = {
1140
+ display: "flex",
1141
+ alignItems: "center",
1142
+ justifyContent: "center",
1143
+ backgroundColor: "transparent",
1144
+ height: lineHeight
1145
+ };
1146
+ const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1147
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1148
+ "button",
1149
+ {
1150
+ ...buttonProps,
1151
+ type,
1152
+ className,
1153
+ disabled: isDisabled,
1154
+ onClick: handleClick,
1155
+ onMouseEnter: handleMouseEnter,
1156
+ onMouseLeave: handleMouseLeave,
1157
+ onMouseDown: handleMouseDown,
1158
+ onMouseUp: handleMouseUp,
1159
+ onKeyDown: handleKeyDown,
1160
+ onKeyUp: handleKeyUp,
1161
+ onFocus: handleFocus,
1162
+ onBlur: handleBlur,
1163
+ "aria-label": computedAriaLabel,
1164
+ "aria-busy": loading || void 0,
1165
+ "aria-disabled": isDisabled || void 0,
1166
+ "aria-describedby": ariaDescribedBy,
1167
+ "aria-expanded": ariaExpanded,
1168
+ "aria-haspopup": ariaHasPopup,
1169
+ "aria-pressed": ariaPressed,
1170
+ "aria-controls": ariaControls,
1171
+ tabIndex,
1172
+ style: buttonStyle,
1173
+ "data-testid": testID || "flex-button",
1174
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: contentStyle, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: spinnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1175
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1176
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
1177
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { size: iconSize, color: colors.text, children: iconRight })
1178
+ ] }) })
1179
+ }
1180
+ );
1181
+ };
1182
+ FlexButton.displayName = "FlexButton";
1183
+
1184
+ // src/ButtonGroup.tsx
1185
+ var import_xui_core4 = require("@xsolla/xui-core");
1186
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1187
+ var ButtonGroup = ({
1188
+ orientation = "horizontal",
1189
+ size = "m",
1190
+ children,
1191
+ description,
1192
+ error,
1193
+ gap,
1194
+ "aria-label": ariaLabel,
1195
+ "aria-labelledby": ariaLabelledBy,
1196
+ "aria-describedby": ariaDescribedBy,
1197
+ id,
1198
+ testID
1199
+ }) => {
1200
+ const { theme } = (0, import_xui_core4.useDesignSystem)();
1201
+ const verticalGapMap = {
1202
+ xl: 16,
1203
+ l: 16,
1204
+ m: 12,
1205
+ s: 8,
1206
+ xs: 4
1207
+ };
1208
+ const horizontalGapMap = {
1209
+ xl: 16,
1210
+ l: 16,
1211
+ m: 16,
1212
+ s: 12,
1213
+ xs: 12
1214
+ };
1215
+ const computedGap = gap ?? (orientation === "vertical" ? verticalGapMap[size] : horizontalGapMap[size]);
1216
+ const descriptionId = id ? `${id}-description` : void 0;
1217
+ const errorId = id ? `${id}-error` : void 0;
1218
+ const computedAriaDescribedBy = [
1219
+ ariaDescribedBy,
1220
+ error && errorId ? errorId : void 0,
1221
+ description && !error && descriptionId ? descriptionId : void 0
1222
+ ].filter(Boolean).join(" ") || void 0;
1223
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1224
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1225
+ Box,
1226
+ {
1227
+ role: "group",
1228
+ "aria-label": ariaLabel,
1229
+ "aria-labelledby": ariaLabelledBy,
1230
+ "aria-describedby": computedAriaDescribedBy,
1231
+ id,
1232
+ testID,
1233
+ flexDirection: orientation === "horizontal" ? "row" : "column",
1234
+ alignItems: "stretch",
1235
+ gap: computedGap,
1236
+ width: "100%",
1237
+ children
1238
+ }
1239
+ ),
1240
+ error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1241
+ Text,
1242
+ {
1243
+ id: errorId,
1244
+ role: "alert",
1245
+ "aria-live": "assertive",
1246
+ color: theme.colors.content.alert.primary,
1247
+ fontSize: 14,
1248
+ fontWeight: "400",
1249
+ children: error
1250
+ }
1251
+ ) }),
1252
+ description && !error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1253
+ Text,
1254
+ {
1255
+ id: descriptionId,
1256
+ color: theme.colors.content.tertiary,
1257
+ fontSize: 14,
1258
+ fontWeight: "400",
1259
+ children: description
1260
+ }
1261
+ ) })
1262
+ ] });
1263
+ };
1264
+ ButtonGroup.displayName = "ButtonGroup";
1265
+ // Annotate the CommonJS export names for ESM import in node:
1266
+ 0 && (module.exports = {
1267
+ Button,
1268
+ ButtonGroup,
1269
+ FlexButton,
1270
+ IconButton
1271
+ });
1272
+ //# sourceMappingURL=index.js.map