@xsolla/xui-button 0.192.0 → 0.193.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
@@ -776,11 +776,26 @@ IconButton.displayName = "IconButton";
776
776
 
777
777
  // src/FlexButton.tsx
778
778
  import React4, {
779
+ forwardRef,
779
780
  useRef,
780
781
  useState as useState3
781
782
  } from "react";
782
- import { useDesignSystem } from "@xsolla/xui-core";
783
+ import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
783
784
  import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
785
+ var ICON_SIZES = {
786
+ xs: 12,
787
+ sm: 14,
788
+ md: 16,
789
+ lg: 18,
790
+ xl: 20
791
+ };
792
+ var SPINNER_SIZES = {
793
+ xs: 12,
794
+ sm: 14,
795
+ md: 16,
796
+ lg: 18,
797
+ xl: 20
798
+ };
784
799
  var FLEX_BUTTON_PADDING = 4;
785
800
  var hasVisibleLabel = (node) => {
786
801
  if (node == null || node === false || node === true) return false;
@@ -799,20 +814,14 @@ var hasRenderableContent = (node) => {
799
814
  if (Array.isArray(node)) return node.some(hasRenderableContent);
800
815
  return true;
801
816
  };
802
- var ICON_SIZES = {
803
- xs: 12,
804
- sm: 14,
805
- md: 16,
806
- lg: 18,
807
- xl: 20
808
- };
809
- var SPINNER_SIZES = {
810
- xs: 12,
811
- sm: 14,
812
- md: 16,
813
- lg: 18,
814
- xl: 20
817
+ var BOX_SIZES = {
818
+ xs: 20,
819
+ sm: 22,
820
+ md: 28,
821
+ lg: 32,
822
+ xl: 36
815
823
  };
824
+ var getFlexButtonBoxSize = (size = "md") => BOX_SIZES[size];
816
825
  var LINE_HEIGHTS = {
817
826
  xs: "14px",
818
827
  sm: "16px",
@@ -834,325 +843,330 @@ var BORDER_RADIUS = {
834
843
  sm: 2,
835
844
  xs: 2
836
845
  };
837
- var FlexButton = ({
838
- children,
839
- variant = "brand",
840
- size = "md",
841
- background = false,
842
- hoverBackground = true,
843
- noPadding = false,
844
- disabled = false,
845
- loading = false,
846
- iconLeft,
847
- iconRight,
848
- onPress,
849
- onClick,
850
- className,
851
- type = "button",
852
- "aria-label": ariaLabel,
853
- "aria-describedby": ariaDescribedBy,
854
- "aria-expanded": ariaExpanded,
855
- "aria-haspopup": ariaHasPopup,
856
- "aria-pressed": ariaPressed,
857
- "aria-controls": ariaControls,
858
- testID,
859
- tabIndex = 0,
860
- ...buttonProps
861
- }) => {
862
- const { theme } = useDesignSystem();
863
- const [state, setState] = useState3("default");
864
- const [isFocused, setIsFocused] = useState3(false);
865
- const isMouseOverRef = useRef(false);
866
- const isDisabled = disabled || loading;
867
- const getVariantColors = (currentState) => {
868
- if (isDisabled) {
869
- return {
870
- bg: background ? theme.colors.overlay.mono : "transparent",
871
- text: theme.colors.control.text.disable,
872
- border: void 0
873
- };
874
- }
875
- const effectiveBackground = loading ? false : background;
876
- switch (variant) {
877
- case "brand":
878
- if (effectiveBackground) {
879
- return {
880
- bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
881
- text: theme.colors.content.on.brand,
882
- border: void 0
883
- };
884
- }
846
+ var FlexButton = forwardRef(
847
+ ({
848
+ children,
849
+ variant = "brand",
850
+ size = "md",
851
+ background = false,
852
+ hoverBackground = true,
853
+ noPadding = false,
854
+ disabled = false,
855
+ loading = false,
856
+ iconLeft,
857
+ iconRight,
858
+ onPress,
859
+ onClick,
860
+ className,
861
+ type = "button",
862
+ "aria-label": ariaLabel,
863
+ "aria-describedby": ariaDescribedBy,
864
+ "aria-expanded": ariaExpanded,
865
+ "aria-haspopup": ariaHasPopup,
866
+ "aria-pressed": ariaPressed,
867
+ "aria-controls": ariaControls,
868
+ testID,
869
+ tabIndex = 0,
870
+ themeMode,
871
+ themeProductContext,
872
+ ...buttonProps
873
+ }, ref) => {
874
+ const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
875
+ const [state, setState] = useState3("default");
876
+ const [isFocused, setIsFocused] = useState3(false);
877
+ const isMouseOverRef = useRef(false);
878
+ const isDisabled = disabled || loading;
879
+ const getVariantColors = (currentState) => {
880
+ if (isDisabled) {
885
881
  return {
886
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
887
- text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
882
+ bg: background ? theme.colors.overlay.mono : "transparent",
883
+ text: theme.colors.control.text.disable,
888
884
  border: void 0
889
885
  };
890
- case "primary":
891
- if (effectiveBackground) {
886
+ }
887
+ const effectiveBackground = loading ? false : background;
888
+ switch (variant) {
889
+ case "brand":
890
+ if (effectiveBackground) {
891
+ return {
892
+ bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
893
+ text: theme.colors.content.on.brand,
894
+ border: void 0
895
+ };
896
+ }
897
+ return {
898
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
899
+ text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
900
+ border: void 0
901
+ };
902
+ case "primary":
903
+ if (effectiveBackground) {
904
+ return {
905
+ bg: theme.colors.background.primary,
906
+ text: theme.colors.content.primary,
907
+ border: currentState === "press" ? theme.colors.border.primary : void 0
908
+ };
909
+ }
892
910
  return {
893
- bg: theme.colors.background.primary,
911
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
894
912
  text: theme.colors.content.primary,
895
913
  border: currentState === "press" ? theme.colors.border.primary : void 0
896
914
  };
897
- }
898
- return {
899
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
900
- text: theme.colors.content.primary,
901
- border: currentState === "press" ? theme.colors.border.primary : void 0
902
- };
903
- case "secondary":
904
- if (effectiveBackground) {
915
+ case "secondary":
916
+ if (effectiveBackground) {
917
+ return {
918
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
919
+ text: theme.colors.content.secondary,
920
+ border: void 0
921
+ };
922
+ }
905
923
  return {
906
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
907
- text: theme.colors.content.secondary,
924
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
925
+ text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
908
926
  border: void 0
909
927
  };
910
- }
911
- return {
912
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
913
- text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
914
- border: void 0
915
- };
916
- case "tertiary":
917
- if (effectiveBackground) {
928
+ case "tertiary":
929
+ if (effectiveBackground) {
930
+ return {
931
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
932
+ text: theme.colors.content.tertiary,
933
+ border: void 0
934
+ };
935
+ }
918
936
  return {
919
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
920
- text: theme.colors.content.tertiary,
937
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
938
+ text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
921
939
  border: void 0
922
940
  };
923
- }
924
- return {
925
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
926
- text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
927
- border: void 0
928
- };
929
- case "brandExtra":
930
- if (effectiveBackground) {
941
+ case "brandExtra":
942
+ if (effectiveBackground) {
943
+ return {
944
+ bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
945
+ text: theme.colors.content.on.brandExtra,
946
+ border: void 0
947
+ };
948
+ }
931
949
  return {
932
- bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
933
- text: theme.colors.content.on.brandExtra,
950
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
951
+ text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
934
952
  border: void 0
935
953
  };
936
- }
937
- return {
938
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
939
- text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
940
- border: void 0
941
- };
942
- case "inverse":
943
- if (effectiveBackground) {
954
+ case "inverse":
955
+ if (effectiveBackground) {
956
+ return {
957
+ bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
958
+ text: theme.colors.content.inverse,
959
+ border: void 0
960
+ };
961
+ }
944
962
  return {
945
- bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
963
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
946
964
  text: theme.colors.content.inverse,
947
965
  border: void 0
948
966
  };
949
- }
950
- return {
951
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
952
- text: theme.colors.content.inverse,
953
- border: void 0
954
- };
955
- default:
956
- return {
957
- bg: "transparent",
958
- text: theme.colors.content.primary,
959
- border: void 0
960
- };
961
- }
962
- };
963
- const getFocusRingColor = () => {
964
- switch (variant) {
965
- case "brand":
966
- return theme.colors.overlay.brand;
967
- case "brandExtra":
968
- return theme.colors.overlay.brandExtra;
969
- case "inverse":
970
- return "rgba(255, 255, 255, 0.3)";
971
- default:
972
- return theme.colors.overlay.mono;
973
- }
974
- };
975
- const getSpinnerColor = () => {
976
- switch (variant) {
977
- case "brand":
978
- return theme.colors.content.brand.primary;
979
- case "primary":
980
- return theme.colors.content.primary;
981
- case "secondary":
982
- return theme.colors.content.secondary;
983
- case "tertiary":
984
- return theme.colors.content.tertiary;
985
- case "brandExtra":
986
- return theme.colors.content.brandExtra.secondary;
987
- case "inverse":
988
- return theme.colors.content.inverse;
989
- default:
990
- return theme.colors.content.brand.primary;
991
- }
992
- };
993
- const colors = getVariantColors(state);
994
- const focusRingColor = getFocusRingColor();
995
- const spinnerColor = getSpinnerColor();
996
- const iconSize = ICON_SIZES[size];
997
- const spinnerSize = SPINNER_SIZES[size];
998
- const fontSize = FONT_SIZES[size];
999
- const borderRadius = BORDER_RADIUS[size];
1000
- const lineHeight = LINE_HEIGHTS[size];
1001
- const showTextLabel = hasVisibleLabel(children);
1002
- const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1003
- const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1004
- const iconOnlyHitArea = theme.sizing.flexButton(size).height;
1005
- const handleMouseEnter = () => {
1006
- if (!isDisabled) {
1007
- isMouseOverRef.current = true;
1008
- setState("hover");
1009
- }
1010
- };
1011
- const handleMouseLeave = () => {
1012
- if (!isDisabled) {
1013
- isMouseOverRef.current = false;
1014
- setState("default");
1015
- }
1016
- };
1017
- const handleMouseDown = () => {
1018
- if (!isDisabled) {
1019
- setState("press");
1020
- }
1021
- };
1022
- const handleMouseUp = () => {
1023
- if (!isDisabled) {
1024
- setState(isMouseOverRef.current ? "hover" : "default");
1025
- }
1026
- };
1027
- const handleFocus = () => {
1028
- if (!isDisabled) {
1029
- setIsFocused(true);
1030
- }
1031
- };
1032
- const handleBlur = () => {
1033
- setIsFocused(false);
1034
- };
1035
- const handleClick = (event) => {
1036
- if (isDisabled) return;
1037
- if (onPress) {
1038
- onPress();
1039
- }
1040
- if (onClick) {
1041
- onClick(event);
1042
- }
1043
- };
1044
- const handleKeyDown = (event) => {
1045
- if (isDisabled) return;
1046
- if (event.key === "Enter" || event.key === " ") {
1047
- event.preventDefault();
1048
- setState("press");
1049
- }
1050
- };
1051
- const handleKeyUp = (event) => {
1052
- if (isDisabled) return;
1053
- if (event.key === "Enter" || event.key === " ") {
1054
- event.preventDefault();
1055
- setState(isMouseOverRef.current ? "hover" : "default");
967
+ default:
968
+ return {
969
+ bg: "transparent",
970
+ text: theme.colors.content.primary,
971
+ border: void 0
972
+ };
973
+ }
974
+ };
975
+ const getFocusRingColor = () => {
976
+ switch (variant) {
977
+ case "brand":
978
+ return theme.colors.overlay.brand;
979
+ case "brandExtra":
980
+ return theme.colors.overlay.brandExtra;
981
+ case "inverse":
982
+ return "rgba(255, 255, 255, 0.3)";
983
+ default:
984
+ return theme.colors.overlay.mono;
985
+ }
986
+ };
987
+ const getSpinnerColor = () => {
988
+ switch (variant) {
989
+ case "brand":
990
+ return theme.colors.content.brand.primary;
991
+ case "primary":
992
+ return theme.colors.content.primary;
993
+ case "secondary":
994
+ return theme.colors.content.secondary;
995
+ case "tertiary":
996
+ return theme.colors.content.tertiary;
997
+ case "brandExtra":
998
+ return theme.colors.content.brandExtra.secondary;
999
+ case "inverse":
1000
+ return theme.colors.content.inverse;
1001
+ default:
1002
+ return theme.colors.content.brand.primary;
1003
+ }
1004
+ };
1005
+ const colors = getVariantColors(state);
1006
+ const focusRingColor = getFocusRingColor();
1007
+ const spinnerColor = getSpinnerColor();
1008
+ const iconSize = ICON_SIZES[size];
1009
+ const spinnerSize = SPINNER_SIZES[size];
1010
+ const fontSize = FONT_SIZES[size];
1011
+ const borderRadius = BORDER_RADIUS[size];
1012
+ const lineHeight = LINE_HEIGHTS[size];
1013
+ const showTextLabel = hasVisibleLabel(children);
1014
+ const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1015
+ const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1016
+ const iconOnlyHitArea = getFlexButtonBoxSize(size);
1017
+ const handleMouseEnter = () => {
1018
+ if (!isDisabled) {
1019
+ isMouseOverRef.current = true;
1020
+ setState("hover");
1021
+ }
1022
+ };
1023
+ const handleMouseLeave = () => {
1024
+ if (!isDisabled) {
1025
+ isMouseOverRef.current = false;
1026
+ setState("default");
1027
+ }
1028
+ };
1029
+ const handleMouseDown = () => {
1030
+ if (!isDisabled) {
1031
+ setState("press");
1032
+ }
1033
+ };
1034
+ const handleMouseUp = () => {
1035
+ if (!isDisabled) {
1036
+ setState(isMouseOverRef.current ? "hover" : "default");
1037
+ }
1038
+ };
1039
+ const handleFocus = () => {
1040
+ if (!isDisabled) {
1041
+ setIsFocused(true);
1042
+ }
1043
+ };
1044
+ const handleBlur = () => {
1045
+ setIsFocused(false);
1046
+ };
1047
+ const handleClick = (event) => {
1048
+ if (isDisabled) return;
1056
1049
  if (onPress) {
1057
1050
  onPress();
1058
1051
  }
1059
- }
1060
- };
1061
- const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1062
- const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1063
- const boxShadows = [];
1064
- if (borderShadow) boxShadows.push(borderShadow);
1065
- if (focusShadow) boxShadows.push(focusShadow);
1066
- const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1067
- const buttonStyle = {
1068
- display: "inline-flex",
1069
- alignItems: "center",
1070
- justifyContent: "center",
1071
- gap: isIconOnly ? 0 : "2px",
1072
- boxSizing: "border-box",
1073
- padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1074
- backgroundColor: loading ? "transparent" : colors.bg,
1075
- color: colors.text,
1076
- border: "none",
1077
- borderWidth: "0px",
1078
- borderRadius: `${borderRadius}px`,
1079
- cursor: isDisabled ? "not-allowed" : "pointer",
1080
- fontSize: `${fontSize}px`,
1081
- fontWeight: 500,
1082
- lineHeight: isIconOnly ? 0 : lineHeight,
1083
- fontFamily: "inherit",
1084
- transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1085
- outline: "none",
1086
- boxShadow: combinedBoxShadow,
1087
- opacity: isDisabled && !loading ? 0.6 : 1,
1088
- ...isIconOnly && {
1089
- width: iconOnlyHitArea,
1090
- height: iconOnlyHitArea,
1091
- minWidth: iconOnlyHitArea,
1092
- minHeight: iconOnlyHitArea,
1093
- flexShrink: 0
1094
- }
1095
- };
1096
- const contentStyle = {
1097
- display: "flex",
1098
- alignItems: "center",
1099
- justifyContent: "center",
1100
- gap: isIconOnly ? 0 : "2px",
1101
- ...isIconOnly && {
1102
- width: "100%",
1103
- height: "100%",
1104
- lineHeight: 0
1105
- }
1106
- };
1107
- const spinnerStyle = {
1108
- display: "flex",
1109
- alignItems: "center",
1110
- justifyContent: "center",
1111
- backgroundColor: "transparent",
1112
- height: lineHeight
1113
- };
1114
- const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1115
- return /* @__PURE__ */ jsx7(
1116
- "button",
1117
- {
1118
- ...buttonProps,
1119
- type,
1120
- className,
1121
- disabled: isDisabled,
1122
- onClick: handleClick,
1123
- onMouseEnter: handleMouseEnter,
1124
- onMouseLeave: handleMouseLeave,
1125
- onMouseDown: handleMouseDown,
1126
- onMouseUp: handleMouseUp,
1127
- onKeyDown: handleKeyDown,
1128
- onKeyUp: handleKeyUp,
1129
- onFocus: handleFocus,
1130
- onBlur: handleBlur,
1131
- "aria-label": computedAriaLabel,
1132
- "aria-busy": loading || void 0,
1133
- "aria-disabled": isDisabled || void 0,
1134
- "aria-describedby": ariaDescribedBy,
1135
- "aria-expanded": ariaExpanded,
1136
- "aria-haspopup": ariaHasPopup,
1137
- "aria-pressed": ariaPressed,
1138
- "aria-controls": ariaControls,
1139
- tabIndex,
1140
- style: buttonStyle,
1141
- "data-testid": testID || "flex-button",
1142
- 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: [
1143
- iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1144
- showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
1145
- hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
1146
- iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1147
- ] }) })
1148
- }
1149
- );
1150
- };
1052
+ if (onClick) {
1053
+ onClick(event);
1054
+ }
1055
+ };
1056
+ const handleKeyDown = (event) => {
1057
+ if (isDisabled) return;
1058
+ if (event.key === "Enter" || event.key === " ") {
1059
+ event.preventDefault();
1060
+ setState("press");
1061
+ }
1062
+ };
1063
+ const handleKeyUp = (event) => {
1064
+ if (isDisabled) return;
1065
+ if (event.key === "Enter" || event.key === " ") {
1066
+ event.preventDefault();
1067
+ setState(isMouseOverRef.current ? "hover" : "default");
1068
+ if (onPress) {
1069
+ onPress();
1070
+ }
1071
+ }
1072
+ };
1073
+ const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1074
+ const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1075
+ const boxShadows = [];
1076
+ if (borderShadow) boxShadows.push(borderShadow);
1077
+ if (focusShadow) boxShadows.push(focusShadow);
1078
+ const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1079
+ const buttonStyle = {
1080
+ display: "inline-flex",
1081
+ alignItems: "center",
1082
+ justifyContent: "center",
1083
+ gap: isIconOnly ? 0 : "2px",
1084
+ boxSizing: "border-box",
1085
+ padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1086
+ backgroundColor: loading ? "transparent" : colors.bg,
1087
+ color: colors.text,
1088
+ border: "none",
1089
+ borderWidth: "0px",
1090
+ borderRadius: `${borderRadius}px`,
1091
+ cursor: isDisabled ? "not-allowed" : "pointer",
1092
+ fontSize: `${fontSize}px`,
1093
+ fontWeight: 500,
1094
+ lineHeight: isIconOnly ? 0 : lineHeight,
1095
+ fontFamily: "inherit",
1096
+ transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1097
+ outline: "none",
1098
+ boxShadow: combinedBoxShadow,
1099
+ opacity: isDisabled && !loading ? 0.6 : 1,
1100
+ ...isIconOnly && {
1101
+ width: iconOnlyHitArea,
1102
+ height: iconOnlyHitArea,
1103
+ minWidth: iconOnlyHitArea,
1104
+ minHeight: iconOnlyHitArea,
1105
+ flexShrink: 0
1106
+ }
1107
+ };
1108
+ const contentStyle = {
1109
+ display: "flex",
1110
+ alignItems: "center",
1111
+ justifyContent: "center",
1112
+ gap: isIconOnly ? 0 : "2px",
1113
+ ...isIconOnly && {
1114
+ width: "100%",
1115
+ height: "100%",
1116
+ lineHeight: 0
1117
+ }
1118
+ };
1119
+ const spinnerStyle = {
1120
+ display: "flex",
1121
+ alignItems: "center",
1122
+ justifyContent: "center",
1123
+ backgroundColor: "transparent",
1124
+ height: lineHeight
1125
+ };
1126
+ const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1127
+ return /* @__PURE__ */ jsx7(
1128
+ "button",
1129
+ {
1130
+ ...buttonProps,
1131
+ ref,
1132
+ type,
1133
+ className,
1134
+ disabled: isDisabled,
1135
+ onClick: handleClick,
1136
+ onMouseEnter: handleMouseEnter,
1137
+ onMouseLeave: handleMouseLeave,
1138
+ onMouseDown: handleMouseDown,
1139
+ onMouseUp: handleMouseUp,
1140
+ onKeyDown: handleKeyDown,
1141
+ onKeyUp: handleKeyUp,
1142
+ onFocus: handleFocus,
1143
+ onBlur: handleBlur,
1144
+ "aria-label": computedAriaLabel,
1145
+ "aria-busy": loading || void 0,
1146
+ "aria-disabled": isDisabled || void 0,
1147
+ "aria-describedby": ariaDescribedBy,
1148
+ "aria-expanded": ariaExpanded,
1149
+ "aria-haspopup": ariaHasPopup,
1150
+ "aria-pressed": ariaPressed,
1151
+ "aria-controls": ariaControls,
1152
+ tabIndex,
1153
+ style: buttonStyle,
1154
+ "data-testid": testID || "flex-button",
1155
+ 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: [
1156
+ iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1157
+ showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
1158
+ hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
1159
+ iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1160
+ ] }) })
1161
+ }
1162
+ );
1163
+ }
1164
+ );
1151
1165
  FlexButton.displayName = "FlexButton";
