@xsolla/xui-button 0.171.2 → 0.171.3

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