@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/native/index.d.mts +7 -1
- package/native/index.d.ts +7 -1
- package/native/index.js +48 -12
- package/native/index.js.map +1 -1
- package/native/index.mjs +48 -12
- package/native/index.mjs.map +1 -1
- package/package.json +4 -4
- package/web/index.d.mts +7 -1
- package/web/index.d.ts +7 -1
- package/web/index.js +48 -12
- package/web/index.js.map +1 -1
- package/web/index.mjs +48 -12
- package/web/index.mjs.map +1 -1
package/web/index.mjs
CHANGED
|
@@ -389,6 +389,7 @@ var Button = ({
|
|
|
389
389
|
sublabel,
|
|
390
390
|
labelAlignment = "center",
|
|
391
391
|
labelIcon,
|
|
392
|
+
labelIconRight,
|
|
392
393
|
customContent,
|
|
393
394
|
"aria-label": ariaLabel,
|
|
394
395
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -425,14 +426,21 @@ var Button = ({
|
|
|
425
426
|
ghost: "#000",
|
|
426
427
|
disable: "#666"
|
|
427
428
|
};
|
|
428
|
-
const handlePress = () => {
|
|
429
|
-
if (
|
|
429
|
+
const handlePress = (e) => {
|
|
430
|
+
if (isDisabled) {
|
|
431
|
+
e?.preventDefault();
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (onPress) {
|
|
430
435
|
onPress();
|
|
431
436
|
}
|
|
432
437
|
};
|
|
433
438
|
const handleKeyDown = (e) => {
|
|
434
|
-
if (isDisabled) return;
|
|
435
439
|
if (e.key === "Enter" || e.key === " ") {
|
|
440
|
+
if (isDisabled) {
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
436
444
|
e.preventDefault();
|
|
437
445
|
setIsKeyboardPressed(true);
|
|
438
446
|
}
|
|
@@ -447,14 +455,23 @@ var Button = ({
|
|
|
447
455
|
}
|
|
448
456
|
}
|
|
449
457
|
};
|
|
458
|
+
const brandControl = theme?.colors?.control?.brand;
|
|
459
|
+
const disabledBg = brandControl?.primary?.bgDisable ?? variantStyles.bgDisable ?? variantStyles.bg;
|
|
460
|
+
const disabledBorder = brandControl?.primary?.borderDisable ?? variantStyles.borderDisable ?? variantStyles.border;
|
|
461
|
+
const disabledText = brandControl?.text?.disable ?? textStyles.disable;
|
|
450
462
|
let backgroundColor = variantStyles.bg;
|
|
451
463
|
if (disabled) {
|
|
452
|
-
backgroundColor =
|
|
464
|
+
backgroundColor = disabledBg;
|
|
453
465
|
} else if (isKeyboardPressed) {
|
|
454
466
|
backgroundColor = variantStyles.bgPress || variantStyles.bg;
|
|
455
467
|
}
|
|
456
|
-
|
|
457
|
-
|
|
468
|
+
let borderColor = variantStyles.border;
|
|
469
|
+
if (disabled) {
|
|
470
|
+
borderColor = disabledBorder;
|
|
471
|
+
} else if (isKeyboardPressed) {
|
|
472
|
+
borderColor = variantStyles.borderPress || variantStyles.border;
|
|
473
|
+
}
|
|
474
|
+
const textColor = disabled ? disabledText : textStyles[variant];
|
|
458
475
|
const computedAriaLabel = ariaLabel;
|
|
459
476
|
return /* @__PURE__ */ jsxs(
|
|
460
477
|
Box,
|
|
@@ -465,7 +482,6 @@ var Button = ({
|
|
|
465
482
|
onPress: handlePress,
|
|
466
483
|
onKeyDown: handleKeyDown,
|
|
467
484
|
onKeyUp: handleKeyUp,
|
|
468
|
-
disabled: isDisabled,
|
|
469
485
|
"aria-label": computedAriaLabel,
|
|
470
486
|
"aria-disabled": isDisabled || void 0,
|
|
471
487
|
"aria-busy": loading || void 0,
|
|
@@ -487,12 +503,17 @@ var Button = ({
|
|
|
487
503
|
justifyContent: "center",
|
|
488
504
|
position: "relative",
|
|
489
505
|
cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
|
|
490
|
-
style: {
|
|
506
|
+
style: {
|
|
507
|
+
transition: "background-color 500ms ease, border-color 500ms ease",
|
|
508
|
+
opacity: 1
|
|
509
|
+
},
|
|
491
510
|
hoverStyle: !isDisabled ? {
|
|
492
|
-
backgroundColor: variantStyles?.bgHover
|
|
511
|
+
backgroundColor: variantStyles?.bgHover,
|
|
512
|
+
borderColor: variantStyles?.borderHover
|
|
493
513
|
} : void 0,
|
|
494
514
|
pressStyle: !isDisabled ? {
|
|
495
|
-
backgroundColor: variantStyles?.bgPress
|
|
515
|
+
backgroundColor: variantStyles?.bgPress,
|
|
516
|
+
borderColor: variantStyles?.borderPress
|
|
496
517
|
} : void 0,
|
|
497
518
|
focusStyle: {
|
|
498
519
|
outlineColor: theme.colors.border.brand,
|
|
@@ -558,12 +579,27 @@ var Button = ({
|
|
|
558
579
|
sizeStyles.labelIconSize,
|
|
559
580
|
textColor
|
|
560
581
|
) }),
|
|
561
|
-
/* @__PURE__ */ jsx5(
|
|
562
|
-
sublabel && /* @__PURE__ */ jsx5(
|
|
582
|
+
/* @__PURE__ */ jsx5(
|
|
563
583
|
Text,
|
|
564
584
|
{
|
|
565
585
|
color: textColor,
|
|
566
586
|
fontSize: sizeStyles.fontSize,
|
|
587
|
+
lineHeight: sizeStyles.lineHeight,
|
|
588
|
+
fontWeight: "500",
|
|
589
|
+
children
|
|
590
|
+
}
|
|
591
|
+
),
|
|
592
|
+
labelIconRight && /* @__PURE__ */ jsx5(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
|
|
593
|
+
labelIconRight,
|
|
594
|
+
sizeStyles.labelIconSize,
|
|
595
|
+
textColor
|
|
596
|
+
) }),
|
|
597
|
+
sublabel && /* @__PURE__ */ jsx5(
|
|
598
|
+
Text,
|
|
599
|
+
{
|
|
600
|
+
color: textColor,
|
|
601
|
+
fontSize: sizeStyles.sublabelFontSize,
|
|
602
|
+
lineHeight: sizeStyles.lineHeight,
|
|
567
603
|
fontWeight: "500",
|
|
568
604
|
style: { opacity: 0.4 },
|
|
569
605
|
children: sublabel
|