@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/native/index.d.mts +7 -1
- package/native/index.d.ts +7 -1
- package/native/index.js +53 -15
- package/native/index.js.map +1 -1
- package/native/index.mjs +53 -15
- 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 +53 -15
- package/web/index.js.map +1 -1
- package/web/index.mjs +53 -15
- package/web/index.mjs.map +1 -1
package/native/index.d.mts
CHANGED
|
@@ -33,11 +33,17 @@ interface ButtonProps extends ThemeOverrideProps {
|
|
|
33
33
|
/** Alignment of the label text */
|
|
34
34
|
labelAlignment?: "left" | "center";
|
|
35
35
|
/**
|
|
36
|
-
* Small icon displayed directly
|
|
36
|
+
* Small icon displayed directly to the left of the label text.
|
|
37
37
|
* Size and color are automatically set based on button size/state.
|
|
38
38
|
* To override, specify size/color on the icon: `labelIcon={<InfoIcon size={12} />}`
|
|
39
39
|
*/
|
|
40
40
|
labelIcon?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Small icon displayed directly to the right of the label text.
|
|
43
|
+
* Size and color are automatically set based on button size/state.
|
|
44
|
+
* To override, specify size/color on the icon: `labelIconRight={<InfoIcon size={12} />}`
|
|
45
|
+
*/
|
|
46
|
+
labelIconRight?: React.ReactNode;
|
|
41
47
|
/** Custom content slot for badges, tags, or other elements */
|
|
42
48
|
customContent?: React.ReactNode;
|
|
43
49
|
/** Accessible label for screen readers (use for icon-only buttons) */
|
package/native/index.d.ts
CHANGED
|
@@ -33,11 +33,17 @@ interface ButtonProps extends ThemeOverrideProps {
|
|
|
33
33
|
/** Alignment of the label text */
|
|
34
34
|
labelAlignment?: "left" | "center";
|
|
35
35
|
/**
|
|
36
|
-
* Small icon displayed directly
|
|
36
|
+
* Small icon displayed directly to the left of the label text.
|
|
37
37
|
* Size and color are automatically set based on button size/state.
|
|
38
38
|
* To override, specify size/color on the icon: `labelIcon={<InfoIcon size={12} />}`
|
|
39
39
|
*/
|
|
40
40
|
labelIcon?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Small icon displayed directly to the right of the label text.
|
|
43
|
+
* Size and color are automatically set based on button size/state.
|
|
44
|
+
* To override, specify size/color on the icon: `labelIconRight={<InfoIcon size={12} />}`
|
|
45
|
+
*/
|
|
46
|
+
labelIconRight?: React.ReactNode;
|
|
41
47
|
/** Custom content slot for badges, tags, or other elements */
|
|
42
48
|
customContent?: React.ReactNode;
|
|
43
49
|
/** Accessible label for screen readers (use for icon-only buttons) */
|
package/native/index.js
CHANGED
|
@@ -368,6 +368,7 @@ var Button = ({
|
|
|
368
368
|
sublabel,
|
|
369
369
|
labelAlignment = "center",
|
|
370
370
|
labelIcon,
|
|
371
|
+
labelIconRight,
|
|
371
372
|
customContent,
|
|
372
373
|
"aria-label": ariaLabel,
|
|
373
374
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -404,14 +405,21 @@ var Button = ({
|
|
|
404
405
|
ghost: "#000",
|
|
405
406
|
disable: "#666"
|
|
406
407
|
};
|
|
407
|
-
const handlePress = () => {
|
|
408
|
-
if (
|
|
408
|
+
const handlePress = (e) => {
|
|
409
|
+
if (isDisabled) {
|
|
410
|
+
e?.preventDefault();
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (onPress) {
|
|
409
414
|
onPress();
|
|
410
415
|
}
|
|
411
416
|
};
|
|
412
417
|
const handleKeyDown = (e) => {
|
|
413
|
-
if (isDisabled) return;
|
|
414
418
|
if (e.key === "Enter" || e.key === " ") {
|
|
419
|
+
if (isDisabled) {
|
|
420
|
+
e.preventDefault();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
415
423
|
e.preventDefault();
|
|
416
424
|
setIsKeyboardPressed(true);
|
|
417
425
|
}
|
|
@@ -426,14 +434,23 @@ var Button = ({
|
|
|
426
434
|
}
|
|
427
435
|
}
|
|
428
436
|
};
|
|
437
|
+
const brandControl = theme?.colors?.control?.brand;
|
|
438
|
+
const disabledBg = brandControl?.primary?.bgDisable ?? variantStyles.bgDisable ?? variantStyles.bg;
|
|
439
|
+
const disabledBorder = brandControl?.primary?.borderDisable ?? variantStyles.borderDisable ?? variantStyles.border;
|
|
440
|
+
const disabledText = brandControl?.text?.disable ?? textStyles.disable;
|
|
429
441
|
let backgroundColor = variantStyles.bg;
|
|
430
442
|
if (disabled) {
|
|
431
|
-
backgroundColor =
|
|
443
|
+
backgroundColor = disabledBg;
|
|
432
444
|
} else if (isKeyboardPressed) {
|
|
433
445
|
backgroundColor = variantStyles.bgPress || variantStyles.bg;
|
|
434
446
|
}
|
|
435
|
-
|
|
436
|
-
|
|
447
|
+
let borderColor = variantStyles.border;
|
|
448
|
+
if (disabled) {
|
|
449
|
+
borderColor = disabledBorder;
|
|
450
|
+
} else if (isKeyboardPressed) {
|
|
451
|
+
borderColor = variantStyles.borderPress || variantStyles.border;
|
|
452
|
+
}
|
|
453
|
+
const textColor = disabled ? disabledText : textStyles[variant];
|
|
437
454
|
const computedAriaLabel = ariaLabel;
|
|
438
455
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
439
456
|
Box,
|
|
@@ -444,7 +461,6 @@ var Button = ({
|
|
|
444
461
|
onPress: handlePress,
|
|
445
462
|
onKeyDown: handleKeyDown,
|
|
446
463
|
onKeyUp: handleKeyUp,
|
|
447
|
-
disabled: isDisabled,
|
|
448
464
|
"aria-label": computedAriaLabel,
|
|
449
465
|
"aria-disabled": isDisabled || void 0,
|
|
450
466
|
"aria-busy": loading || void 0,
|
|
@@ -466,12 +482,17 @@ var Button = ({
|
|
|
466
482
|
justifyContent: "center",
|
|
467
483
|
position: "relative",
|
|
468
484
|
cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
|
|
469
|
-
style: {
|
|
485
|
+
style: {
|
|
486
|
+
transition: "background-color 500ms ease, border-color 500ms ease",
|
|
487
|
+
opacity: 1
|
|
488
|
+
},
|
|
470
489
|
hoverStyle: !isDisabled ? {
|
|
471
|
-
backgroundColor: variantStyles?.bgHover
|
|
490
|
+
backgroundColor: variantStyles?.bgHover,
|
|
491
|
+
borderColor: variantStyles?.borderHover
|
|
472
492
|
} : void 0,
|
|
473
493
|
pressStyle: !isDisabled ? {
|
|
474
|
-
backgroundColor: variantStyles?.bgPress
|
|
494
|
+
backgroundColor: variantStyles?.bgPress,
|
|
495
|
+
borderColor: variantStyles?.borderPress
|
|
475
496
|
} : void 0,
|
|
476
497
|
focusStyle: {
|
|
477
498
|
outlineColor: theme.colors.border.brand,
|
|
@@ -537,12 +558,27 @@ var Button = ({
|
|
|
537
558
|
sizeStyles.labelIconSize,
|
|
538
559
|
textColor
|
|
539
560
|
) }),
|
|
540
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
541
|
-
sublabel && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
542
562
|
Text,
|
|
543
563
|
{
|
|
544
564
|
color: textColor,
|
|
545
565
|
fontSize: sizeStyles.fontSize,
|
|
566
|
+
lineHeight: sizeStyles.lineHeight,
|
|
567
|
+
fontWeight: "500",
|
|
568
|
+
children
|
|
569
|
+
}
|
|
570
|
+
),
|
|
571
|
+
labelIconRight && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
|
|
572
|
+
labelIconRight,
|
|
573
|
+
sizeStyles.labelIconSize,
|
|
574
|
+
textColor
|
|
575
|
+
) }),
|
|
576
|
+
sublabel && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
577
|
+
Text,
|
|
578
|
+
{
|
|
579
|
+
color: textColor,
|
|
580
|
+
fontSize: sizeStyles.sublabelFontSize,
|
|
581
|
+
lineHeight: sizeStyles.lineHeight,
|
|
546
582
|
fontWeight: "500",
|
|
547
583
|
style: { opacity: 0.4 },
|
|
548
584
|
children: sublabel
|
|
@@ -1404,7 +1440,7 @@ var ButtonGroup = ({
|
|
|
1404
1440
|
}
|
|
1405
1441
|
return processedChildren;
|
|
1406
1442
|
};
|
|
1407
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { flexDirection: "column", width: "100%", gap:
|
|
1443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { flexDirection: "column", width: "100%", gap: 12, children: [
|
|
1408
1444
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1409
1445
|
Box,
|
|
1410
1446
|
{
|
|
@@ -1422,7 +1458,7 @@ var ButtonGroup = ({
|
|
|
1422
1458
|
children: renderChildren()
|
|
1423
1459
|
}
|
|
1424
1460
|
),
|
|
1425
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, {
|
|
1461
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1426
1462
|
Text,
|
|
1427
1463
|
{
|
|
1428
1464
|
id: errorId,
|
|
@@ -1430,17 +1466,19 @@ var ButtonGroup = ({
|
|
|
1430
1466
|
"aria-live": "assertive",
|
|
1431
1467
|
color: theme.colors.content.alert.primary,
|
|
1432
1468
|
fontSize: 14,
|
|
1469
|
+
lineHeight: 18,
|
|
1433
1470
|
fontWeight: "400",
|
|
1434
1471
|
style: orientation === "vertical" ? { textAlign: "center" } : void 0,
|
|
1435
1472
|
children: error
|
|
1436
1473
|
}
|
|
1437
1474
|
) }),
|
|
1438
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, {
|
|
1475
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1439
1476
|
Text,
|
|
1440
1477
|
{
|
|
1441
1478
|
id: descriptionId,
|
|
1442
1479
|
color: theme.colors.content.tertiary,
|
|
1443
1480
|
fontSize: 14,
|
|
1481
|
+
lineHeight: 18,
|
|
1444
1482
|
fontWeight: "400",
|
|
1445
1483
|
style: orientation === "vertical" ? { textAlign: "center" } : void 0,
|
|
1446
1484
|
children: description
|