@xsolla/xui-button 0.192.0 → 0.194.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/web/index.mjs CHANGED
@@ -832,11 +832,26 @@ IconButton.displayName = "IconButton";
832
832
 
833
833
  // src/FlexButton.tsx
834
834
  import React5, {
835
+ forwardRef,
835
836
  useRef,
836
837
  useState as useState3
837
838
  } from "react";
838
- import { useDesignSystem } from "@xsolla/xui-core";
839
+ import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
839
840
  import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
841
+ var ICON_SIZES = {
842
+ xs: 12,
843
+ sm: 14,
844
+ md: 16,
845
+ lg: 18,
846
+ xl: 20
847
+ };
848
+ var SPINNER_SIZES = {
849
+ xs: 12,
850
+ sm: 14,
851
+ md: 16,
852
+ lg: 18,
853
+ xl: 20
854
+ };
840
855
  var FLEX_BUTTON_PADDING = 4;
841
856
  var hasVisibleLabel = (node) => {
842
857
  if (node == null || node === false || node === true) return false;
@@ -855,20 +870,14 @@ var hasRenderableContent = (node) => {
855
870
  if (Array.isArray(node)) return node.some(hasRenderableContent);
856
871
  return true;
857
872
  };
858
- var ICON_SIZES = {
859
- xs: 12,
860
- sm: 14,
861
- md: 16,
862
- lg: 18,
863
- xl: 20
864
- };
865
- var SPINNER_SIZES = {
866
- xs: 12,
867
- sm: 14,
868
- md: 16,
869
- lg: 18,
870
- xl: 20
873
+ var BOX_SIZES = {
874
+ xs: 20,
875
+ sm: 22,
876
+ md: 28,
877
+ lg: 32,
878
+ xl: 36
871
879
  };
880
+ var getFlexButtonBoxSize = (size = "md") => BOX_SIZES[size];
872
881
  var LINE_HEIGHTS = {
873
882
  xs: "14px",
874
883
  sm: "16px",
@@ -890,325 +899,330 @@ var BORDER_RADIUS = {
890
899
  sm: 2,
891
900
  xs: 2
892
901
  };
893
- var FlexButton = ({
894
- children,
895
- variant = "brand",
896
- size = "md",
897
- background = false,
898
- hoverBackground = true,
899
- noPadding = false,
900
- disabled = false,
901
- loading = false,
902
- iconLeft,
903
- iconRight,
904
- onPress,
905
- onClick,
906
- className,
907
- type = "button",
908
- "aria-label": ariaLabel,
909
- "aria-describedby": ariaDescribedBy,
910
- "aria-expanded": ariaExpanded,
911
- "aria-haspopup": ariaHasPopup,
912
- "aria-pressed": ariaPressed,
913
- "aria-controls": ariaControls,
914
- testID,
915
- tabIndex = 0,
916
- ...buttonProps
917
- }) => {
918
- const { theme } = useDesignSystem();
919
- const [state, setState] = useState3("default");
920
- const [isFocused, setIsFocused] = useState3(false);
921
- const isMouseOverRef = useRef(false);
922
- const isDisabled = disabled || loading;
923
- const getVariantColors = (currentState) => {
924
- if (isDisabled) {
925
- return {
926
- bg: background ? theme.colors.overlay.mono : "transparent",
927
- text: theme.colors.control.text.disable,
928
- border: void 0
929
- };
930
- }
931
- const effectiveBackground = loading ? false : background;
932
- switch (variant) {
933
- case "brand":
934
- if (effectiveBackground) {
935
- return {
936
- bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
937
- text: theme.colors.content.on.brand,
938
- border: void 0
939
- };
940
- }
902
+ var FlexButton = forwardRef(
903
+ ({
904
+ children,
905
+ variant = "brand",
906
+ size = "md",
907
+ background = false,
908
+ hoverBackground = true,
909
+ noPadding = false,
910
+ disabled = false,
911
+ loading = false,
912
+ iconLeft,
913
+ iconRight,
914
+ onPress,
915
+ onClick,
916
+ className,
917
+ type = "button",
918
+ "aria-label": ariaLabel,
919
+ "aria-describedby": ariaDescribedBy,
920
+ "aria-expanded": ariaExpanded,
921
+ "aria-haspopup": ariaHasPopup,
922
+ "aria-pressed": ariaPressed,
923
+ "aria-controls": ariaControls,
924
+ testID,
925
+ tabIndex = 0,
926
+ themeMode,
927
+ themeProductContext,
928
+ ...buttonProps
929
+ }, ref) => {
930
+ const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
931
+ const [state, setState] = useState3("default");
932
+ const [isFocused, setIsFocused] = useState3(false);
933
+ const isMouseOverRef = useRef(false);
934
+ const isDisabled = disabled || loading;
935
+ const getVariantColors = (currentState) => {
936
+ if (isDisabled) {
941
937
  return {
942
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
943
- text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
938
+ bg: background ? theme.colors.overlay.mono : "transparent",
939
+ text: theme.colors.control.text.disable,
944
940
  border: void 0
945
941
  };
946
- case "primary":
947
- if (effectiveBackground) {
942
+ }
943
+ const effectiveBackground = loading ? false : background;
944
+ switch (variant) {
945
+ case "brand":
946
+ if (effectiveBackground) {
947
+ return {
948
+ bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
949
+ text: theme.colors.content.on.brand,
950
+ border: void 0
951
+ };
952
+ }
953
+ return {
954
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
955
+ text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
956
+ border: void 0
957
+ };
958
+ case "primary":
959
+ if (effectiveBackground) {
960
+ return {
961
+ bg: theme.colors.background.primary,
962
+ text: theme.colors.content.primary,
963
+ border: currentState === "press" ? theme.colors.border.primary : void 0
964
+ };
965
+ }
948
966
  return {
949
- bg: theme.colors.background.primary,
967
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
950
968
  text: theme.colors.content.primary,
951
969
  border: currentState === "press" ? theme.colors.border.primary : void 0
952
970
  };
953
- }
954
- return {
955
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
956
- text: theme.colors.content.primary,
957
- border: currentState === "press" ? theme.colors.border.primary : void 0
958
- };
959
- case "secondary":
960
- if (effectiveBackground) {
971
+ case "secondary":
972
+ if (effectiveBackground) {
973
+ return {
974
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
975
+ text: theme.colors.content.secondary,
976
+ border: void 0
977
+ };
978
+ }
961
979
  return {
962
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
963
- text: theme.colors.content.secondary,
980
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
981
+ text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
964
982
  border: void 0
965
983
  };
966
- }
967
- return {
968
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
969
- text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
970
- border: void 0
971
- };
972
- case "tertiary":
973
- if (effectiveBackground) {
984
+ case "tertiary":
985
+ if (effectiveBackground) {
986
+ return {
987
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
988
+ text: theme.colors.content.tertiary,
989
+ border: void 0
990
+ };
991
+ }
974
992
  return {
975
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
976
- text: theme.colors.content.tertiary,
993
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
994
+ text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
977
995
  border: void 0
978
996
  };
979
- }
980
- return {
981
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
982
- text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
983
- border: void 0
984
- };
985
- case "brandExtra":
986
- if (effectiveBackground) {
997
+ case "brandExtra":
998
+ if (effectiveBackground) {
999
+ return {
1000
+ bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
1001
+ text: theme.colors.content.on.brandExtra,
1002
+ border: void 0
1003
+ };
1004
+ }
987
1005
  return {
988
- bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
989
- text: theme.colors.content.on.brandExtra,
1006
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
1007
+ text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
990
1008
  border: void 0
991
1009
  };
992
- }
993
- return {
994
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
995
- text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
996
- border: void 0
997
- };
998
- case "inverse":
999
- if (effectiveBackground) {
1010
+ case "inverse":
1011
+ if (effectiveBackground) {
1012
+ return {
1013
+ bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
1014
+ text: theme.colors.content.inverse,
1015
+ border: void 0
1016
+ };
1017
+ }
1000
1018
  return {
1001
- bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
1019
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1002
1020
  text: theme.colors.content.inverse,
1003
1021
  border: void 0
1004
1022
  };
1005
- }
1006
- return {
1007
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1008
- text: theme.colors.content.inverse,
1009
- border: void 0
1010
- };
1011
- default:
1012
- return {
1013
- bg: "transparent",
1014
- text: theme.colors.content.primary,
1015
- border: void 0
1016
- };
1017
- }
1018
- };
1019
- const getFocusRingColor = () => {
1020
- switch (variant) {
1021
- case "brand":
1022
- return theme.colors.overlay.brand;
1023
- case "brandExtra":
1024
- return theme.colors.overlay.brandExtra;
1025
- case "inverse":
1026
- return "rgba(255, 255, 255, 0.3)";
1027
- default:
1028
- return theme.colors.overlay.mono;
1029
- }
1030
- };
1031
- const getSpinnerColor = () => {
1032
- switch (variant) {
1033
- case "brand":
1034
- return theme.colors.content.brand.primary;
1035
- case "primary":
1036
- return theme.colors.content.primary;
1037
- case "secondary":
1038
- return theme.colors.content.secondary;
1039
- case "tertiary":
1040
- return theme.colors.content.tertiary;
1041
- case "brandExtra":
1042
- return theme.colors.content.brandExtra.secondary;
1043
- case "inverse":
1044
- return theme.colors.content.inverse;
1045
- default:
1046
- return theme.colors.content.brand.primary;
1047
- }
1048
- };
1049
- const colors = getVariantColors(state);
1050
- const focusRingColor = getFocusRingColor();
1051
- const spinnerColor = getSpinnerColor();
1052
- const iconSize = ICON_SIZES[size];
1053
- const spinnerSize = SPINNER_SIZES[size];
1054
- const fontSize = FONT_SIZES[size];
1055
- const borderRadius = BORDER_RADIUS[size];
1056
- const lineHeight = LINE_HEIGHTS[size];
1057
- const showTextLabel = hasVisibleLabel(children);
1058
- const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1059
- const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1060
- const iconOnlyHitArea = theme.sizing.flexButton(size).height;
1061
- const handleMouseEnter = () => {
1062
- if (!isDisabled) {
1063
- isMouseOverRef.current = true;
1064
- setState("hover");
1065
- }
1066
- };
1067
- const handleMouseLeave = () => {
1068
- if (!isDisabled) {
1069
- isMouseOverRef.current = false;
1070
- setState("default");
1071
- }
1072
- };
1073
- const handleMouseDown = () => {
1074
- if (!isDisabled) {
1075
- setState("press");
1076
- }
1077
- };
1078
- const handleMouseUp = () => {
1079
- if (!isDisabled) {
1080
- setState(isMouseOverRef.current ? "hover" : "default");
1081
- }
1082
- };
1083
- const handleFocus = () => {
1084
- if (!isDisabled) {
1085
- setIsFocused(true);
1086
- }
1087
- };
1088
- const handleBlur = () => {
1089
- setIsFocused(false);
1090
- };
1091
- const handleClick = (event) => {
1092
- if (isDisabled) return;
1093
- if (onPress) {
1094
- onPress();
1095
- }
1096
- if (onClick) {
1097
- onClick(event);
1098
- }
1099
- };
1100
- const handleKeyDown = (event) => {
1101
- if (isDisabled) return;
1102
- if (event.key === "Enter" || event.key === " ") {
1103
- event.preventDefault();
1104
- setState("press");
1105
- }
1106
- };
1107
- const handleKeyUp = (event) => {
1108
- if (isDisabled) return;
1109
- if (event.key === "Enter" || event.key === " ") {
1110
- event.preventDefault();
1111
- setState(isMouseOverRef.current ? "hover" : "default");
1023
+ default:
1024
+ return {
1025
+ bg: "transparent",
1026
+ text: theme.colors.content.primary,
1027
+ border: void 0
1028
+ };
1029
+ }
1030
+ };
1031
+ const getFocusRingColor = () => {
1032
+ switch (variant) {
1033
+ case "brand":
1034
+ return theme.colors.overlay.brand;
1035
+ case "brandExtra":
1036
+ return theme.colors.overlay.brandExtra;
1037
+ case "inverse":
1038
+ return "rgba(255, 255, 255, 0.3)";
1039
+ default:
1040
+ return theme.colors.overlay.mono;
1041
+ }
1042
+ };
1043
+ const getSpinnerColor = () => {
1044
+ switch (variant) {
1045
+ case "brand":
1046
+ return theme.colors.content.brand.primary;
1047
+ case "primary":
1048
+ return theme.colors.content.primary;
1049
+ case "secondary":
1050
+ return theme.colors.content.secondary;
1051
+ case "tertiary":
1052
+ return theme.colors.content.tertiary;
1053
+ case "brandExtra":
1054
+ return theme.colors.content.brandExtra.secondary;
1055
+ case "inverse":
1056
+ return theme.colors.content.inverse;
1057
+ default:
1058
+ return theme.colors.content.brand.primary;
1059
+ }
1060
+ };
1061
+ const colors = getVariantColors(state);
1062
+ const focusRingColor = getFocusRingColor();
1063
+ const spinnerColor = getSpinnerColor();
1064
+ const iconSize = ICON_SIZES[size];
1065
+ const spinnerSize = SPINNER_SIZES[size];
1066
+ const fontSize = FONT_SIZES[size];
1067
+ const borderRadius = BORDER_RADIUS[size];
1068
+ const lineHeight = LINE_HEIGHTS[size];
1069
+ const showTextLabel = hasVisibleLabel(children);
1070
+ const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1071
+ const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1072
+ const iconOnlyHitArea = getFlexButtonBoxSize(size);
1073
+ const handleMouseEnter = () => {
1074
+ if (!isDisabled) {
1075
+ isMouseOverRef.current = true;
1076
+ setState("hover");
1077
+ }
1078
+ };
1079
+ const handleMouseLeave = () => {
1080
+ if (!isDisabled) {
1081
+ isMouseOverRef.current = false;
1082
+ setState("default");
1083
+ }
1084
+ };
1085
+ const handleMouseDown = () => {
1086
+ if (!isDisabled) {
1087
+ setState("press");
1088
+ }
1089
+ };
1090
+ const handleMouseUp = () => {
1091
+ if (!isDisabled) {
1092
+ setState(isMouseOverRef.current ? "hover" : "default");
1093
+ }
1094
+ };
1095
+ const handleFocus = () => {
1096
+ if (!isDisabled) {
1097
+ setIsFocused(true);
1098
+ }
1099
+ };
1100
+ const handleBlur = () => {
1101
+ setIsFocused(false);
1102
+ };
1103
+ const handleClick = (event) => {
1104
+ if (isDisabled) return;
1112
1105
  if (onPress) {
1113
1106
  onPress();
1114
1107
  }
1115
- }
1116
- };
1117
- const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1118
- const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1119
- const boxShadows = [];
1120
- if (borderShadow) boxShadows.push(borderShadow);
1121
- if (focusShadow) boxShadows.push(focusShadow);
1122
- const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1123
- const buttonStyle = {
1124
- display: "inline-flex",
1125
- alignItems: "center",
1126
- justifyContent: "center",
1127
- gap: isIconOnly ? 0 : "2px",
1128
- boxSizing: "border-box",
1129
- padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1130
- backgroundColor: loading ? "transparent" : colors.bg,
1131
- color: colors.text,
1132
- border: "none",
1133
- borderWidth: "0px",
1134
- borderRadius: `${borderRadius}px`,
1135
- cursor: isDisabled ? "not-allowed" : "pointer",
1136
- fontSize: `${fontSize}px`,
1137
- fontWeight: 500,
1138
- lineHeight: isIconOnly ? 0 : lineHeight,
1139
- fontFamily: "inherit",
1140
- transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1141
- outline: "none",
1142
- boxShadow: combinedBoxShadow,
1143
- opacity: isDisabled && !loading ? 0.6 : 1,
1144
- ...isIconOnly && {
1145
- width: iconOnlyHitArea,
1146
- height: iconOnlyHitArea,
1147
- minWidth: iconOnlyHitArea,
1148
- minHeight: iconOnlyHitArea,
1149
- flexShrink: 0
1150
- }
1151
- };
1152
- const contentStyle = {
1153
- display: "flex",
1154
- alignItems: "center",
1155
- justifyContent: "center",
1156
- gap: isIconOnly ? 0 : "2px",
1157
- ...isIconOnly && {
1158
- width: "100%",
1159
- height: "100%",
1160
- lineHeight: 0
1161
- }
1162
- };
1163
- const spinnerStyle = {
1164
- display: "flex",
1165
- alignItems: "center",
1166
- justifyContent: "center",
1167
- backgroundColor: "transparent",
1168
- height: lineHeight
1169
- };
1170
- const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1171
- return /* @__PURE__ */ jsx7(
1172
- "button",
1173
- {
1174
- ...buttonProps,
1175
- type,
1176
- className,
1177
- disabled: isDisabled,
1178
- onClick: handleClick,
1179
- onMouseEnter: handleMouseEnter,
1180
- onMouseLeave: handleMouseLeave,
1181
- onMouseDown: handleMouseDown,
1182
- onMouseUp: handleMouseUp,
1183
- onKeyDown: handleKeyDown,
1184
- onKeyUp: handleKeyUp,
1185
- onFocus: handleFocus,
1186
- onBlur: handleBlur,
1187
- "aria-label": computedAriaLabel,
1188
- "aria-busy": loading || void 0,
1189
- "aria-disabled": isDisabled || void 0,
1190
- "aria-describedby": ariaDescribedBy,
1191
- "aria-expanded": ariaExpanded,
1192
- "aria-haspopup": ariaHasPopup,
1193
- "aria-pressed": ariaPressed,
1194
- "aria-controls": ariaControls,
1195
- tabIndex,
1196
- style: buttonStyle,
1197
- "data-testid": testID || "flex-button",
1198
- 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: [
1199
- iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1200
- showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
1201
- hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
1202
- iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1203
- ] }) })
1204
- }
1205
- );
1206
- };
1108
+ if (onClick) {
1109
+ onClick(event);
1110
+ }
1111
+ };
1112
+ const handleKeyDown = (event) => {
1113
+ if (isDisabled) return;
1114
+ if (event.key === "Enter" || event.key === " ") {
1115
+ event.preventDefault();
1116
+ setState("press");
1117
+ }
1118
+ };
1119
+ const handleKeyUp = (event) => {
1120
+ if (isDisabled) return;
1121
+ if (event.key === "Enter" || event.key === " ") {
1122
+ event.preventDefault();
1123
+ setState(isMouseOverRef.current ? "hover" : "default");
1124
+ if (onPress) {
1125
+ onPress();
1126
+ }
1127
+ }
1128
+ };
1129
+ const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1130
+ const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1131
+ const boxShadows = [];
1132
+ if (borderShadow) boxShadows.push(borderShadow);
1133
+ if (focusShadow) boxShadows.push(focusShadow);
1134
+ const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1135
+ const buttonStyle = {
1136
+ display: "inline-flex",
1137
+ alignItems: "center",
1138
+ justifyContent: "center",
1139
+ gap: isIconOnly ? 0 : "2px",
1140
+ boxSizing: "border-box",
1141
+ padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1142
+ backgroundColor: loading ? "transparent" : colors.bg,
1143
+ color: colors.text,
1144
+ border: "none",
1145
+ borderWidth: "0px",
1146
+ borderRadius: `${borderRadius}px`,
1147
+ cursor: isDisabled ? "not-allowed" : "pointer",
1148
+ fontSize: `${fontSize}px`,
1149
+ fontWeight: 500,
1150
+ lineHeight: isIconOnly ? 0 : lineHeight,
1151
+ fontFamily: "inherit",
1152
+ transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1153
+ outline: "none",
1154
+ boxShadow: combinedBoxShadow,
1155
+ opacity: isDisabled && !loading ? 0.6 : 1,
1156
+ ...isIconOnly && {
1157
+ width: iconOnlyHitArea,
1158
+ height: iconOnlyHitArea,
1159
+ minWidth: iconOnlyHitArea,
1160
+ minHeight: iconOnlyHitArea,
1161
+ flexShrink: 0
1162
+ }
1163
+ };
1164
+ const contentStyle = {
1165
+ display: "flex",
1166
+ alignItems: "center",
1167
+ justifyContent: "center",
1168
+ gap: isIconOnly ? 0 : "2px",
1169
+ ...isIconOnly && {
1170
+ width: "100%",
1171
+ height: "100%",
1172
+ lineHeight: 0
1173
+ }
1174
+ };
1175
+ const spinnerStyle = {
1176
+ display: "flex",
1177
+ alignItems: "center",
1178
+ justifyContent: "center",
1179
+ backgroundColor: "transparent",
1180
+ height: lineHeight
1181
+ };
1182
+ const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1183
+ return /* @__PURE__ */ jsx7(
1184
+ "button",
1185
+ {
1186
+ ...buttonProps,
1187
+ ref,
1188
+ type,
1189
+ className,
1190
+ disabled: isDisabled,
1191
+ onClick: handleClick,
1192
+ onMouseEnter: handleMouseEnter,
1193
+ onMouseLeave: handleMouseLeave,
1194
+ onMouseDown: handleMouseDown,
1195
+ onMouseUp: handleMouseUp,
1196
+ onKeyDown: handleKeyDown,
1197
+ onKeyUp: handleKeyUp,
1198
+ onFocus: handleFocus,
1199
+ onBlur: handleBlur,
1200
+ "aria-label": computedAriaLabel,
1201
+ "aria-busy": loading || void 0,
1202
+ "aria-disabled": isDisabled || void 0,
1203
+ "aria-describedby": ariaDescribedBy,
1204
+ "aria-expanded": ariaExpanded,
1205
+ "aria-haspopup": ariaHasPopup,
1206
+ "aria-pressed": ariaPressed,
1207
+ "aria-controls": ariaControls,
1208
+ tabIndex,
1209
+ style: buttonStyle,
1210
+ "data-testid": testID || "flex-button",
1211
+ 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: [
1212
+ iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1213
+ showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
1214
+ hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
1215
+ iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
1216
+ ] }) })
1217
+ }
1218
+ );
1219
+ }
1220
+ );
1207
1221
  FlexButton.displayName = "FlexButton";
