sapo-components-ui-rn 1.1.3 → 1.1.4

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.
@@ -3,8 +3,8 @@ import { StyleProp, ViewStyle, TextStyle } from "react-native";
3
3
  type BadgeType = "success" | "error" | "info" | "warning" | "default";
4
4
  type BadgeSize = "default" | "small" | "tiny";
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
@@ -6799,13 +6799,47 @@ var BADGE_CONFIGS = {
6799
6799
  borderRadius: 4,
6800
6800
  },
6801
6801
  };
6802
+ var ProgressCircle = function (_a) {
6803
+ var progress = _a.progress, color = _a.color;
6804
+ var size = 8;
6805
+ if (progress === "empty") {
6806
+ return (React__default.createElement(View, { style: {
6807
+ width: size,
6808
+ height: size,
6809
+ borderRadius: size / 2,
6810
+ borderWidth: CONSTANTS.BORDER_WIDTH_1,
6811
+ borderColor: color,
6812
+ backgroundColor: "transparent",
6813
+ } }));
6814
+ }
6815
+ if (progress === "half") {
6816
+ return (React__default.createElement(View, { style: {
6817
+ width: size,
6818
+ height: size,
6819
+ borderRadius: size / 2,
6820
+ borderWidth: CONSTANTS.BORDER_WIDTH_1,
6821
+ borderColor: color,
6822
+ backgroundColor: "transparent",
6823
+ overflow: "hidden",
6824
+ justifyContent: "flex-end",
6825
+ } },
6826
+ React__default.createElement(View, { style: {
6827
+ width: size,
6828
+ height: size / 2,
6829
+ backgroundColor: color,
6830
+ } })));
6831
+ }
6832
+ return (React__default.createElement(View, { style: {
6833
+ width: size,
6834
+ height: size,
6835
+ borderRadius: size / 2,
6836
+ backgroundColor: color,
6837
+ } }));
6838
+ };
6802
6839
  var Badge = React__default.memo(function (_a) {
6803
- var children = _a.children, _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 ? "default" : _d, _e = _a.mode, mode = _e === void 0 ? "default" : _e, textSize = _a.textSize, borderColor = _a.borderColor, backgroundColor = _a.backgroundColor;
6840
+ 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 ? "default" : _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
6841
  var theme = useInternalTheme();
6805
6842
  var colors = theme.colors;
6806
- if (children) {
6807
- return React__default.createElement(View, { style: style }, children);
6808
- }
6809
6843
  var sizeStyles = useMemo(function () {
6810
6844
  if (badgeSize === "tiny")
6811
6845
  return null;
@@ -6898,11 +6932,15 @@ var Badge = React__default.memo(function (_a) {
6898
6932
  return textSize || ((_a = BADGE_CONFIGS.sizes[badgeSize]) === null || _a === void 0 ? void 0 : _a.textSize) || 12;
6899
6933
  }, [textSize, badgeSize]);
6900
6934
  if (badgeSize === "tiny") {
6901
- return (React__default.createElement(View, { row: true, width: BADGE_CONFIGS.tiny.width, height: BADGE_CONFIGS.tiny.height, borderRadius: BADGE_CONFIGS.tiny.borderRadius, backgroundColor: typeStyles.backgroundColor }));
6935
+ return (React__default.createElement(View, { row: true, style: style },
6936
+ React__default.createElement(ProgressCircle, { progress: progressType, color: typeStyles.backgroundColor })));
6902
6937
  }
6903
6938
  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(Text$1, { size: finalTextSize, color: textColor || textColorStyle, style: [styles$8.textMedium, textStyle] }, value))));
6939
+ React__default.createElement(View, { row: true, center: true, borderRadius: 999, borderWidth: CONSTANTS.BORDER_WIDTH_1, style: [sizeStyles, typeStyles, style] },
6940
+ leftIcon && React__default.createElement(View, { paddingRight: CONSTANTS.SPACE_4 }, leftIcon),
6941
+ progressType !== "none" && (React__default.createElement(ProgressCircle, { progress: progressType, color: textColorStyle })),
6942
+ React__default.createElement(View, { paddingLeft: progressType !== "none" ? CONSTANTS.SPACE_4 : 0 },
6943
+ React__default.createElement(Text$1, { size: finalTextSize, color: textColor || textColorStyle, style: [styles$8.textMedium, textStyle] }, value)))));
6906
6944
  });
6907
6945
  Badge.displayName = "Badge";
6908
6946
  var styles$8 = StyleSheet.create(__assign({}, containerStyles));