@xsolla/xui-button 0.171.2 → 0.171.3-pr341.1781516667

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
@@ -429,6 +429,7 @@ var Button = ({
429
429
  sublabel,
430
430
  labelAlignment = "center",
431
431
  labelIcon,
432
+ labelIconRight,
432
433
  customContent,
433
434
  "aria-label": ariaLabel,
434
435
  "aria-describedby": ariaDescribedBy,
@@ -465,14 +466,21 @@ var Button = ({
465
466
  ghost: "#000",
466
467
  disable: "#666"
467
468
  };
468
- const handlePress = () => {
469
- if (!isDisabled && onPress) {
469
+ const handlePress = (e) => {
470
+ if (isDisabled) {
471
+ e?.preventDefault();
472
+ return;
473
+ }
474
+ if (onPress) {
470
475
  onPress();
471
476
  }
472
477
  };
473
478
  const handleKeyDown = (e) => {
474
- if (isDisabled) return;
475
479
  if (e.key === "Enter" || e.key === " ") {
480
+ if (isDisabled) {
481
+ e.preventDefault();
482
+ return;
483
+ }
476
484
  e.preventDefault();
477
485
  setIsKeyboardPressed(true);
478
486
  }
@@ -487,14 +495,23 @@ var Button = ({
487
495
  }
488
496
  }
489
497
  };
498
+ const brandControl = theme?.colors?.control?.brand;
499
+ const disabledBg = brandControl?.primary?.bgDisable ?? variantStyles.bgDisable ?? variantStyles.bg;
500
+ const disabledBorder = brandControl?.primary?.borderDisable ?? variantStyles.borderDisable ?? variantStyles.border;
501
+ const disabledText = brandControl?.text?.disable ?? textStyles.disable;
490
502
  let backgroundColor = variantStyles.bg;
491
503
  if (disabled) {
492
- backgroundColor = variantStyles.bgDisable || variantStyles.bg;
504
+ backgroundColor = disabledBg;
493
505
  } else if (isKeyboardPressed) {
494
506
  backgroundColor = variantStyles.bgPress || variantStyles.bg;
495
507
  }
496
- const borderColor = disabled ? variantStyles.borderDisable || variantStyles.border : variantStyles.border;
497
- const textColor = disabled ? textStyles.disable : textStyles[variant];
508
+ let borderColor = variantStyles.border;
509
+ if (disabled) {
510
+ borderColor = disabledBorder;
511
+ } else if (isKeyboardPressed) {
512
+ borderColor = variantStyles.borderPress || variantStyles.border;
513
+ }
514
+ const textColor = disabled ? disabledText : textStyles[variant];
498
515
  const computedAriaLabel = ariaLabel;
499
516
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
500
517
  Box,
@@ -505,7 +522,6 @@ var Button = ({
505
522
  onPress: handlePress,
506
523
  onKeyDown: handleKeyDown,
507
524
  onKeyUp: handleKeyUp,
508
- disabled: isDisabled,
509
525
  "aria-label": computedAriaLabel,
510
526
  "aria-disabled": isDisabled || void 0,
511
527
  "aria-busy": loading || void 0,
@@ -527,12 +543,17 @@ var Button = ({
527
543
  justifyContent: "center",
528
544
  position: "relative",
529
545
  cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
530
- style: { transition: "background-color 500ms ease", opacity: 1 },
546
+ style: {
547
+ transition: "background-color 500ms ease, border-color 500ms ease",
548
+ opacity: 1
549
+ },
531
550
  hoverStyle: !isDisabled ? {
532
- backgroundColor: variantStyles?.bgHover
551
+ backgroundColor: variantStyles?.bgHover,
552
+ borderColor: variantStyles?.borderHover
533
553
  } : void 0,
534
554
  pressStyle: !isDisabled ? {
535
- backgroundColor: variantStyles?.bgPress
555
+ backgroundColor: variantStyles?.bgPress,
556
+ borderColor: variantStyles?.borderPress
536
557
  } : void 0,
537
558
  focusStyle: {
538
559
  outlineColor: theme.colors.border.brand,
@@ -598,12 +619,27 @@ var Button = ({
598
619
  sizeStyles.labelIconSize,
599
620
  textColor
600
621
  ) }),
601
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
602
- sublabel && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
622
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
603
623
  Text,
604
624
  {
605
625
  color: textColor,
606
626
  fontSize: sizeStyles.fontSize,
627
+ lineHeight: sizeStyles.lineHeight,
628
+ fontWeight: "500",
629
+ children
630
+ }
631
+ ),
632
+ labelIconRight && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
633
+ labelIconRight,
634
+ sizeStyles.labelIconSize,
635
+ textColor
636
+ ) }),
637
+ sublabel && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
638
+ Text,
639
+ {
640
+ color: textColor,
641
+ fontSize: sizeStyles.sublabelFontSize,
642
+ lineHeight: sizeStyles.lineHeight,
607
643
  fontWeight: "500",
608
644
  style: { opacity: 0.4 },
609
645
  children: sublabel
@@ -1465,7 +1501,7 @@ var ButtonGroup = ({
1465
1501
  }
1466
1502
  return processedChildren;
1467
1503
  };
1468
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1504
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 12, children: [
1469
1505
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1470
1506
  Box,
1471
1507
  {
@@ -1483,7 +1519,7 @@ var ButtonGroup = ({
1483
1519
  children: renderChildren()
1484
1520
  }
1485
1521
  ),
1486
- error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1522
+ error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1487
1523
  Text,
1488
1524
  {
1489
1525
  id: errorId,
@@ -1491,17 +1527,19 @@ var ButtonGroup = ({
1491
1527
  "aria-live": "assertive",
1492
1528
  color: theme.colors.content.alert.primary,
1493
1529
  fontSize: 14,
1530
+ lineHeight: 18,
1494
1531
  fontWeight: "400",
1495
1532
  style: orientation === "vertical" ? { textAlign: "center" } : void 0,
1496
1533
  children: error
1497
1534
  }
1498
1535
  ) }),
1499
- description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { marginTop: 4, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1536
+ description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1500
1537
  Text,
1501
1538
  {
1502
1539
  id: descriptionId,
1503
1540
  color: theme.colors.content.tertiary,
1504
1541
  fontSize: 14,
1542
+ lineHeight: 18,
1505
1543
  fontWeight: "400",
1506
1544
  style: orientation === "vertical" ? { textAlign: "center" } : void 0,
1507
1545
  children: description