@xsolla/xui-button 0.216.1 → 0.218.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
@@ -859,7 +859,13 @@ var SPINNER_SIZES = {
859
859
  lg: 18,
860
860
  xl: 20
861
861
  };
862
- var FLEX_BUTTON_PADDING = 4;
862
+ var BACKGROUND_PADDING = {
863
+ xs: 2,
864
+ sm: 2,
865
+ md: 2,
866
+ lg: 4,
867
+ xl: 4
868
+ };
863
869
  var hasVisibleLabel = (node) => {
864
870
  if (node == null || node === false || node === true) return false;
865
871
  if (typeof node === "string") return node.trim().length > 0;
@@ -936,7 +942,6 @@ var FlexButton = forwardRef(
936
942
  }, ref) => {
937
943
  const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
938
944
  const [state, setState] = useState3("default");
939
- const [isFocused, setIsFocused] = useState3(false);
940
945
  const isMouseOverRef = useRef(false);
941
946
  const isDisabled = disabled || loading;
942
947
  const getVariantColors = (currentState) => {
@@ -1035,18 +1040,6 @@ var FlexButton = forwardRef(
1035
1040
  };
1036
1041
  }
1037
1042
  };
1038
- const getFocusRingColor = () => {
1039
- switch (variant) {
1040
- case "brand":
1041
- return theme.colors.overlay.brand;
1042
- case "brandExtra":
1043
- return theme.colors.overlay.brandExtra;
1044
- case "inverse":
1045
- return "rgba(255, 255, 255, 0.3)";
1046
- default:
1047
- return theme.colors.overlay.mono;
1048
- }
1049
- };
1050
1043
  const getSpinnerColor = () => {
1051
1044
  switch (variant) {
1052
1045
  case "brand":
@@ -1066,13 +1059,13 @@ var FlexButton = forwardRef(
1066
1059
  }
1067
1060
  };
1068
1061
  const colors = getVariantColors(state);
1069
- const focusRingColor = getFocusRingColor();
1070
1062
  const spinnerColor = getSpinnerColor();
1071
1063
  const iconSize = ICON_SIZES[size];
1072
1064
  const spinnerSize = SPINNER_SIZES[size];
1073
1065
  const fontSize = FONT_SIZES[size];
1074
1066
  const borderRadius = BORDER_RADIUS[size];
1075
1067
  const lineHeight = LINE_HEIGHTS[size];
1068
+ const framePadding = background ? BACKGROUND_PADDING[size] : 0;
1076
1069
  const showTextLabel = hasVisibleLabel(children);
1077
1070
  const hasIconChildren = !showTextLabel && hasRenderableContent(children);
1078
1071
  const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
@@ -1099,14 +1092,6 @@ var FlexButton = forwardRef(
1099
1092
  setState(isMouseOverRef.current ? "hover" : "default");
1100
1093
  }
1101
1094
  };
1102
- const handleFocus = () => {
1103
- if (!isDisabled) {
1104
- setIsFocused(true);
1105
- }
1106
- };
1107
- const handleBlur = () => {
1108
- setIsFocused(false);
1109
- };
1110
1095
  const handleClick = (event) => {
1111
1096
  if (isDisabled) return;
1112
1097
  if (onPress) {
@@ -1134,18 +1119,13 @@ var FlexButton = forwardRef(
1134
1119
  }
1135
1120
  };
1136
1121
  const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
1137
- const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
1138
- const boxShadows = [];
1139
- if (borderShadow) boxShadows.push(borderShadow);
1140
- if (focusShadow) boxShadows.push(focusShadow);
1141
- const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
1142
1122
  const buttonStyle = {
1143
1123
  display: "inline-flex",
1144
1124
  alignItems: "center",
1145
1125
  justifyContent: "center",
1146
1126
  gap: isIconOnly ? 0 : "2px",
1147
1127
  boxSizing: "border-box",
1148
- padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
1128
+ padding: noPadding ? "0px" : `${framePadding}px`,
1149
1129
  backgroundColor: loading ? "transparent" : colors.bg,
1150
1130
  color: colors.text,
1151
1131
  border: "none",
@@ -1157,8 +1137,7 @@ var FlexButton = forwardRef(
1157
1137
  lineHeight: isIconOnly ? 0 : lineHeight,
1158
1138
  fontFamily: "inherit",
1159
1139
  transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
1160
- outline: "none",
1161
- boxShadow: combinedBoxShadow,
1140
+ boxShadow: borderShadow ?? "none",
1162
1141
  ...isIconOnly && {
1163
1142
  width: iconOnlyHitArea,
1164
1143
  height: iconOnlyHitArea,
@@ -1201,8 +1180,6 @@ var FlexButton = forwardRef(
1201
1180
  onMouseUp: handleMouseUp,
1202
1181
  onKeyDown: handleKeyDown,
1203
1182
  onKeyUp: handleKeyUp,
1204
- onFocus: handleFocus,
1205
- onBlur: handleBlur,
1206
1183
  "aria-label": computedAriaLabel,
1207
1184
  "aria-busy": loading || void 0,
1208
1185
  "aria-disabled": isDisabled || void 0,