@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/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
|
|
896
|
-
xs:
|
|
897
|
-
sm:
|
|
898
|
-
md:
|
|
899
|
-
lg:
|
|
900
|
-
xl:
|
|
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
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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:
|
|
980
|
-
text:
|
|
975
|
+
bg: background ? theme.colors.overlay.mono : "transparent",
|
|
976
|
+
text: theme.colors.control.text.disable,
|
|
981
977
|
border: void 0
|
|
982
978
|
};
|
|
983
|
-
|
|
984
|
-
|
|
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.
|
|
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
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
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"
|
|
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
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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"
|
|
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
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
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.
|
|
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
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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"
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
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
|
-
|
|
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
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
"
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
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
|