@xsolla/xui-button 0.101.0 → 0.102.0

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
@@ -261,33 +261,9 @@ var Icon = ({ children, color, size }) => {
261
261
  return /* @__PURE__ */ jsx4(View3, { style, children: childrenWithProps });
262
262
  };
263
263
 
264
- // ../primitives-native/src/Divider.tsx
265
- import { View as View4 } from "react-native";
266
- import { jsx as jsx5 } from "react/jsx-runtime";
267
- var Divider = ({
268
- color,
269
- height,
270
- width,
271
- vertical,
272
- dashStroke
273
- }) => {
274
- const style = {
275
- backgroundColor: dashStroke ? "transparent" : color || "rgba(255, 255, 255, 0.15)",
276
- width: vertical ? typeof width === "number" ? width : 1 : "100%",
277
- height: vertical ? "100%" : typeof height === "number" ? height : 1,
278
- ...dashStroke && {
279
- borderStyle: "dashed",
280
- borderColor: color || "rgba(255, 255, 255, 0.15)",
281
- borderWidth: 0,
282
- ...vertical ? { borderLeftWidth: typeof width === "number" ? width : 1 } : { borderTopWidth: typeof height === "number" ? height : 1 }
283
- }
284
- };
285
- return /* @__PURE__ */ jsx5(View4, { style });
286
- };
287
-
288
264
  // src/Button.tsx
289
265
  import { useDesignSystem } from "@xsolla/xui-core";
