@xsolla/xui-button 0.101.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/index.js CHANGED
@@ -307,34 +307,9 @@ var Icon = ({ children, ...props }) => {
307
307
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledIcon, { ...props, children });
308
308
  };
309
309
 
310
- // ../primitives-web/src/Divider.tsx
311
- var import_styled_components5 = __toESM(require("styled-components"));
312
- var import_jsx_runtime5 = require("react/jsx-runtime");
313
- var StyledDivider = import_styled_components5.default.div`
314
- background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
315
- width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
316
- height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
317
-
318
- ${(props) => props.dashStroke && `
319
- border-style: dashed;
320
- border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
321
- border-width: 0;
322
- ${props.vertical ? `
323
- border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
324
- height: 100%;
325
- ` : `
326
- border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
327
- width: 100%;
328
- `}
329
- `}
330
- `;
331
- var Divider = (props) => {
332
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledDivider, { ...props });
333
- };
334
-
335
310
  // src/Button.tsx
336
311
  var import_xui_core = require("@xsolla/xui-core");
337
- var import_jsx_runtime6 = require("react/jsx-runtime");
312
+ var import_jsx_runtime5 = require("react/jsx-runtime");
338
313
  var cloneIconWithDefaults = (icon, defaultSize, defaultColor) => {
339
314
  if (!import_react2.default.isValidElement(icon)) return icon;
340
315
  const iconElement = icon;
@@ -356,7 +331,6 @@ var Button = ({
356
331
  onPress,
357
332
  iconLeft,
358
333
  iconRight,
359
- divider,
360
334
  sublabel,
361
335
  labelAlignment = "center",
362
336
  labelIcon,
@@ -385,8 +359,13 @@ var Button = ({
385
359
  border: "transparent",
386
360
  borderHover: "transparent",
387
361
  borderPress: "transparent",
388
- borderDisable: "transparent",
389
- text: { primary: "#000", secondary: "#000", disable: "#666" }
362
+ borderDisable: "transparent"
363
+ };
364
+ const textStyles = controlTone?.text || theme?.colors?.control?.brand?.text || {
365
+ primary: "#000",
366
+ secondary: "#fff",
367
+ tertiary: "#888",
368
+ disable: "#666"
390
369
  };
391
370
  const handlePress = () => {
392
371
  if (!isDisabled && onPress) {
@@ -417,14 +396,9 @@ var Button = ({
417
396
  backgroundColor = variantStyles.bgPress || variantStyles.bg;
418
397
  }
419
398
  const borderColor = disabled ? variantStyles.borderDisable || variantStyles.border : variantStyles.border;
420
- const textColor = disabled ? variantStyles.text?.disable || variantStyles.text?.primary : variantStyles.text?.primary;
421
- const textColorStr = typeof textColor === "string" ? textColor : "";
422
- const isDarkText = textColorStr === "#000000" || textColorStr === "black" || textColorStr.startsWith("rgba(0, 0, 0");
423
- const dividerLineColor = isDarkText ? "rgba(0, 0, 0, 0.2)" : "rgba(255, 255, 255, 0.2)";
424
- const hasIcon = Boolean(iconLeft || iconRight);
425
- const showDivider = divider !== void 0 ? divider : hasIcon;
399
+ const textColor = disabled ? textStyles.disable : textStyles[variant];
426
400
  const computedAriaLabel = ariaLabel;
427
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
401
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
428
402
  Box,
429
403
  {
430
404
  as: "button",
@@ -469,7 +443,7 @@ var Button = ({
469
443
  outlineStyle: "solid"
470
444
  },
471
445
  children: [
472
- loading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
446
+ loading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
473
447
  Box,
474
448
  {
475
449
  position: "absolute",
@@ -480,7 +454,7 @@ var Button = ({
480
454
  alignItems: "center",
481
455
  justifyContent: "center",
482
456
  zIndex: 1,
483
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
457
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
484
458
  Spinner,
485
459
  {
486
460
  color: textColor,
@@ -490,33 +464,22 @@ var Button = ({
490
464
  )
491
465
  }
492
466
  ),
493
- iconLeft && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
467
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
494
468
  Box,
495
469
  {
496
- height: "100%",
497
- flexDirection: "row",
470
+ width: sizeStyles.iconContainerSize,
471
+ height: sizeStyles.iconContainerSize,
498
472
  alignItems: "center",
473
+ justifyContent: "center",
499
474
  "aria-hidden": true,
500
475
  style: {
501
476
  opacity: loading ? 0 : 1,
502
477
  pointerEvents: loading ? "none" : "auto"
503
478
  },
504
- children: [
505
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
506
- Box,
507
- {
508
- width: sizeStyles.iconContainerSize,
509
- height: sizeStyles.iconContainerSize,
510
- alignItems: "center",
511
- justifyContent: "center",
512
- children: cloneIconWithDefaults(iconLeft, sizeStyles.iconSize, textColor)
513
- }
514
- ),
515
- showDivider && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider, { vertical: true, color: dividerLineColor, height: "100%" })
516
- ]
479
+ children: cloneIconWithDefaults(iconLeft, sizeStyles.iconSize, textColor)
517
480
  }
518
481
  ),
519
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
482
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
520
483
  Box,
521
484
  {
522
485
  flex: fullWidth ? 1 : void 0,
@@ -532,13 +495,13 @@ var Button = ({
532
495
  },
533
496
  "aria-hidden": loading ? true : void 0,
534
497
  children: [
535
- labelIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
498
+ labelIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
536
499
  labelIcon,
537
500
  sizeStyles.labelIconSize,
538
501
  textColor
539
502
  ) }),
540
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
541
- sublabel && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
503
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
504
+ sublabel && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
542
505
  Text,
543
506
  {
544
507
  color: textColor,
@@ -548,34 +511,23 @@ var Button = ({
548
511
  children: sublabel
549
512
  }
550
513
  ),
551
- customContent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box, { "aria-hidden": true, children: customContent })
514
+ customContent && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { "aria-hidden": true, children: customContent })
552
515
  ]
553
516
  }
554
517
  ),
555
- iconRight && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
518
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
556
519
  Box,
557
520
  {
558
- height: "100%",
559
- flexDirection: "row",
521
+ width: sizeStyles.iconContainerSize,
522
+ height: sizeStyles.iconContainerSize,
560
523
  alignItems: "center",
524
+ justifyContent: "center",
561
525
  "aria-hidden": true,
562
526
  style: {
563
527
  opacity: loading ? 0 : 1,
564
528
  pointerEvents: loading ? "none" : "auto"
565
529
  },
566
- children: [
567
- showDivider && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider, { vertical: true, color: dividerLineColor, height: "100%" }),
568
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
569
- Box,
570
- {
571
- width: sizeStyles.iconContainerSize,
572
- height: sizeStyles.iconContainerSize,
573
- alignItems: "center",
574
- justifyContent: "center",
575
- children: cloneIconWithDefaults(iconRight, sizeStyles.iconSize, textColor)
576
- }
577
- )
578
- ]
530
+ children: cloneIconWithDefaults(iconRight, sizeStyles.iconSize, textColor)
579
531
  }
580
532
  )
581
533
  ]
@@ -587,7 +539,7 @@ Button.displayName = "Button";
587
539
  // src/IconButton.tsx
588
540
  var import_react3 = __toESM(require("react"));
589
541
  var import_xui_core2 = require("@xsolla/xui-core");
590
- var import_jsx_runtime7 = require("react/jsx-runtime");
542
+ var import_jsx_runtime6 = require("react/jsx-runtime");
591
543
  var cloneIconWithDefaults2 = (icon, defaultSize, defaultColor) => {
592
544
  if (!import_react3.default.isValidElement(icon)) return icon;
593
545
  const iconElement = icon;
@@ -663,7 +615,7 @@ var IconButton = ({
663
615
  }
664
616
  const borderColor = disabled ? variantStyles.borderDisable || variantStyles.border : variantStyles.border;
665
617
  const textColor = disabled ? variantStyles.text?.disable || variantStyles.text?.primary : variantStyles.text?.primary;
666
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
618
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
667
619
  Box,
668
620
  {
669
621
  as: "button",
@@ -708,7 +660,7 @@ var IconButton = ({
708
660
  outlineStyle: "solid"
709
661
  },
710
662
  children: [
711
- loading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
663
+ loading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
712
664
  Box,
713
665
  {
714
666
  position: "absolute",
@@ -719,7 +671,7 @@ var IconButton = ({
719
671
  alignItems: "center",
720
672
  justifyContent: "center",
721
673
  zIndex: 1,
722
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
674
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
723
675
  Spinner,
724
676
  {
725
677
  color: textColor,
@@ -729,7 +681,7 @@ var IconButton = ({
729
681
  )
730
682
  }
731
683
  ),
732
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
684
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
733
685
  Box,
734
686
  {
735
687
  "aria-hidden": true,
@@ -749,7 +701,7 @@ IconButton.displayName = "IconButton";
749
701
  // src/FlexButton.tsx
750
702
  var import_react4 = require("react");
751
703
  var import_xui_core3 = require("@xsolla/xui-core");
752
- var import_jsx_runtime8 = require("react/jsx-runtime");
704
+ var import_jsx_runtime7 = require("react/jsx-runtime");
753
705
  var ICON_SIZES = {
754
706
  xs: 12,
755
707
  sm: 14,
@@ -1044,7 +996,7 @@ var FlexButton = ({
1044
996
  height: lineHeight
1045
997
  };
1046
998
  const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1047
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
999
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1048
1000
  "button",
1049
1001
  {
1050
1002
  ...buttonProps,
@@ -1071,10 +1023,10 @@ var FlexButton = ({
1071
1023
  tabIndex,
1072
1024
  style: buttonStyle,
1073
1025
  "data-testid": testID || "flex-button",
1074
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: contentStyle, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: spinnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1075
- iconLeft && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1076
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children }),
1077
- iconRight && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: iconSize, color: colors.text, children: iconRight })
1026
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: contentStyle, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: spinnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1027
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1028
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children }),
1029
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconRight })
1078
1030
  ] }) })
1079
1031
  }
1080
1032
  );
@@ -1084,7 +1036,7 @@ FlexButton.displayName = "FlexButton";
1084
1036
  // src/ButtonGroup.tsx
1085
1037
  var import_react5 = __toESM(require("react"));
1086
1038
  var import_xui_core4 = require("@xsolla/xui-core");
1087
- var import_jsx_runtime9 = require("react/jsx-runtime");
1039
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1088
1040
  var ButtonGroup = ({
1089
1041
  orientation = "horizontal",
1090
1042
  size = "md",
@@ -1155,9 +1107,9 @@ var ButtonGroup = ({
1155
1107
  if (useSpaceBetween) {
1156
1108
  const firstChild = processedChildren[0];
1157
1109
  const restChildren = processedChildren.slice(1);
1158
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1110
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1159
1111
  firstChild,
1160
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { flexDirection: "row", gap: computedGap, children: restChildren })
1112
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flexDirection: "row", gap: computedGap, children: restChildren })
1161
1113
  ] });
