@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/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/native/index.mjs
CHANGED
|
@@ -776,11 +776,26 @@ IconButton.displayName = "IconButton";
|
|
|
776
776
|
|
|
777
777
|
// src/FlexButton.tsx
|
|
778
778
|
import React4, {
|
|
779
|
+
forwardRef,
|
|
779
780
|
useRef,
|
|
780
781
|
useState as useState3
|
|
781
782
|
} from "react";
|
|
782
|
-
import {
|
|
783
|
+
import { useResolvedTheme as useResolvedTheme3 } from "@xsolla/xui-core";
|
|
783
784
|
import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
785
|
+
var ICON_SIZES = {
|
|
786
|
+
xs: 12,
|
|
787
|
+
sm: 14,
|
|
788
|
+
md: 16,
|
|
789
|
+
lg: 18,
|
|
790
|
+
xl: 20
|
|
791
|
+
};
|
|
792
|
+
var SPINNER_SIZES = {
|
|
793
|
+
xs: 12,
|
|
794
|
+
sm: 14,
|
|
795
|
+
md: 16,
|
|
796
|
+
lg: 18,
|
|
797
|
+
xl: 20
|
|
798
|
+
};
|
|
784
799
|
var FLEX_BUTTON_PADDING = 4;
|
|
785
800
|
var hasVisibleLabel = (node) => {
|
|
786
801
|
if (node == null || node === false || node === true) return false;
|
|
@@ -799,20 +814,14 @@ var hasRenderableContent = (node) => {
|
|
|
799
814
|
if (Array.isArray(node)) return node.some(hasRenderableContent);
|
|
800
815
|
return true;
|
|
801
816
|
};
|
|
802
|
-
var
|
|
803
|
-
xs:
|
|
804
|
-
sm:
|
|
805
|
-
md:
|
|
806
|
-
lg:
|
|
807
|
-
xl:
|
|
808
|
-
};
|
|
809
|
-
var SPINNER_SIZES = {
|
|
810
|
-
xs: 12,
|
|
811
|
-
sm: 14,
|
|
812
|
-
md: 16,
|
|
813
|
-
lg: 18,
|
|
814
|
-
xl: 20
|
|
817
|
+
var BOX_SIZES = {
|
|
818
|
+
xs: 20,
|
|
819
|
+
sm: 22,
|
|
820
|
+
md: 28,
|
|
821
|
+
lg: 32,
|
|
822
|
+
xl: 36
|
|
815
823
|
};
|
|
824
|
+
var getFlexButtonBoxSize = (size = "md") => BOX_SIZES[size];
|
|
816
825
|
var LINE_HEIGHTS = {
|
|
817
826
|
xs: "14px",
|
|
818
827
|
sm: "16px",
|
|
@@ -834,325 +843,330 @@ var BORDER_RADIUS = {
|
|
|
834
843
|
sm: 2,
|
|
835
844
|
xs: 2
|
|
836
845
|
};
|
|
837
|
-
var FlexButton = (
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
border: void 0
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
const effectiveBackground = loading ? false : background;
|
|
876
|
-
switch (variant) {
|
|
877
|
-
case "brand":
|
|
878
|
-
if (effectiveBackground) {
|
|
879
|
-
return {
|
|
880
|
-
bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
|
|
881
|
-
text: theme.colors.content.on.brand,
|
|
882
|
-
border: void 0
|
|
883
|
-
};
|
|
884
|
-
}
|
|
846
|
+
var FlexButton = forwardRef(
|
|
847
|
+
({
|
|
848
|
+
children,
|
|
849
|
+
variant = "brand",
|
|
850
|
+
size = "md",
|
|
851
|
+
background = false,
|
|
852
|
+
hoverBackground = true,
|
|
853
|
+
noPadding = false,
|
|
854
|
+
disabled = false,
|
|
855
|
+
loading = false,
|
|
856
|
+
iconLeft,
|
|
857
|
+
iconRight,
|
|
858
|
+
onPress,
|
|
859
|
+
onClick,
|
|
860
|
+
className,
|
|
861
|
+
type = "button",
|
|
862
|
+
"aria-label": ariaLabel,
|
|
863
|
+
"aria-describedby": ariaDescribedBy,
|
|
864
|
+
"aria-expanded": ariaExpanded,
|
|
865
|
+
"aria-haspopup": ariaHasPopup,
|
|
866
|
+
"aria-pressed": ariaPressed,
|
|
867
|
+
"aria-controls": ariaControls,
|
|
868
|
+
testID,
|
|
869
|
+
tabIndex = 0,
|
|
870
|
+
themeMode,
|
|
871
|
+
themeProductContext,
|
|
872
|
+
...buttonProps
|
|
873
|
+
}, ref) => {
|
|
874
|
+
const { theme } = useResolvedTheme3({ themeMode, themeProductContext });
|
|
875
|
+
const [state, setState] = useState3("default");
|
|
876
|
+
const [isFocused, setIsFocused] = useState3(false);
|
|
877
|
+
const isMouseOverRef = useRef(false);
|
|
878
|
+
const isDisabled = disabled || loading;
|
|
879
|
+
const getVariantColors = (currentState) => {
|
|
880
|
+
if (isDisabled) {
|
|
885
881
|
return {
|
|
886
|
-
bg:
|
|
887
|
-
text:
|
|
882
|
+
bg: background ? theme.colors.overlay.mono : "transparent",
|
|
883
|
+
text: theme.colors.control.text.disable,
|
|
888
884
|
border: void 0
|
|
889
885
|
};
|
|
890
|
-
|
|
891
|
-
|
|
886
|
+
}
|
|
887
|
+
const effectiveBackground = loading ? false : background;
|
|
888
|
+
switch (variant) {
|
|
889
|
+
case "brand":
|
|
890
|
+
if (effectiveBackground) {
|
|
891
|
+
return {
|
|
892
|
+
bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
|
|
893
|
+
text: theme.colors.content.on.brand,
|
|
894
|
+
border: void 0
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
return {
|
|
898
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
|
|
899
|
+
text: currentState === "press" && hoverBackground ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
|
|
900
|
+
border: void 0
|
|
901
|
+
};
|
|
902
|
+
case "primary":
|
|
903
|
+
if (effectiveBackground) {
|
|
904
|
+
return {
|
|
905
|
+
bg: theme.colors.background.primary,
|
|
906
|
+
text: theme.colors.content.primary,
|
|
907
|
+
border: currentState === "press" ? theme.colors.border.primary : void 0
|
|
908
|
+
};
|
|
909
|
+
}
|
|
892
910
|
return {
|
|
893
|
-
bg: theme.colors.
|
|
911
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
894
912
|
text: theme.colors.content.primary,
|
|
895
913
|
border: currentState === "press" ? theme.colors.border.primary : void 0
|
|
896
914
|
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
915
|
+
case "secondary":
|
|
916
|
+
if (effectiveBackground) {
|
|
917
|
+
return {
|
|
918
|
+
bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
|
|
919
|
+
text: theme.colors.content.secondary,
|
|
920
|
+
border: void 0
|
|
921
|
+
};
|
|
922
|
+
}
|
|
905
923
|
return {
|
|
906
|
-
bg: currentState === "press"
|
|
907
|
-
text: theme.colors.content.secondary,
|
|
924
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
925
|
+
text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
|
|
908
926
|
border: void 0
|
|
909
927
|
};
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
928
|
+
case "tertiary":
|
|
929
|
+
if (effectiveBackground) {
|
|
930
|
+
return {
|
|
931
|
+
bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
|
|
932
|
+
text: theme.colors.content.tertiary,
|
|
933
|
+
border: void 0
|
|
934
|
+
};
|
|
935
|
+
}
|
|
918
936
|
return {
|
|
919
|
-
bg: currentState === "press"
|
|
920
|
-
text: theme.colors.content.tertiary,
|
|
937
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
938
|
+
text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
|
|
921
939
|
border: void 0
|
|
922
940
|
};
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
941
|
+
case "brandExtra":
|
|
942
|
+
if (effectiveBackground) {
|
|
943
|
+
return {
|
|
944
|
+
bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
|
|
945
|
+
text: theme.colors.content.on.brandExtra,
|
|
946
|
+
border: void 0
|
|
947
|
+
};
|
|
948
|
+
}
|
|
931
949
|
return {
|
|
932
|
-
bg: currentState === "press" ? theme.colors.
|
|
933
|
-
text: theme.colors.content.on.brandExtra,
|
|
950
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
|
|
951
|
+
text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
|
|
934
952
|
border: void 0
|
|
935
953
|
};
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
954
|
+
case "inverse":
|
|
955
|
+
if (effectiveBackground) {
|
|
956
|
+
return {
|
|
957
|
+
bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
|
|
958
|
+
text: theme.colors.content.inverse,
|
|
959
|
+
border: void 0
|
|
960
|
+
};
|
|
961
|
+
}
|
|
944
962
|
return {
|
|
945
|
-
bg: currentState === "press"
|
|
963
|
+
bg: !hoverBackground ? "transparent" : currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
946
964
|
text: theme.colors.content.inverse,
|
|
947
965
|
border: void 0
|
|
948
966
|
};
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
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
|
-
const handleBlur = () => {
|
|
1033
|
-
setIsFocused(false);
|
|
1034
|
-
};
|
|
1035
|
-
const handleClick = (event) => {
|
|
1036
|
-
if (isDisabled) return;
|
|
1037
|
-
if (onPress) {
|
|
1038
|
-
onPress();
|
|
1039
|
-
}
|
|
1040
|
-
if (onClick) {
|
|
1041
|
-
onClick(event);
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
const handleKeyDown = (event) => {
|
|
1045
|
-
if (isDisabled) return;
|
|
1046
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
1047
|
-
event.preventDefault();
|
|
1048
|
-
setState("press");
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
const handleKeyUp = (event) => {
|
|
1052
|
-
if (isDisabled) return;
|
|
1053
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
1054
|
-
event.preventDefault();
|
|
1055
|
-
setState(isMouseOverRef.current ? "hover" : "default");
|
|
967
|
+
default:
|
|
968
|
+
return {
|
|
969
|
+
bg: "transparent",
|
|
970
|
+
text: theme.colors.content.primary,
|
|
971
|
+
border: void 0
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
const getFocusRingColor = () => {
|
|
976
|
+
switch (variant) {
|
|
977
|
+
case "brand":
|
|
978
|
+
return theme.colors.overlay.brand;
|
|
979
|
+
case "brandExtra":
|
|
980
|
+
return theme.colors.overlay.brandExtra;
|
|
981
|
+
case "inverse":
|
|
982
|
+
return "rgba(255, 255, 255, 0.3)";
|
|
983
|
+
default:
|
|
984
|
+
return theme.colors.overlay.mono;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
const getSpinnerColor = () => {
|
|
988
|
+
switch (variant) {
|
|
989
|
+
case "brand":
|
|
990
|
+
return theme.colors.content.brand.primary;
|
|
991
|
+
case "primary":
|
|
992
|
+
return theme.colors.content.primary;
|
|
993
|
+
case "secondary":
|
|
994
|
+
return theme.colors.content.secondary;
|
|
995
|
+
case "tertiary":
|
|
996
|
+
return theme.colors.content.tertiary;
|
|
997
|
+
case "brandExtra":
|
|
998
|
+
return theme.colors.content.brandExtra.secondary;
|
|
999
|
+
case "inverse":
|
|
1000
|
+
return theme.colors.content.inverse;
|
|
1001
|
+
default:
|
|
1002
|
+
return theme.colors.content.brand.primary;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
const colors = getVariantColors(state);
|
|
1006
|
+
const focusRingColor = getFocusRingColor();
|
|
1007
|
+
const spinnerColor = getSpinnerColor();
|
|
1008
|
+
const iconSize = ICON_SIZES[size];
|
|
1009
|
+
const spinnerSize = SPINNER_SIZES[size];
|
|
1010
|
+
const fontSize = FONT_SIZES[size];
|
|
1011
|
+
const borderRadius = BORDER_RADIUS[size];
|
|
1012
|
+
const lineHeight = LINE_HEIGHTS[size];
|
|
1013
|
+
const showTextLabel = hasVisibleLabel(children);
|
|
1014
|
+
const hasIconChildren = !showTextLabel && hasRenderableContent(children);
|
|
1015
|
+
const isIconOnly = !loading && !showTextLabel && Boolean(iconLeft || iconRight || hasIconChildren);
|
|
1016
|
+
const iconOnlyHitArea = getFlexButtonBoxSize(size);
|
|
1017
|
+
const handleMouseEnter = () => {
|
|
1018
|
+
if (!isDisabled) {
|
|
1019
|
+
isMouseOverRef.current = true;
|
|
1020
|
+
setState("hover");
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
const handleMouseLeave = () => {
|
|
1024
|
+
if (!isDisabled) {
|
|
1025
|
+
isMouseOverRef.current = false;
|
|
1026
|
+
setState("default");
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
const handleMouseDown = () => {
|
|
1030
|
+
if (!isDisabled) {
|
|
1031
|
+
setState("press");
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
const handleMouseUp = () => {
|
|
1035
|
+
if (!isDisabled) {
|
|
1036
|
+
setState(isMouseOverRef.current ? "hover" : "default");
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
const handleFocus = () => {
|
|
1040
|
+
if (!isDisabled) {
|
|
1041
|
+
setIsFocused(true);
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
const handleBlur = () => {
|
|
1045
|
+
setIsFocused(false);
|
|
1046
|
+
};
|
|
1047
|
+
const handleClick = (event) => {
|
|
1048
|
+
if (isDisabled) return;
|
|
1056
1049
|
if (onPress) {
|
|
1057
1050
|
onPress();
|
|
1058
1051
|
}
|
|
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
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
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
|
-
|
|
1052
|
+
if (onClick) {
|
|
1053
|
+
onClick(event);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
const handleKeyDown = (event) => {
|
|
1057
|
+
if (isDisabled) return;
|
|
1058
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1059
|
+
event.preventDefault();
|
|
1060
|
+
setState("press");
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
const handleKeyUp = (event) => {
|
|
1064
|
+
if (isDisabled) return;
|
|
1065
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1066
|
+
event.preventDefault();
|
|
1067
|
+
setState(isMouseOverRef.current ? "hover" : "default");
|
|
1068
|
+
if (onPress) {
|
|
1069
|
+
onPress();
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
|
|
1074
|
+
const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
|
|
1075
|
+
const boxShadows = [];
|
|
1076
|
+
if (borderShadow) boxShadows.push(borderShadow);
|
|
1077
|
+
if (focusShadow) boxShadows.push(focusShadow);
|
|
1078
|
+
const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
|
|
1079
|
+
const buttonStyle = {
|
|
1080
|
+
display: "inline-flex",
|
|
1081
|
+
alignItems: "center",
|
|
1082
|
+
justifyContent: "center",
|
|
1083
|
+
gap: isIconOnly ? 0 : "2px",
|
|
1084
|
+
boxSizing: "border-box",
|
|
1085
|
+
padding: noPadding ? "0px" : `${FLEX_BUTTON_PADDING}px`,
|
|
1086
|
+
backgroundColor: loading ? "transparent" : colors.bg,
|
|
1087
|
+
color: colors.text,
|
|
1088
|
+
border: "none",
|
|
1089
|
+
borderWidth: "0px",
|
|
1090
|
+
borderRadius: `${borderRadius}px`,
|
|
1091
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
1092
|
+
fontSize: `${fontSize}px`,
|
|
1093
|
+
fontWeight: 500,
|
|
1094
|
+
lineHeight: isIconOnly ? 0 : lineHeight,
|
|
1095
|
+
fontFamily: "inherit",
|
|
1096
|
+
transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
|
|
1097
|
+
outline: "none",
|
|
1098
|
+
boxShadow: combinedBoxShadow,
|
|
1099
|
+
opacity: isDisabled && !loading ? 0.6 : 1,
|
|
1100
|
+
...isIconOnly && {
|
|
1101
|
+
width: iconOnlyHitArea,
|
|
1102
|
+
height: iconOnlyHitArea,
|
|
1103
|
+
minWidth: iconOnlyHitArea,
|
|
1104
|
+
minHeight: iconOnlyHitArea,
|
|
1105
|
+
flexShrink: 0
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
const contentStyle = {
|
|
1109
|
+
display: "flex",
|
|
1110
|
+
alignItems: "center",
|
|
1111
|
+
justifyContent: "center",
|
|
1112
|
+
gap: isIconOnly ? 0 : "2px",
|
|
1113
|
+
...isIconOnly && {
|
|
1114
|
+
width: "100%",
|
|
1115
|
+
height: "100%",
|
|
1116
|
+
lineHeight: 0
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
const spinnerStyle = {
|
|
1120
|
+
display: "flex",
|
|
1121
|
+
alignItems: "center",
|
|
1122
|
+
justifyContent: "center",
|
|
1123
|
+
backgroundColor: "transparent",
|
|
1124
|
+
height: lineHeight
|
|
1125
|
+
};
|
|
1126
|
+
const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
|
|
1127
|
+
return /* @__PURE__ */ jsx7(
|
|
1128
|
+
"button",
|
|
1129
|
+
{
|
|
1130
|
+
...buttonProps,
|
|
1131
|
+
ref,
|
|
1132
|
+
type,
|
|
1133
|
+
className,
|
|
1134
|
+
disabled: isDisabled,
|
|
1135
|
+
onClick: handleClick,
|
|
1136
|
+
onMouseEnter: handleMouseEnter,
|
|
1137
|
+
onMouseLeave: handleMouseLeave,
|
|
1138
|
+
onMouseDown: handleMouseDown,
|
|
1139
|
+
onMouseUp: handleMouseUp,
|
|
1140
|
+
onKeyDown: handleKeyDown,
|
|
1141
|
+
onKeyUp: handleKeyUp,
|
|
1142
|
+
onFocus: handleFocus,
|
|
1143
|
+
onBlur: handleBlur,
|
|
1144
|
+
"aria-label": computedAriaLabel,
|
|
1145
|
+
"aria-busy": loading || void 0,
|
|
1146
|
+
"aria-disabled": isDisabled || void 0,
|
|
1147
|
+
"aria-describedby": ariaDescribedBy,
|
|
1148
|
+
"aria-expanded": ariaExpanded,
|
|
1149
|
+
"aria-haspopup": ariaHasPopup,
|
|
1150
|
+
"aria-pressed": ariaPressed,
|
|
1151
|
+
"aria-controls": ariaControls,
|
|
1152
|
+
tabIndex,
|
|
1153
|
+
style: buttonStyle,
|
|
1154
|
+
"data-testid": testID || "flex-button",
|
|
1155
|
+
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: [
|
|
1156
|
+
iconLeft && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
|
|
1157
|
+
showTextLabel && /* @__PURE__ */ jsx7("span", { children }),
|
|
1158
|
+
hasIconChildren && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children }),
|
|
1159
|
+
iconRight && /* @__PURE__ */ jsx7(Icon, { size: iconSize, color: colors.text, children: iconRight })
|
|
1160
|
+
] }) })
|
|
1161
|
+
}
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1151
1165
|
FlexButton.displayName = "FlexButton";
|
|
1152
1166
|
|
|
1153
1167
|
// src/AppButton.tsx
|
|
1154
1168
|
import React5, { useState as useState4 } from "react";
|
|
1155
|
-
import { useResolvedTheme as
|
|
1169
|
+
import { useResolvedTheme as useResolvedTheme4 } from "@xsolla/xui-core";
|
|
1156
1170
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1157
1171
|
var cloneIconWithDefaults3 = (icon, defaultSize, defaultColor) => {
|
|
1158
1172
|
if (!React5.isValidElement(icon)) return icon;
|
|
@@ -1189,7 +1203,7 @@ var AppButton = ({
|
|
|
1189
1203
|
themeMode,
|
|
1190
1204
|
themeProductContext
|
|
1191
1205
|
}) => {
|
|
1192
|
-
const { theme } =
|
|
1206
|
+
const { theme } = useResolvedTheme4({ themeMode, themeProductContext });
|
|
1193
1207
|
const [isKeyboardPressed, setIsKeyboardPressed] = useState4(false);
|
|
1194
1208
|
const isDisabled = disabled || loading;
|
|
1195
1209
|
const sizeStyles = theme.sizing.button(size);
|
|
@@ -1375,7 +1389,7 @@ AppButton.displayName = "AppButton";
|
|
|
1375
1389
|
|
|
1376
1390
|
// src/ButtonGroup.tsx
|
|
1377
1391
|
import React6 from "react";
|
|
1378
|
-
import { useResolvedTheme as
|
|
1392
|
+
import { useResolvedTheme as useResolvedTheme5 } from "@xsolla/xui-core";
|
|
1379
1393
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1380
1394
|
var ButtonGroup = ({
|
|
1381
1395
|
orientation = "horizontal",
|
|
@@ -1392,7 +1406,7 @@ var ButtonGroup = ({
|
|
|
1392
1406
|
themeMode,
|
|
1393
1407
|
themeProductContext
|
|
1394
1408
|
}) => {
|
|
1395
|
-
const { theme } =
|
|
1409
|
+
const { theme } = useResolvedTheme5({ themeMode, themeProductContext });
|
|
1396
1410
|
const flattenChildren = (children2) => {
|
|
1397
1411
|
const result = [];
|
|
1398
1412
|
React6.Children.forEach(children2, (child) => {
|
|
@@ -1507,6 +1521,7 @@ export {
|
|
|
1507
1521
|
Button,
|
|
1508
1522
|
ButtonGroup,
|
|
1509
1523
|
FlexButton,
|
|
1510
|
-
IconButton
|
|
1524
|
+
IconButton,
|
|
1525
|
+
getFlexButtonBoxSize
|
|
1511
1526
|
};
|
|
1512
1527
|
//# sourceMappingURL=index.mjs.map
|