sapo-components-ui-rn 1.1.3 → 1.1.5
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/dist/components/Badge/index.d.ts +4 -2
- package/dist/index.esm.js +55 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +55 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Badge/index.tsx +96 -33
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
3
3
|
type BadgeType = "success" | "error" | "info" | "warning" | "default";
|
|
4
|
-
type BadgeSize = "
|
|
4
|
+
type BadgeSize = "large" | "medium" | "small";
|
|
5
5
|
type BadgeMode = "default" | "outline";
|
|
6
|
+
type ProgressType = "full" | "half" | "empty" | "none";
|
|
6
7
|
interface BadgeProps {
|
|
7
|
-
children?: React.ReactNode;
|
|
8
8
|
value?: string;
|
|
9
9
|
borderColor?: string;
|
|
10
10
|
backgroundColor?: string;
|
|
@@ -15,6 +15,8 @@ interface BadgeProps {
|
|
|
15
15
|
badgeSize?: BadgeSize;
|
|
16
16
|
mode?: BadgeMode;
|
|
17
17
|
textSize?: number;
|
|
18
|
+
progressType?: ProgressType;
|
|
19
|
+
leftIcon?: React.ReactNode;
|
|
18
20
|
}
|
|
19
21
|
declare const Badge: React.NamedExoticComponent<BadgeProps>;
|
|
20
22
|
export default Badge;
|
package/dist/index.esm.js
CHANGED
|
@@ -6781,33 +6781,68 @@ var Image$1 = memoDeepEqual(Image);
|
|
|
6781
6781
|
|
|
6782
6782
|
var BADGE_CONFIGS = {
|
|
6783
6783
|
sizes: {
|
|
6784
|
-
|
|
6784
|
+
medium: {
|
|
6785
6785
|
paddingHorizontal: CONSTANTS.SPACE_4,
|
|
6786
6786
|
minWidth: 16,
|
|
6787
6787
|
minHeight: 16,
|
|
6788
6788
|
textSize: 10,
|
|
6789
6789
|
},
|
|
6790
|
-
|
|
6790
|
+
large: {
|
|
6791
6791
|
paddingHorizontal: CONSTANTS.SPACE_8,
|
|
6792
6792
|
minWidth: 16,
|
|
6793
|
+
minHeight: 24,
|
|
6793
6794
|
textSize: 12,
|
|
6794
6795
|
},
|
|
6795
6796
|
},
|
|
6796
|
-
|
|
6797
|
+
small: {
|
|
6797
6798
|
width: 8,
|
|
6798
6799
|
height: 8,
|
|
6799
6800
|
borderRadius: 4,
|
|
6800
6801
|
},
|
|
6801
6802
|
};
|
|
6803
|
+
var ProgressCircle = function (_a) {
|
|
6804
|
+
var progress = _a.progress, color = _a.color;
|
|
6805
|
+
var size = 8;
|
|
6806
|
+
if (progress === "empty") {
|
|
6807
|
+
return (React__default.createElement(View, { style: {
|
|
6808
|
+
width: size,
|
|
6809
|
+
height: size,
|
|
6810
|
+
borderRadius: size / 2,
|
|
6811
|
+
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6812
|
+
borderColor: color,
|
|
6813
|
+
backgroundColor: "transparent",
|
|
6814
|
+
} }));
|
|
6815
|
+
}
|
|
6816
|
+
if (progress === "half") {
|
|
6817
|
+
return (React__default.createElement(View, { style: {
|
|
6818
|
+
width: size,
|
|
6819
|
+
height: size,
|
|
6820
|
+
borderRadius: size / 2,
|
|
6821
|
+
borderWidth: CONSTANTS.BORDER_WIDTH_1,
|
|
6822
|
+
borderColor: color,
|
|
6823
|
+
backgroundColor: "transparent",
|
|
6824
|
+
overflow: "hidden",
|
|
6825
|
+
justifyContent: "flex-end",
|
|
6826
|
+
} },
|
|
6827
|
+
React__default.createElement(View, { style: {
|
|
6828
|
+
width: size,
|
|
6829
|
+
height: size / 2,
|
|
6830
|
+
backgroundColor: color,
|
|
6831
|
+
} })));
|
|
6832
|
+
}
|
|
6833
|
+
return (React__default.createElement(View, { style: {
|
|
6834
|
+
width: size,
|
|
6835
|
+
height: size,
|
|
6836
|
+
borderRadius: size / 2,
|
|
6837
|
+
backgroundColor: color,
|
|
6838
|
+
} }));
|
|
6839
|
+
};
|
|
6802
6840
|
var Badge = React__default.memo(function (_a) {
|
|
6803
|
-
var
|
|
6841
|
+
var _b = _a.value, value = _b === void 0 ? "1" : _b, style = _a.style, textColor = _a.textColor, textStyle = _a.textStyle, _c = _a.type, type = _c === void 0 ? "success" : _c, _d = _a.badgeSize, badgeSize = _d === void 0 ? "large" : _d, _e = _a.mode, mode = _e === void 0 ? "default" : _e, textSize = _a.textSize, borderColor = _a.borderColor, backgroundColor = _a.backgroundColor, _f = _a.progressType, progressType = _f === void 0 ? "none" : _f, leftIcon = _a.leftIcon;
|
|
6804
6842
|
var theme = useInternalTheme();
|
|
6805
6843
|
var colors = theme.colors;
|
|
6806
|
-
if (children) {
|
|
6807
|
-
return React__default.createElement(View, { style: style }, children);
|
|
6808
|
-
}
|
|
6809
6844
|
var sizeStyles = useMemo(function () {
|
|
6810
|
-
if (badgeSize === "
|
|
6845
|
+
if (badgeSize === "small")
|
|
6811
6846
|
return null;
|
|
6812
6847
|
return BADGE_CONFIGS.sizes[badgeSize];
|
|
6813
6848
|
}, [badgeSize]);
|
|
@@ -6839,8 +6874,8 @@ var Badge = React__default.memo(function (_a) {
|
|
|
6839
6874
|
backgroundColor: backgroundColor || colors.surfacePrimaryInverseDefault,
|
|
6840
6875
|
},
|
|
6841
6876
|
outline: {
|
|
6842
|
-
borderColor: borderColor || colors.
|
|
6843
|
-
backgroundColor: backgroundColor || colors.
|
|
6877
|
+
borderColor: borderColor || colors.borderPrimaryDefault,
|
|
6878
|
+
backgroundColor: backgroundColor || colors.surfaceSecondaryDefault,
|
|
6844
6879
|
},
|
|
6845
6880
|
},
|
|
6846
6881
|
warning: {
|
|
@@ -6878,7 +6913,7 @@ var Badge = React__default.memo(function (_a) {
|
|
|
6878
6913
|
},
|
|
6879
6914
|
info: {
|
|
6880
6915
|
default: colors.textOnFillDefault,
|
|
6881
|
-
outline: colors.
|
|
6916
|
+
outline: colors.textDefault,
|
|
6882
6917
|
},
|
|
6883
6918
|
warning: {
|
|
6884
6919
|
default: colors.textOnFillDefault,
|
|
@@ -6893,16 +6928,20 @@ var Badge = React__default.memo(function (_a) {
|
|
|
6893
6928
|
}, [colors, type, mode]);
|
|
6894
6929
|
var finalTextSize = useMemo(function () {
|
|
6895
6930
|
var _a;
|
|
6896
|
-
if (badgeSize === "
|
|
6931
|
+
if (badgeSize === "small")
|
|
6897
6932
|
return 0;
|
|
6898
6933
|
return textSize || ((_a = BADGE_CONFIGS.sizes[badgeSize]) === null || _a === void 0 ? void 0 : _a.textSize) || 12;
|
|
6899
6934
|
}, [textSize, badgeSize]);
|
|
6900
|
-
if (badgeSize === "
|
|
6901
|
-
return (React__default.createElement(View, { row: true,
|
|
6935
|
+
if (badgeSize === "small") {
|
|
6936
|
+
return (React__default.createElement(View, { row: true, style: style },
|
|
6937
|
+
React__default.createElement(ProgressCircle, { progress: progressType, color: typeStyles.backgroundColor })));
|
|
6902
6938
|
}
|
|
6903
6939
|
return (React__default.createElement(View, { row: true },
|
|
6904
|
-
React__default.createElement(View, { center: true, borderRadius: 999, borderWidth: CONSTANTS.BORDER_WIDTH_1, style: [sizeStyles, typeStyles, style] },
|
|
6905
|
-
React__default.createElement(
|
|
6940
|
+
React__default.createElement(View, { row: true, center: true, borderRadius: 999, borderWidth: CONSTANTS.BORDER_WIDTH_1, style: [sizeStyles, typeStyles, style] },
|
|
6941
|
+
leftIcon && React__default.createElement(View, { paddingRight: CONSTANTS.SPACE_4 }, leftIcon),
|
|
6942
|
+
progressType !== "none" && (React__default.createElement(ProgressCircle, { progress: progressType, color: textColorStyle })),
|
|
6943
|
+
React__default.createElement(View, { paddingLeft: progressType !== "none" ? CONSTANTS.SPACE_4 : 0 },
|
|
6944
|
+
React__default.createElement(Text$1, { size: finalTextSize, color: textColor || textColorStyle, style: [styles$8.textMedium, textStyle] }, value)))));
|
|
6906
6945
|
});
|
|
6907
6946
|
Badge.displayName = "Badge";
|
|
6908
6947
|
var styles$8 = StyleSheet.create(__assign({}, containerStyles));
|