1162
1114
  }
1163
1115
  if (orientation === "vertical") {
@@ -1165,8 +1117,8 @@ var ButtonGroup = ({
1165
1117
  }
1166
1118
  return children;
1167
1119
  };
1168
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1169
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1120
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1121
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1170
1122
  Box,
1171
1123
  {
1172
1124
  role: "group",
@@ -1183,7 +1135,7 @@ var ButtonGroup = ({
1183
1135
  children: renderChildren()
1184
1136
  }
1185
1137
  ),
1186
- error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1138
+ error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1187
1139
  Text,
1188
1140
  {
1189
1141
  id: errorId,
@@ -1196,7 +1148,7 @@ var ButtonGroup = ({
1196
1148
  children: error
1197
1149
  }
1198
1150
  ) }),
1199
- description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1151
+ description && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1200
1152
  Text,
1201
1153
  {
1202
1154
  id: descriptionId,
package/web/index.js.flow CHANGED
@@ -56,11 +56,6 @@ declare interface ButtonProps {
56
56
  */
57
57
  iconRight?: React.ReactNode;
58
58
 
59
- /**
60
- * Show/hide vertical divider between icon and content (default: true when icon present)
61
- */
62
- divider?: boolean;
63
-
64
59
  /**
65
60
  * Secondary text displayed inline with the main label (e.g., price), shown with 40% opacity
66
61
  */