@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.d.mts +25 -3
- package/native/index.d.ts +25 -3
- package/native/index.js +10 -33
- package/native/index.js.map +1 -1
- package/native/index.mjs +10 -33
- package/native/index.mjs.map +1 -1
- package/package.json +4 -4
- package/web/index.d.mts +25 -3
- package/web/index.d.ts +25 -3
- package/web/index.js +10 -33
- package/web/index.js.map +1 -1
- package/web/index.mjs +10 -33
- package/web/index.mjs.map +1 -1
package/web/index.mjs
CHANGED
|
@@ -895,7 +895,13 @@ var SPINNER_SIZES = {
|
|
|
895
895
|
lg: 18,
|
|
896
896
|
xl: 20
|
|
897
897
|
};
|
|
898
|
-
var
|
|
898
|
+
var BACKGROUND_PADDING = {
|
|
899
|
+
xs: 2,
|
|
900
|
+
sm: 2,
|
|
901
|
+
md: 2,
|
|
902
|
+
lg: 4,
|
|
903
|
+
xl: 4
|
|
904
|
+
};
|
|
899
905
|
var hasVisibleLabel = (node) => {
|
|
900
906
|
if (node == null || node === false || node === true) return false;
|
|
901
907
|
if (typeof node === "string") return node.trim().length > 0;
|
|
@@ -972,7 +978,6 @@ var FlexButton = forwardRef(
|
|
|
972
978
|
}, ref) => {
|
|
973
979
|
const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
|
|
974
980
|
const [state, setState] = useState3("default");
|
|
975
|
-
const [isFocused, setIsFocused] = useState3(false);
|
|
976
981
|
const isMouseOverRef = useRef(false);
|
|
977
982
|
const isDisabled = disabled || loading;
|
|
978
983
|
const getVariantColors = (currentState) => {
|
|
@@ -1071,18 +1076,6 @@ var FlexButton = forwardRef(
|
|
|
1071
1076
|
};
|
|
1072
1077
|
}
|
|
1073
1078
|
};
|
|
1074
|
-
const getFocusRingColor = () => {
|
|
1075
|
-
switch (variant) {
|
|
1076
|
-
case "brand":
|
|
1077
|
-
return theme.colors.overlay.brand;
|
|
1078
|
-
case "brandExtra":
|
|
1079
|
-
return theme.colors.overlay.brandExtra;
|
|
1080
|
-
case "inverse":
|
|
1081
|
-
return "rgba(255, 255, 255, 0.3)";
|
|
1082
|
-
default:
|
|
1083
|
-
return theme.colors.overlay.mono;
|
|
1084
|
-
}
|
|
1085
|
-
};
|
|
1086
1079
|
const getSpinnerColor = () => {
|
|
1087
1080
|
switch (variant) {
|
|
1088
1081
|
case "brand":
|
|
@@ -1102,13 +1095,13 @@ var FlexButton = forwardRef(
|
|
|
1102
1095
|
}
|
|
1103
1096
|
};
|
|
1104
1097
|
const colors = getVariantColors(state);
|
|
1105
|
-
const focusRingColor = getFocusRingColor();
|
|
1106
1098
|
const spinnerColor = getSpinnerColor();
|
|
1107
1099
|
const iconSize = ICON_SIZES[size];
|
|
1108
1100
|
const spinnerSize = SPINNER_SIZES[size];
|
|
1109
1101
|
const fontSize = FONT_SIZES[size];
|
|
1110
1102
|
const borderRadius = BORDER_RADIUS[size];
|
|
1111
1103
|
const lineHeight = LINE_HEIGHTS[size];
|
|
1104
|
+
const framePadding = background ? BACKGROUND_PADDING[size] : 0;
|
|
1112
1105
|
const showTextLabel = hasVisibleLabel(children);
|
|
1113
1106
|
const hasIconChildren = !showTextLabel && hasRenderableContent(children);
|
|
1114
1107
|
const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
|
|
@@ -1135,14 +1128,6 @@ var FlexButton = forwardRef(
|
|
|
1135
1128
|
setState(isMouseOverRef.current ? "hover" : "default");
|
|
1136
1129
|
}
|
|
1137
1130
|
};
|
|
1138
|
-
const handleFocus = () => {
|
|
1139
|
-
if (!isDisabled) {
|
|
1140
|
-
setIsFocused(true);
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
const handleBlur = () => {
|
|
1144
|
-
setIsFocused(false);
|
|
1145
|
-
};
|
|
1146
1131
|
const handleClick = (event) => {
|
|
1147
1132
|
if (isDisabled) return;
|
|
1148
1133
|
if (onPress) {
|
|
@@ -1170,18 +1155,13 @@ var FlexButton = forwardRef(
|
|
|
1170
1155
|
}
|
|
1171
1156
|
};
|
|
1172
1157
|
const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
|
|
1173
|
-
const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
|
|
1174
|
-
const boxShadows = [];
|
|
1175
|
-
if (borderShadow) boxShadows.push(borderShadow);
|
|
1176
|
-
if (focusShadow) boxShadows.push(focusShadow);
|
|
1177
|
-
const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
|
|
1178
1158
|
const buttonStyle = {
|
|
1179
1159
|
display: "inline-flex",
|
|
1180
1160
|
alignItems: "center",
|
|
1181
1161
|
justifyContent: "center",
|
|
1182
1162
|
gap: isIconOnly ? 0 : "2px",
|
|
1183
1163
|
boxSizing: "border-box",
|
|
1184
|
-
padding: noPadding ? "0px" : `${
|
|
1164
|
+
padding: noPadding ? "0px" : `${framePadding}px`,
|
|
1185
1165
|
backgroundColor: loading ? "transparent" : colors.bg,
|
|
1186
1166
|
color: colors.text,
|
|
1187
1167
|
border: "none",
|
|
@@ -1193,8 +1173,7 @@ var FlexButton = forwardRef(
|
|
|
1193
1173
|
lineHeight: isIconOnly ? 0 : lineHeight,
|
|
1194
1174
|
fontFamily: "inherit",
|
|
1195
1175
|
transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
|
|
1196
|
-
|
|
1197
|
-
boxShadow: combinedBoxShadow,
|
|
1176
|
+
boxShadow: borderShadow ?? "none",
|
|
1198
1177
|
...isIconOnly && {
|
|
1199
1178
|
width: iconOnlyHitArea,
|
|
1200
1179
|
height: iconOnlyHitArea,
|
|
@@ -1237,8 +1216,6 @@ var FlexButton = forwardRef(
|
|
|
1237
1216
|
onMouseUp: handleMouseUp,
|
|
1238
1217
|
onKeyDown: handleKeyDown,
|
|
1239
1218
|
onKeyUp: handleKeyUp,
|
|
1240
|
-
onFocus: handleFocus,
|
|
1241
|
-
onBlur: handleBlur,
|
|
1242
1219
|
"aria-label": computedAriaLabel,
|
|
1243
1220
|
"aria-busy": loading || void 0,
|
|
1244
1221
|
"aria-disabled": isDisabled || void 0,
|