1152
1166
 
1153
1167
  // src/AppButton.tsx
1154
1168
  import React5, { useState as useState4 } from "react";
1155
- import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
1169
+ import { useResolvedTheme as useResolvedTheme4 } from "@xsolla/xui-core";
1156
1170
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1157
1171
  var cloneIconWithDefaults3 = (icon, defaultSize, defaultColor) => {
1158
1172
  if (!React5.isValidElement(icon)) return icon;
@@ -1189,7 +1203,7 @@ var AppButton = ({
1189
1203
  themeMode,
1190
1204
  themeProductContext
1191
1205
  }) => {
1192
- const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
1206
+ const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
1193
1207
  const [isKeyboardPressed, setIsKeyboardPressed] = useState4(false);
1194
1208
  const isDisabled = disabled || loading;
1195
1209
  const sizeStyles = theme.sizing.button(size);
@@ -1375,7 +1389,7 @@ AppButton.displayName = "AppButton";
1375
1389
 
1376
1390
  // src/ButtonGroup.tsx
1377
1391
  import React6 from "react";
1378
- import { useResolvedTheme as useResolvedTheme4 } from "@xsolla/xui-core";
1392
+ import { useResolvedTheme as useResolvedTheme5 } from "@xsolla/xui-core";
1379
1393
  import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1380
1394
  var ButtonGroup = ({
1381
1395
  orientation = "horizontal",
@@ -1392,7 +1406,7 @@ var ButtonGroup = ({
1392
1406
  themeMode,
1393
1407
  themeProductContext
1394
1408
  }) => {
1395
- const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
1409
+ const { theme } = useResolvedTheme5({ themeMode, themeProductContext });
1396
1410
  const flattenChildren = (children2) => {
1397
1411
  const result = [];
1398
1412
  React6.Children.forEach(children2, (child) => {
@@ -1507,6 +1521,7 @@ export {
1507
1521
  Button,
1508
1522
  ButtonGroup,
1509
1523
  FlexButton,
1510
- IconButton
1524
+ IconButton,
1525
+ getFlexButtonBoxSize
1511
1526
  };
1512
1527
  //# sourceMappingURL=index.mjs.map