@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.mjs CHANGED
@@ -335,6 +335,7 @@ var Button = ({
335
335
  sublabel,
336
336
  labelAlignment = "center",
337
337
  labelIcon,
338
+ labelIconRight,
338
339
  customContent,
339
340
  "aria-label": ariaLabel,
340
341
  "aria-describedby": ariaDescribedBy,
@@ -371,14 +372,21 @@ var Button = ({
371
372
  ghost: "#000",
372
373
  disable: "#666"
373
374
  };
374
- const handlePress = () => {
375
- if (!isDisabled && onPress) {
375
+ const handlePress = (e) => {
376
+ if (isDisabled) {
377
+ e?.preventDefault();
378
+ return;
379
+ }
380
+ if (onPress) {
376
381
  onPress();
377
382
  }
378
383
  };
379
384
  const handleKeyDown = (e) => {
380
- if (isDisabled) return;
381
385
  if (e.key === "Enter" || e.key === " ") {
386
+ if (isDisabled) {
387
+ e.preventDefault();
388
+ return;
389
+ }
382
390
  e.preventDefault();
383
391
  setIsKeyboardPressed(true);
384
392
  }
@@ -393,14 +401,23 @@ var Button = ({
393
401
  }
394
402
  }
395
403
  };
404
+ const brandControl = theme?.colors?.control?.brand;
405
+ const disabledBg = brandControl?.primary?.bgDisable ?? variantStyles.bgDisable ?? variantStyles.bg;
406
+ const disabledBorder = brandControl?.primary?.borderDisable ?? variantStyles.borderDisable ?? variantStyles.border;
407
+ const disabledText = brandControl?.text?.disable ?? textStyles.disable;
396
408
  let backgroundColor = variantStyles.bg;
397
409
  if (disabled) {
398
- backgroundColor = variantStyles.bgDisable || variantStyles.bg;
410
+ backgroundColor = disabledBg;
399
411
  } else if (isKeyboardPressed) {
400
412
  backgroundColor = variantStyles.bgPress || variantStyles.bg;
401
413
  }
402
- const borderColor = disabled ? variantStyles.borderDisable || variantStyles.border : variantStyles.border;
403
- const textColor = disabled ? textStyles.disable : textStyles[variant];
414
+ let borderColor = variantStyles.border;
415
+ if (disabled) {
416
+ borderColor = disabledBorder;
417
+ } else if (isKeyboardPressed) {
418
+ borderColor = variantStyles.borderPress || variantStyles.border;
419
+ }
420
+ const textColor = disabled ? disabledText : textStyles[variant];
404
421
  const computedAriaLabel = ariaLabel;
405
422
  return /* @__PURE__ */ jsxs(
406
423
  Box,
@@ -411,7 +428,6 @@ var Button = ({
411
428
  onPress: handlePress,
412
429
  onKeyDown: handleKeyDown,
413
430
  onKeyUp: handleKeyUp,
414
- disabled: isDisabled,
415
431
  "aria-label": computedAriaLabel,
416
432
  "aria-disabled": isDisabled || void 0,
417
433
  "aria-busy": loading || void 0,
@@ -433,12 +449,17 @@ var Button = ({
433
449
  justifyContent: "center",
434
450
  position: "relative",
435
451
  cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
436
- style: { transition: "background-color 500ms ease", opacity: 1 },
452
+ style: {
453
+ transition: "background-color 500ms ease, border-color 500ms ease",
454
+ opacity: 1
455
+ },
437
456
  hoverStyle: !isDisabled ? {
438
- backgroundColor: variantStyles?.bgHover
457
+ backgroundColor: variantStyles?.bgHover,
458
+ borderColor: variantStyles?.borderHover
439
459
  } : void 0,
440
460
  pressStyle: !isDisabled ? {
441
- backgroundColor: variantStyles?.bgPress
461
+ backgroundColor: variantStyles?.bgPress,
462
+ borderColor: variantStyles?.borderPress
442
463
  } : void 0,
443
464
  focusStyle: {
444
465
  outlineColor: theme.colors.border.brand,
@@ -504,12 +525,27 @@ var Button = ({
504
525
  sizeStyles.labelIconSize,
505
526
  textColor
506
527
  ) }),
507
- /* @__PURE__ */ jsx5(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
508
- sublabel && /* @__PURE__ */ jsx5(
528
+ /* @__PURE__ */ jsx5(
509
529
  Text,
510
530
  {
511
531
  color: textColor,
512
532
  fontSize: sizeStyles.fontSize,
533
+ lineHeight: sizeStyles.lineHeight,
534
+ fontWeight: "500",
535
+ children
536
+ }
537
+ ),
538
+ labelIconRight && /* @__PURE__ */ jsx5(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
539
+ labelIconRight,
540
+ sizeStyles.labelIconSize,
541
+ textColor
542
+ ) }),
543
+ sublabel && /* @__PURE__ */ jsx5(
544
+ Text,
545
+ {
546
+ color: textColor,
547
+ fontSize: sizeStyles.sublabelFontSize,
548
+ lineHeight: sizeStyles.lineHeight,
513
549
  fontWeight: "500",
514
550
  style: { opacity: 0.4 },
515
551
  children: sublabel
@@ -1374,7 +1410,7 @@ var ButtonGroup = ({
1374
1410
  }
1375
1411
  return processedChildren;
1376
1412
  };
1377
- return /* @__PURE__ */ jsxs5(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1413
+ return /* @__PURE__ */ jsxs5(Box, { flexDirection: "column", width: "100%", gap: 12, children: [
1378
1414
  /* @__PURE__ */ jsx9(
1379
1415
  Box,
1380
1416
  {
@@ -1392,7 +1428,7 @@ var ButtonGroup = ({
1392
1428
  children: renderChildren()
1393
1429
  }
1394
1430
  ),
1395
- error && /* @__PURE__ */ jsx9(Box, { marginTop: 4, children: /* @__PURE__ */ jsx9(
1431
+ error && /* @__PURE__ */ jsx9(Box, { children: /* @__PURE__ */ jsx9(
1396
1432
  Text,
1397
1433
  {
1398
1434
  id: errorId,
@@ -1400,17 +1436,19 @@ var ButtonGroup = ({
1400
1436
  "aria-live": "assertive",
1401
1437
  color: theme.colors.content.alert.primary,
1402
1438
  fontSize: 14,
1439
+ lineHeight: 18,
1403
1440
  fontWeight: "400",
1404
1441
  style: orientation === "vertical" ? { textAlign: "center" } : void 0,
1405
1442
  children: error
1406
1443
  }
1407
1444
  ) }),
1408
- description && /* @__PURE__ */ jsx9(Box, { marginTop: 4, children: /* @__PURE__ */ jsx9(
1445
+ description && /* @__PURE__ */ jsx9(Box, { children: /* @__PURE__ */ jsx9(
1409
1446
  Text,
1410
1447
  {
1411
1448
  id: descriptionId,
1412
1449
  color: theme.colors.content.tertiary,
1413
1450
  fontSize: 14,
1451
+ lineHeight: 18,
1414
1452
  fontWeight: "400",
1415
1453
  style: orientation === "vertical" ? { textAlign: "center" } : void 0,
1416
1454
  children: description