@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/README.md +13 -1
- package/native/index.d.mts +8 -3
- package/native/index.d.ts +8 -3
- package/native/index.js +321 -306
- package/native/index.js.map +1 -1
- package/native/index.mjs +325 -310
- package/native/index.mjs.map +1 -1
- package/package.json +4 -4
- package/web/index.d.mts +8 -3
- package/web/index.d.ts +8 -3
- package/web/index.js +321 -306
- package/web/index.js.map +1 -1
- package/web/index.mjs +325 -310
- package/web/index.mjs.map +1 -1
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 {
|
|
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
|
|
859
|
-
xs:
|
|
860
|
-
sm:
|
|
861
|
-
md:
|
|
862
|
-
lg:
|
|
863
|
-
xl:
|
|
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
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
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:
|
|
943
|
-
text:
|
|
938
|
+
bg: background ? theme.colors.overlay.mono : "transparent",
|
|
939
|
+
text: theme.colors.control.text.disable,
|
|
944
940
|
border: void 0
|
|
945
941
|
};
|
|
946
|
-
|
|
947
|
-
|
|
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.
|
|
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
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
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"
|
|
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
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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"
|
|
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
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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.
|
|
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
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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"
|
|
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
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
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
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
"
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
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
|
|
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 } =
|
|
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
|
|
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 } =
|
|
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
|