1208
1222
 
1209
1223
  // src/AppButton.tsx
1210
1224
  import React6, { useState as useState4 } from "react";
1211
- import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
1225
+ import { useResolvedTheme as useResolvedTheme4 } from "@xsolla/xui-core";
1212
1226
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1213
1227
  var cloneIconWithDefaults3 = (icon, defaultSize, defaultColor) => {
1214
1228
  if (!React6.isValidElement(icon)) return icon;
@@ -1245,7 +1259,7 @@ var AppButton = ({
1245
1259
  themeMode,
1246
1260
  themeProductContext
1247
1261
  }) => {
1248
- const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
1262
+ const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
1249
1263
  const [isKeyboardPressed, setIsKeyboardPressed] = useState4(false);
1250
1264
  const isDisabled = disabled || loading;
1251
1265
  const sizeStyles = theme.sizing.button(size);
@@ -1431,7 +1445,7 @@ AppButton.displayName = "AppButton";
1431
1445
 
1432
1446
  // src/ButtonGroup.tsx
1433
1447
  import React7 from "react";
1434
- import { useResolvedTheme as useResolvedTheme4 } from "@xsolla/xui-core";
1448
+ import { useResolvedTheme as useResolvedTheme5 } from "@xsolla/xui-core";
1435
1449
  import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1436
1450
  var ButtonGroup = ({
1437
1451
  orientation = "horizontal",
@@ -1448,7 +1462,7 @@ var ButtonGroup = ({
1448
1462
  themeMode,
1449
1463
  themeProductContext
1450
1464
  }) => {
1451
- const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
1465
+ const { theme } = useResolvedTheme5({ themeMode, themeProductContext });
1452
1466
  const flattenChildren = (children2) => {
1453
1467
  const result = [];
1454
1468
  React7.Children.forEach(children2, (child) => {
@@ -1563,6 +1577,7 @@ export {
1563
1577
  Button,
1564
1578
  ButtonGroup,
1565
1579
  FlexButton,
1566
- IconButton
1580
+ IconButton,
1581
+ getFlexButtonBoxSize
1567
1582
  };
1568
1583
  //# sourceMappingURL=index.mjs.map