@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.js CHANGED
@@ -34,7 +34,8 @@ __export(index_exports, {
34
34
  Button: () => Button,
35
35
  ButtonGroup: () => ButtonGroup,
36
36
  FlexButton: () => FlexButton,
37
- IconButton: () => IconButton
37
+ IconButton: () => IconButton,
38
+ getFlexButtonBoxSize: () => getFlexButtonBoxSize
38
39
  });
39
40
  module.exports = __toCommonJS(index_exports);
40
41
 
@@ -874,6 +875,20 @@ IconButton.displayName = "IconButton";
874
875
  var import_react5 = __toESM(require("react"));
875
876
  var import_xui_core3 = require("@xsolla/xui-core");
876
877
  var import_jsx_runtime7 = require("react/jsx-runtime");
878
+ var ICON_SIZES = {
879
+ xs: 12,
880
+ sm: 14,
881
+ md: 16,
882
+ lg: 18,
883
+ xl: 20
884
+ };
885
+ var SPINNER_SIZES = {
886
+ xs: 12,
887
+ sm: 14,
888
+ md: 16,
889
+ lg: 18,
890
+ xl: 20
891
+ };
877
892
  var FLEX_BUTTON_PADDING = 4;
878
893
  var hasVisibleLabel = (node) => {
879
894
  if (node == null || node === false || node === true) return false;
@@ -892,20 +907,14 @@ var hasRenderableContent = (node) => {
892
907
  if (Array.isArray(node)) return node.some(hasRenderableContent);
893
908
  return true;
894
909
  };
895
- var ICON_SIZES = {
896
- xs: 12,
897
- sm: 14,
898
- md: 16,
899
- lg: 18,
900
- xl: 20
901
- };
902
- var SPINNER_SIZES = {
903
- xs: 12,
904
- sm: 14,
905
- md: 16,
906
- lg: 18,
907
- xl: 20
910
+ var BOX_SIZES = {
911
+ xs: 20,
912
+ sm: 22,
913
+ md: 28,
914
+ lg: 32,
915
+ xl: 36
908
916
  };
917
+ var getFlexButtonBoxSize = (size = "md") => BOX_SIZES[size];
909
918
  var LINE_HEIGHTS = {
910
919
  xs: "14px",
911
920
  sm: "16px",
@@ -927,320 +936,325 @@ var BORDER_RADIUS = {
927
936
  sm: 2,
928
937
  xs: 2
929
938
  };
930
- var FlexButton = ({
931
- children,
932
- variant = "brand",
933
- size = "md",
934
- background = false,
935
- hoverBackground = true,
936
- noPadding = false,
937
- disabled = false,
938
- loading = false,
939
- iconLeft,
940
- iconRight,
941
- onPress,
942
- onClick,
943
- className,
944
- type = "button",
945
- "aria-label": ariaLabel,
946
- "aria-describedby": ariaDescribedBy,
947
- "aria-expanded": ariaExpanded,
948
- "aria-haspopup": ariaHasPopup,
949
- "aria-pressed": ariaPressed,
950
- "aria-controls": ariaControls,
951
- testID,
952
- tabIndex = 0,
953
- ...buttonProps
954
- }) => {
955
- const { theme } = (0, import_xui_core3.useDesignSystem)();
956
- const [state, setState] = (0, import_react5.useState)("default");
957
- const [isFocused, setIsFocused] = (0, import_react5.useState)(false);
958
- const isMouseOverRef = (0, import_react5.useRef)(false);
959
- const isDisabled = disabled || loading;
960
- const getVariantColors = (currentState) => {
961
- if (isDisabled) {
962
- return {
963
- bg: background ? theme.colors.overlay.mono : "transparent",
964
- text: theme.colors.control.text.disable,
965
- border: void 0
966
- };
967
- }
968
- const effectiveBackground = loading ? false : background;
969
- switch (variant) {
970
- case "brand":
971
- if (effectiveBackground) {
972
- return {
973
- bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
974
- text: theme.colors.content.on.brand,
975
- border: void 0
976
- };
977
- }
939
+ var FlexButton = (0, import_react5.forwardRef)(
940
+ ({
941
+ children,
942
+ variant = "brand",
943
+ size = "md",
944
+ background = false,
945
+ hoverBackground = true,
946
+ noPadding = false,
947
+ disabled = false,
948
+ loading = false,
949
+ iconLeft,
950
+ iconRight,
951
+ onPress,
952
+ onClick,
953
+ className,
954
+ type = "button",
955
+ "aria-label": ariaLabel,
956
+ "aria-describedby": ariaDescribedBy,
957
+ "aria-expanded": ariaExpanded,
958
+ "aria-haspopup": ariaHasPopup,
959
+ "aria-pressed": ariaPressed,
960
+ "aria-controls": ariaControls,
961
+ testID,
962
+ tabIndex = 0,
963
+ themeMode,
964
+ themeProductContext,
965
+ ...buttonProps
966
+ }, ref) => {
967
+ const { theme } = (0, import_xui_core3.useResolvedTheme)({ themeMode, themeProductContext });
968
+ const [state, setState] = (0, import_react5.useState)("default");
969
+ const [isFocused, setIsFocused] = (0, import_react5.useState)(false);
970
+ const isMouseOverRef = (0, import_react5.useRef)(false);
971
+ const isDisabled = disabled || loading;
972
+ const getVariantColors = (currentState) => {
973
+ if (isDisabled) {
978
974
  return {
979
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
980
- text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
975
+ bg: background ? theme.colors.overlay.mono : "transparent",
976
+ text: theme.colors.control.text.disable,
981
977
  border: void 0
982
978
  };
983
- case "primary":
984
- if (effectiveBackground) {
979
+ }
980
+ const effectiveBackground = loading ? false : background;
981
+ switch (variant) {
982
+ case "brand":
983
+ if (effectiveBackground) {
984
+ return {
985
+ bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
986
+ text: theme.colors.content.on.brand,
987
+ border: void 0
988
+ };
989
+ }
990
+ return {
991
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
992
+ text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
993
+ border: void 0
994
+ };
995
+ case "primary":
996
+ if (effectiveBackground) {
997
+ return {
998
+ bg: theme.colors.background.primary,
999
+ text: theme.colors.content.primary,
1000
+ border: currentState === "press" ? theme.colors.border.primary : void 0
1001
+ };
1002
+ }
985
1003
  return {
986
- bg: theme.colors.background.primary,
1004
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
987
1005
  text: theme.colors.content.primary,
988
1006
  border: currentState === "press" ? theme.colors.border.primary : void 0
989
1007
  };
990
- }
991
- return {
992
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
993
- text: theme.colors.content.primary,
994
- border: currentState === "press" ? theme.colors.border.primary : void 0
995
- };
996
- case "secondary":
997
- if (effectiveBackground) {
1008
+ case "secondary":
1009
+ if (effectiveBackground) {
1010
+ return {
1011
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
1012
+ text: theme.colors.content.secondary,
1013
+ border: void 0
1014
+ };
1015
+ }
998
1016
  return {
999
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
1000
- text: theme.colors.content.secondary,
1017
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1018
+ text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
1001
1019
  border: void 0
1002
1020
  };
1003
- }
1004
- return {
1005
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1006
- text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
1007
- border: void 0
1008
- };
1009
- case "tertiary":
1010
- if (effectiveBackground) {
1021
+ case "tertiary":
1022
+ if (effectiveBackground) {
1023
+ return {
1024
+ bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
1025
+ text: theme.colors.content.tertiary,
1026
+ border: void 0
1027
+ };
1028
+ }
1011
1029
  return {
1012
- bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
1013
- text: theme.colors.content.tertiary,
1030
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1031
+ text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
1014
1032
  border: void 0
1015
1033
  };
1016
- }
1017
- return {
1018
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1019
- text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
1020
- border: void 0
1021
- };
1022
- case "brandExtra":
1023
- if (effectiveBackground) {
1034
+ case "brandExtra":
1035
+ if (effectiveBackground) {
1036
+ return {
1037
+ bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
1038
+ text: theme.colors.content.on.brandExtra,
1039
+ border: void 0
1040
+ };
1041
+ }
1024
1042
  return {
1025
- bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
1026
- text: theme.colors.content.on.brandExtra,
1043
+ bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
1044
+ text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
1027
1045
  border: void 0
1028
1046
  };
1029
- }
1030
- return {
1031
- bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
1032
- text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
1033
- border: void 0
1034
- };
1035
- case "inverse":
1036
- if (effectiveBackground) {
1047
+ case "inverse":
1048
+ if (effectiveBackground) {
1049
+ return {
1050
+ bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
1051
+ text: theme.colors.content.inverse,
1052
+ border: void 0
1053
+ };
1054
+ }
1037
1055
  return {
1038
- bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
1056
+ bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1039
1057
  text: theme.colors.content.inverse,
1040
1058
  border: void 0
1041
1059
  };
1042
- }
1043
- return {
1044
- bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
1045
- text: theme.colors.content.inverse,
1046
- border: void 0
1047
- };
1048
- default:
1049
- return {
1050
- bg: "transparent",
1051
- text: theme.colors.content.primary,
1052
- border: void 0
1053
- };
1054
- }
1055
- };
1056
- const getFocusRingColor = () => {
1057
- switch (variant) {
1058
- case "brand":
1059
- return theme.colors.overlay.brand;
1060
- case "brandExtra":
1061
- return theme.colors.overlay.brandExtra;
1062
- case "inverse":
1063
- return "rgba(255, 255, 255, 0.3)";
1064
- default:
1065
- return theme.colors.overlay.mono;
1066
- }
1067
- };
1068
- const getSpinnerColor = () => {
1069
- switch (variant) {
1070
- case "brand":
1071
- return theme.colors.content.brand.primary;
1072
- case "primary":
1073
- return theme.colors.content.primary;
1074
- case "secondary":
1075
- return theme.colors.content.secondary;
1076
- case "tertiary":
1077
- return theme.colors.content.tertiary;
1078
- case "brandExtra":
1079
- return theme.colors.content.brandExtra.secondary;
1080
- case "inverse":
1081
- return theme.colors.content.inverse;
1082
- default:
1083
- return theme.colors.content.brand.primary;
1084
- }
1085
- };
1086
- const colors = getVariantColors(state);
1087
- const focusRingColor = getFocusRingColor();
1088
- const spinnerColor = getSpinnerColor();
1089
- const iconSize = ICON_SIZES[size];
1090
- const spinnerSize = SPINNER_SIZES[size];
1091
- const fontSize = FONT_SIZES[size];
1092
- const borderRadius = BORDER_RADIUS[size];
1093
- const lineHeight = LINE_HEIGHTS[size];
1094
- const showTextLabel = hasVisibleLabel(children);
1095
- const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1096
- const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1097
- const iconOnlyHitArea = theme.sizing.flexButton(size).height;
1098
- const handleMouseEnter = () => {
1099
- if (!isDisabled) {
1100
- isMouseOverRef.current = true;
1101
- setState("hover");
1102
- }
1103
- };
1104
- const handleMouseLeave = () => {
1105
- if (!isDisabled) {
1106
- isMouseOverRef.current = false;
1107
- setState("default");
1108
- }
1109
- };
1110
- const handleMouseDown = () => {
1111
- if (!isDisabled) {
1112
- setState("press");
1113
- }
1114
- };
1115
- const handleMouseUp = () => {
1116
- if (!isDisabled) {
1117
- setState(isMouseOverRef.current ? "hover" : "default");
1118
- }
1119
- };
1120
- const handleFocus = () => {
1121
- if (!isDisabled) {
1122
- setIsFocused(true);
1123
- }
1124
- };
1125
- const handleBlur = () => {
1126
- setIsFocused(false);
1127
- };
1128
- const handleClick = (event) => {
1129
- if (isDisabled) return;
1130
- if (onPress) {
1131
- onPress();
1132
- }
1133
- if (onClick) {
1134
- onClick(event);
1135
- }
1136
- };
1137
- const handleKeyDown = (event) => {
1138
- if (isDisabled) return;
1139
- if (event.key === "Enter" || event.key === " ") {
1140
- event.preventDefault();
1141
- setState("press");
1142
- }
1143
- };
1144
- const handleKeyUp = (event) => {
1145
- if (isDisabled) return;
1146
- if (event.key === "Enter" || event.key === " ") {
1147
- event.preventDefault();
1148
- setState(isMouseOverRef.current ? "hover" : "default");
1060
+ default:
1061
+ return {
1062
+ bg: "transparent",
1063
+ text: theme.colors.content.primary,
1064
+ border: void 0
1065
+ };
1066
+ }
1067
+ };
1068
+ const getFocusRingColor = () => {
1069
+ switch (variant) {
1070
+ case "brand":
1071
+ return theme.colors.overlay.brand;
1072
+ case "brandExtra":
1073
+ return theme.colors.overlay.brandExtra;
1074
+ case "inverse":
1075
+ return "rgba(255, 255, 255, 0.3)";
1076
+ default:
1077
+ return theme.colors.overlay.mono;
1078
+ }
1079
+ };
1080
+ const getSpinnerColor = () => {
1081
+ switch (variant) {
1082
+ case "brand":
1083
+ return theme.colors.content.brand.primary;
1084
+ case "primary":
1085
+ return theme.colors.content.primary;
1086
+ case "secondary":
1087
+ return theme.colors.content.secondary;
1088
+ case "tertiary":
1089
+ return theme.colors.content.tertiary;
1090
+ case "brandExtra":
1091
+ return theme.colors.content.brandExtra.secondary;
1092
+ case "inverse":
1093
+ return theme.colors.content.inverse;
1094
+ default:
1095
+ return theme.colors.content.brand.primary;
1096
+ }
1097
+ };
1098
+ const colors = getVariantColors(state);
1099
+ const focusRingColor = getFocusRingColor();
1100
+ const spinnerColor = getSpinnerColor();
1101
+ const iconSize = ICON_SIZES[size];
1102
+ const spinnerSize = SPINNER_SIZES[size];
1103
+ const fontSize = FONT_SIZES[size];
1104
+ const borderRadius = BORDER_RADIUS[size];
1105
+ const lineHeight = LINE_HEIGHTS[size];
1106
+ const showTextLabel = hasVisibleLabel(children);
1107
+ const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1108
+ const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
1109
+ const iconOnlyHitArea = getFlexButtonBoxSize(size);
1110
+ const handleMouseEnter = () => {
1111
+ if (!isDisabled) {
1112
+ isMouseOverRef.current = true;
1113
+ setState("hover");
1114
+ }
1115
+ };
1116
+ const handleMouseLeave = () => {
1117
+ if (!isDisabled) {
1118
+ isMouseOverRef.current = false;
1119
+ setState("default");
1120
+ }
1121
+ };
1122
+ const handleMouseDown = () => {
1123
+ if (!isDisabled) {
1124
+ setState("press");
1125
+ }
1126
+ };
1127
+ const handleMouseUp = () => {
1128
+ if (!isDisabled) {
1129
+ setState(isMouseOverRef.current ? "hover" : "default");
1130
+ }
1131
+ };
1132
+ const handleFocus = () => {
1133
+ if (!isDisabled) {
1134
+ setIsFocused(true);
1135
+ }
1136
+ };
1137
+ const handleBlur = () => {
1138
+ setIsFocused(false);
1139
+ };
1140
+ const handleClick = (event) => {
1141
+ if (isDisabled) return;
1149
1142
  if (onPress) {
1150
1143
  onPress();
1151
1144
  }
1152
- }
1153
- };
1154
- const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1155
- const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1156
- const boxShadows = [];
1157
- if (borderShadow) boxShadows.push(borderShadow);
1158
- if (focusShadow) boxShadows.push(focusShadow);
1159
- const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1160
- const buttonStyle = {
1161
- display: "inline-flex",
1162
- alignItems: "center",
1163
- justifyContent: "center",
1164
- gap: isIconOnly ? 0 : "2px",
1165
- boxSizing: "border-box",
1166
- padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1167
- backgroundColor: loading ? "transparent" : colors.bg,
1168
- color: colors.text,
1169
- border: "none",
1170
- borderWidth: "0px",
1171
- borderRadius: `${borderRadius}px`,
1172
- cursor: isDisabled ? "not-allowed" : "pointer",
1173
- fontSize: `${fontSize}px`,
1174
- fontWeight: 500,
1175
- lineHeight: isIconOnly ? 0 : lineHeight,
1176
- fontFamily: "inherit",
1177
- transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1178
- outline: "none",
1179
- boxShadow: combinedBoxShadow,
1180
- opacity: isDisabled && !loading ? 0.6 : 1,
1181
- ...isIconOnly && {
1182
- width: iconOnlyHitArea,
1183
- height: iconOnlyHitArea,
1184
- minWidth: iconOnlyHitArea,
1185
- minHeight: iconOnlyHitArea,
1186
- flexShrink: 0
1187
- }
1188
- };
1189
- const contentStyle = {
1190
- display: "flex",
1191
- alignItems: "center",
1192
- justifyContent: "center",
1193
- gap: isIconOnly ? 0 : "2px",
1194
- ...isIconOnly && {
1195
- width: "100%",
1196
- height: "100%",
1197
- lineHeight: 0
1198
- }
1199
- };
1200
- const spinnerStyle = {
1201
- display: "flex",
1202
- alignItems: "center",
1203
- justifyContent: "center",
1204
- backgroundColor: "transparent",
1205
- height: lineHeight
1206
- };
1207
- const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1208
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1209
- "button",
1210
- {
1211
- ...buttonProps,
1212
- type,
1213
- className,
1214
- disabled: isDisabled,
1215
- onClick: handleClick,
1216
- onMouseEnter: handleMouseEnter,
1217
- onMouseLeave: handleMouseLeave,
1218
- onMouseDown: handleMouseDown,
1219
- onMouseUp: handleMouseUp,
1220
- onKeyDown: handleKeyDown,
1221
- onKeyUp: handleKeyUp,
1222
- onFocus: handleFocus,
1223
- onBlur: handleBlur,
1224
- "aria-label": computedAriaLabel,
1225
- "aria-busy": loading || void 0,
1226
- "aria-disabled": isDisabled || void 0,
1227
- "aria-describedby": ariaDescribedBy,
1228
- "aria-expanded": ariaExpanded,
1229
- "aria-haspopup": ariaHasPopup,
1230
- "aria-pressed": ariaPressed,
1231
- "aria-controls": ariaControls,
1232
- tabIndex,
1233
- style: buttonStyle,
1234
- "data-testid": testID || "flex-button",
1235
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: contentStyle, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: spinnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1236
- iconLeft && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1237
- showTextLabel && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children }),
1238
- hasIconChildren && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children }),
1239
- iconRight && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconRight })
1240
- ] }) })
1241
- }
1242
- );
1243
- };
1145
+ if (onClick) {
1146
+ onClick(event);
1147
+ }
1148
+ };
1149
+ const handleKeyDown = (event) => {
1150
+ if (isDisabled) return;
1151
+ if (event.key === "Enter" || event.key === " ") {
1152
+ event.preventDefault();
1153
+ setState("press");
1154
+ }
1155
+ };
1156
+ const handleKeyUp = (event) => {
1157
+ if (isDisabled) return;
1158
+ if (event.key === "Enter" || event.key === " ") {
1159
+ event.preventDefault();
1160
+ setState(isMouseOverRef.current ? "hover" : "default");
1161
+ if (onPress) {
1162
+ onPress();
1163
+ }
1164
+ }
1165
+ };
1166
+ const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1167
+ const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1168
+ const boxShadows = [];
1169
+ if (borderShadow) boxShadows.push(borderShadow);
1170
+ if (focusShadow) boxShadows.push(focusShadow);
1171
+ const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1172
+ const buttonStyle = {
1173
+ display: "inline-flex",
1174
+ alignItems: "center",
1175
+ justifyContent: "center",
1176
+ gap: isIconOnly ? 0 : "2px",
1177
+ boxSizing: "border-box",
1178
+ padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1179
+ backgroundColor: loading ? "transparent" : colors.bg,
1180
+ color: colors.text,
1181
+ border: "none",
1182
+ borderWidth: "0px",
1183
+ borderRadius: `${borderRadius}px`,
1184
+ cursor: isDisabled ? "not-allowed" : "pointer",
1185
+ fontSize: `${fontSize}px`,
1186
+ fontWeight: 500,
1187
+ lineHeight: isIconOnly ? 0 : lineHeight,
1188
+ fontFamily: "inherit",
1189
+ transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1190
+ outline: "none",
1191
+ boxShadow: combinedBoxShadow,
1192
+ opacity: isDisabled && !loading ? 0.6 : 1,
1193
+ ...isIconOnly && {
1194
+ width: iconOnlyHitArea,
1195
+ height: iconOnlyHitArea,
1196
+ minWidth: iconOnlyHitArea,
1197
+ minHeight: iconOnlyHitArea,
1198
+ flexShrink: 0
1199
+ }
1200
+ };
1201
+ const contentStyle = {
1202
+ display: "flex",
1203
+ alignItems: "center",
1204
+ justifyContent: "center",
1205
+ gap: isIconOnly ? 0 : "2px",
1206
+ ...isIconOnly && {
1207
+ width: "100%",
1208
+ height: "100%",
1209
+ lineHeight: 0
1210
+ }
1211
+ };
1212
+ const spinnerStyle = {
1213
+ display: "flex",
1214
+ alignItems: "center",
1215
+ justifyContent: "center",
1216
+ backgroundColor: "transparent",
1217
+ height: lineHeight
1218
+ };
1219
+ const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
1220
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1221
+ "button",
1222
+ {
1223
+ ...buttonProps,
1224
+ ref,
1225
+ type,
1226
+ className,
1227
+ disabled: isDisabled,
1228
+ onClick: handleClick,
1229
+ onMouseEnter: handleMouseEnter,
1230
+ onMouseLeave: handleMouseLeave,
1231
+ onMouseDown: handleMouseDown,
1232
+ onMouseUp: handleMouseUp,
1233
+ onKeyDown: handleKeyDown,
1234
+ onKeyUp: handleKeyUp,
1235
+ onFocus: handleFocus,
1236
+ onBlur: handleBlur,
1237
+ "aria-label": computedAriaLabel,
1238
+ "aria-busy": loading || void 0,
1239
+ "aria-disabled": isDisabled || void 0,
1240
+ "aria-describedby": ariaDescribedBy,
1241
+ "aria-expanded": ariaExpanded,
1242
+ "aria-haspopup": ariaHasPopup,
1243
+ "aria-pressed": ariaPressed,
1244
+ "aria-controls": ariaControls,
1245
+ tabIndex,
1246
+ style: buttonStyle,
1247
+ "data-testid": testID || "flex-button",
1248
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: contentStyle, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: spinnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1249
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
1250
+ showTextLabel && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children }),
1251
+ hasIconChildren && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children }),
1252
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: iconSize, color: colors.text, children: iconRight })
1253
+ ] }) })
1254
+ }
1255
+ );
1256
+ }
1257
+ );
1244
1258
  FlexButton.displayName = "FlexButton";
1245
1259
 
1246
1260
  // src/AppButton.tsx
@@ -1601,6 +1615,7 @@ ButtonGroup.displayName = "ButtonGroup";
1601
1615
  Button,
1602
1616
  ButtonGroup,
1603
1617
  FlexButton,
1604
- IconButton
1618
+ IconButton,
1619
+ getFlexButtonBoxSize
1605
1620
  });
1606
1621
  //# sourceMappingURL=index.js.map