290
- import { jsx as jsx6, jsxs } from "react/jsx-runtime";
266
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
291
267
  var cloneIconWithDefaults = (icon, defaultSize, defaultColor) => {
292
268
  if (!React2.isValidElement(icon)) return icon;
293
269
  const iconElement = icon;
@@ -309,7 +285,6 @@ var Button = ({
309
285
  onPress,
310
286
  iconLeft,
311
287
  iconRight,
312
- divider,
313
288
  sublabel,
314
289
  labelAlignment = "center",
315
290
  labelIcon,
@@ -338,8 +313,13 @@ var Button = ({
338
313
  border: "transparent",
339
314
  borderHover: "transparent",
340
315
  borderPress: "transparent",
341
- borderDisable: "transparent",
342
- text: { primary: "#000", secondary: "#000", disable: "#666" }
316
+ borderDisable: "transparent"
317
+ };
318
+ const textStyles = controlTone?.text || theme?.colors?.control?.brand?.text || {
319
+ primary: "#000",
320
+ secondary: "#fff",
321
+ tertiary: "#888",
322
+ disable: "#666"
343
323
  };
344
324
  const handlePress = () => {
345
325
  if (!isDisabled && onPress) {
@@ -370,12 +350,7 @@ var Button = ({
370
350
  backgroundColor = variantStyles.bgPress || variantStyles.bg;
371
351
  }
372
352
  const borderColor = disabled ? variantStyles.borderDisable || variantStyles.border : variantStyles.border;
373
- const textColor = disabled ? variantStyles.text?.disable || variantStyles.text?.primary : variantStyles.text?.primary;
374
- const textColorStr = typeof textColor === "string" ? textColor : "";
375
- const isDarkText = textColorStr === "#000000" || textColorStr === "black" || textColorStr.startsWith("rgba(0, 0, 0");
376
- const dividerLineColor = isDarkText ? "rgba(0, 0, 0, 0.2)" : "rgba(255, 255, 255, 0.2)";
377
- const hasIcon = Boolean(iconLeft || iconRight);
378
- const showDivider = divider !== void 0 ? divider : hasIcon;
353
+ const textColor = disabled ? textStyles.disable : textStyles[variant];
379
354
  const computedAriaLabel = ariaLabel;
380
355
  return /* @__PURE__ */ jsxs(
381
356
  Box,
@@ -422,7 +397,7 @@ var Button = ({
422
397
  outlineStyle: "solid"
423
398
  },
424
399
  children: [
425
- loading && /* @__PURE__ */ jsx6(
400
+ loading && /* @__PURE__ */ jsx5(
426
401
  Box,
427
402
  {
428
403
  position: "absolute",
@@ -433,7 +408,7 @@ var Button = ({
433
408
  alignItems: "center",
434
409
  justifyContent: "center",
435
410
  zIndex: 1,
436
- children: /* @__PURE__ */ jsx6(
411
+ children: /* @__PURE__ */ jsx5(
437
412
  Spinner,
438
413
  {
439
414
  color: textColor,
@@ -443,30 +418,19 @@ var Button = ({
443
418
  )
444
419
  }
445
420
  ),
446
- iconLeft && /* @__PURE__ */ jsxs(
421
+ iconLeft && /* @__PURE__ */ jsx5(
447
422
  Box,
448
423
  {
449
- height: "100%",
450
- flexDirection: "row",
424
+ width: sizeStyles.iconContainerSize,
425
+ height: sizeStyles.iconContainerSize,
451
426
  alignItems: "center",
427
+ justifyContent: "center",
452
428
  "aria-hidden": true,
453
429
  style: {
454
430
  opacity: loading ? 0 : 1,
455
431
  pointerEvents: loading ? "none" : "auto"
456
432
  },
457
- children: [
458
- /* @__PURE__ */ jsx6(
459
- Box,
460
- {
461
- width: sizeStyles.iconContainerSize,
462
- height: sizeStyles.iconContainerSize,
463
- alignItems: "center",
464
- justifyContent: "center",
465
- children: cloneIconWithDefaults(iconLeft, sizeStyles.iconSize, textColor)
466
- }
467
- ),
468
- showDivider && /* @__PURE__ */ jsx6(Divider, { vertical: true, color: dividerLineColor, height: "100%" })
469
- ]
433
+ children: cloneIconWithDefaults(iconLeft, sizeStyles.iconSize, textColor)
470
434
  }
471
435
  ),
472
436
  /* @__PURE__ */ jsxs(
@@ -485,13 +449,13 @@ var Button = ({
485
449
  },
486
450
  "aria-hidden": loading ? true : void 0,
487
451
  children: [
488
- labelIcon && /* @__PURE__ */ jsx6(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
452
+ labelIcon && /* @__PURE__ */ jsx5(Box, { "aria-hidden": true, children: cloneIconWithDefaults(
489
453
  labelIcon,
490
454
  sizeStyles.labelIconSize,
491
455
  textColor
492
456
  ) }),
493
- /* @__PURE__ */ jsx6(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
494
- sublabel && /* @__PURE__ */ jsx6(
457
+ /* @__PURE__ */ jsx5(Text, { color: textColor, fontSize: sizeStyles.fontSize, fontWeight: "500", children }),
458
+ sublabel && /* @__PURE__ */ jsx5(
495
459
  Text,
496
460
  {
497
461
  color: textColor,
@@ -501,34 +465,23 @@ var Button = ({
501
465
  children: sublabel
502
466
  }
503
467
  ),
504
- customContent && /* @__PURE__ */ jsx6(Box, { "aria-hidden": true, children: customContent })
468
+ customContent && /* @__PURE__ */ jsx5(Box, { "aria-hidden": true, children: customContent })
505
469
  ]
506
470
  }
507
471
  ),
508
- iconRight && /* @__PURE__ */ jsxs(
472
+ iconRight && /* @__PURE__ */ jsx5(
509
473
  Box,
510
474
  {
511
- height: "100%",
512
- flexDirection: "row",
475
+ width: sizeStyles.iconContainerSize,
476
+ height: sizeStyles.iconContainerSize,
513
477
  alignItems: "center",
478
+ justifyContent: "center",
514
479
  "aria-hidden": true,
515
480
  style: {
516
481
  opacity: loading ? 0 : 1,
517
482
  pointerEvents: loading ? "none" : "auto"
518
483
  },
519
- children: [
520
- showDivider && /* @__PURE__ */ jsx6(Divider, { vertical: true, color: dividerLineColor, height: "100%" }),
521
- /* @__PURE__ */ jsx6(
522
- Box,
523
- {
524
- width: sizeStyles.iconContainerSize,
525
- height: sizeStyles.iconContainerSize,
526
- alignItems: "center",
527
- justifyContent: "center",
528
- children: cloneIconWithDefaults(iconRight, sizeStyles.iconSize, textColor)
529
- }
530
- )
531
- ]
484
+ children: cloneIconWithDefaults(iconRight, sizeStyles.iconSize, textColor)
532
485
  }
533
486
  )
534
487
  ]
@@ -540,7 +493,7 @@ Button.displayName = "Button";
540
493
  // src/IconButton.tsx
541
494
  import React3, { useState as useState2 } from "react";
542
495
  import { useDesignSystem as useDesignSystem2 } from "@xsolla/xui-core";
543
- import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
496
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
544
497
  var cloneIconWithDefaults2 = (icon, defaultSize, defaultColor) => {
545
498
  if (!React3.isValidElement(icon)) return icon;
546
499
  const iconElement = icon;
@@ -661,7 +614,7 @@ var IconButton = ({
661
614
  outlineStyle: "solid"
662
615
  },
663
616
  children: [
664
- loading && /* @__PURE__ */ jsx7(
617
+ loading && /* @__PURE__ */ jsx6(
665
618
  Box,
666
619
  {
667
620
  position: "absolute",
@@ -672,7 +625,7 @@ var IconButton = ({
672
625
  alignItems: "center",
673
626
  justifyContent: "center",
674
627
  zIndex: 1,
675
- children: /* @__PURE__ */ jsx7(
628
+ children: /* @__PURE__ */ jsx6(
676
629
  Spinner,
677
630
  {
678
631
  color: textColor,
@@ -682,7 +635,7 @@ var IconButton = ({
682
635
  )
683
636
  }
684
637
  ),
685
- /* @__PURE__ */ jsx7(
638
+ /* @__PURE__ */ jsx6(
686
639
  Box,
687
640
  {
688
641
  "aria-hidden": true,
@@ -705,7 +658,7 @@ import {
705
658
  useState as useState3
706
659
  } from "react";
707
660
  import { useDesignSystem as useDesignSystem3 } from "@xsolla/xui-core";
708
- import { Fragment, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
661
+ import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
709
662
  var ICON_SIZES = {
710
663
  xs: 12,
711
664
  sm: 14,
@@ -1000,7 +953,7 @@ var FlexButton = ({
1000
953
  height: lineHeight
1001
954
  };
1002
955
  const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1003
- return /* @__PURE__ */ jsx8(
956
+ return /* @__PURE__ */ jsx7(
1004
957
  "button",
1005
958
  {
1006
959
  ...buttonProps,
@@ -1027,10 +980,10 @@ var FlexButton = ({
1027
980
  tabIndex,
1028
981
  style: buttonStyle,
1029
982
  "data-testid": testID || "flex-button",
1030
- children: /* @__PURE__ */ jsx8("span", { style: contentStyle, children: loading ? /* @__PURE__ */ jsx8("span", { style: spinnerStyle, children: /* @__PURE__ */ jsx8(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
1031
- iconLeft && /* @__PURE__ */ jsx8(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1032
- /* @__PURE__ */ jsx8("span", { children }),
1033
- iconRight && /* @__PURE__ */ jsx8(Icon, { size: iconSize, color: colors.text, children: iconRight })
983
+ children: /* @__PURE__ */ jsx7("span", { style: contentStyle, children: loading ? /* @__PURE__ */ jsx7("span", { style: spinnerStyle, children: /* @__PURE__ */ jsx7(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
984
+ iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
985
+ /* @__PURE__ */ jsx7("span", { children }),
986
+ iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1034
987
  ] }) })
1035
988
  }
1036
989
  );
@@ -1040,7 +993,7 @@ FlexButton.displayName = "FlexButton";
1040
993
  // src/ButtonGroup.tsx
1041
994
  import React5 from "react";
1042
995
  import { useDesignSystem as useDesignSystem4 } from "@xsolla/xui-core";
1043
- import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
996
+ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1044
997
  var ButtonGroup = ({
1045
998
  orientation = "horizontal",
1046
999
  size = "md",
@@ -1113,7 +1066,7 @@ var ButtonGroup = ({
1113
1066
  const restChildren = processedChildren.slice(1);
1114
1067
  return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1115
1068
  firstChild,
1116
- /* @__PURE__ */ jsx9(Box, { flexDirection: "row", gap: computedGap, children: restChildren })
1069
+ /* @__PURE__ */ jsx8(Box, { flexDirection: "row", gap: computedGap, children: restChildren })
1117
1070
  ] });
1118
1071
  }
1119
1072
  if (orientation === "vertical") {
@@ -1122,7 +1075,7 @@ var ButtonGroup = ({
1122
1075
  return children;
1123
1076
  };
1124
1077
  return /* @__PURE__ */ jsxs4(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
1125
- /* @__PURE__ */ jsx9(
1078
+ /* @__PURE__ */ jsx8(
1126
1079
  Box,
1127
1080
  {
1128
1081
  role: "group",
@@ -1139,7 +1092,7 @@ var ButtonGroup = ({
1139
1092
  children: renderChildren()
1140
1093
  }
1141
1094
  ),
1142
- error && /* @__PURE__ */ jsx9(Box, { marginTop: 4, children: /* @__PURE__ */ jsx9(
1095
+ error && /* @__PURE__ */ jsx8(Box, { marginTop: 4, children: /* @__PURE__ */ jsx8(
1143
1096
  Text,
1144
1097
  {
1145
1098
  id: errorId,
@@ -1152,7 +1105,7 @@ var ButtonGroup = ({
1152
1105
  children: error
1153
1106
  }
1154
1107
  ) }),
1155
- description && /* @__PURE__ */ jsx9(Box, { marginTop: 4, children: /* @__PURE__ */ jsx9(
1108
+ description && /* @__PURE__ */ jsx8(Box, { marginTop: 4, children: /* @__PURE__ */ jsx8(
1156
1109
  Text,
1157
1110
  {
1158
1111
  id: descriptionId,