dhre-ui-kit 0.0.263 → 0.0.264
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/lib/index.d.ts +0 -1
- package/lib/index.js +85 -88
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +85 -88
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -2042,7 +2042,7 @@ const styles$l = StyleSheet.create({
|
|
|
2042
2042
|
container: {
|
|
2043
2043
|
position: "absolute",
|
|
2044
2044
|
alignSelf: "center",
|
|
2045
|
-
height: verticalScale(
|
|
2045
|
+
height: verticalScale(80),
|
|
2046
2046
|
width: width - horizontalScale(32),
|
|
2047
2047
|
top: 56,
|
|
2048
2048
|
borderRadius: moderateScale(8),
|
|
@@ -2072,100 +2072,97 @@ const styles$l = StyleSheet.create({
|
|
|
2072
2072
|
}
|
|
2073
2073
|
});
|
|
2074
2074
|
|
|
2075
|
-
const Toast = React.forwardRef(
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2075
|
+
const Toast = React.forwardRef(({ sucessIcon, errorIcon }, ref) => {
|
|
2076
|
+
const [visible, setVisible] = useState(false);
|
|
2077
|
+
const [message, setMessage] = useState("");
|
|
2078
|
+
const [isSuccess, setIsSuccess] = useState(true);
|
|
2079
|
+
const [btnText, setBtnText] = useState(null);
|
|
2080
|
+
const [onBtnPress, setOnBtnPress] = useState(null);
|
|
2081
|
+
const [progress, setProgress] = useState(0);
|
|
2082
|
+
const bottom = useRef(new Animated.Value(-80)).current;
|
|
2083
|
+
const showToast = (toastMessage, duration = 3e3, success = true, buttonText = null, buttonAction = null) => {
|
|
2084
|
+
setMessage(toastMessage);
|
|
2085
|
+
setIsSuccess(success);
|
|
2086
|
+
setBtnText(buttonText);
|
|
2087
|
+
setOnBtnPress(() => buttonAction);
|
|
2088
|
+
setVisible(true);
|
|
2089
|
+
Animated.timing(bottom, {
|
|
2090
|
+
toValue: 20,
|
|
2091
|
+
duration: 500,
|
|
2092
|
+
useNativeDriver: false
|
|
2093
|
+
}).start();
|
|
2094
|
+
setTimeout(() => {
|
|
2095
|
+
hideToast();
|
|
2096
|
+
}, duration);
|
|
2097
|
+
};
|
|
2098
|
+
const hideToast = () => {
|
|
2099
|
+
Animated.timing(bottom, {
|
|
2100
|
+
toValue: -80,
|
|
2101
|
+
duration: 500,
|
|
2102
|
+
useNativeDriver: false
|
|
2103
|
+
}).start(() => {
|
|
2104
|
+
setVisible(false);
|
|
2105
|
+
setMessage("");
|
|
2106
|
+
});
|
|
2107
|
+
};
|
|
2108
|
+
const simulateProgress = () => {
|
|
2109
|
+
setProgress((prev) => prev + 0.1 > 1 ? 1 : prev + 0.1);
|
|
2110
|
+
};
|
|
2111
|
+
useEffect(() => {
|
|
2112
|
+
if (visible) {
|
|
2113
|
+
setProgress(0);
|
|
2114
|
+
const interval = setInterval(simulateProgress, 180);
|
|
2115
|
+
return () => clearInterval(interval);
|
|
2116
|
+
}
|
|
2117
|
+
}, [visible]);
|
|
2118
|
+
React.useImperativeHandle(ref, () => ({
|
|
2119
|
+
showToast
|
|
2120
|
+
}));
|
|
2121
|
+
return visible ? /* @__PURE__ */ React.createElement(
|
|
2122
|
+
Animated.View,
|
|
2123
|
+
{
|
|
2124
|
+
style: [
|
|
2125
|
+
styles$l.container,
|
|
2126
|
+
{ bottom },
|
|
2127
|
+
{ backgroundColor: isSuccess ? "#00B578" : "#EB0542" }
|
|
2128
|
+
],
|
|
2129
|
+
testID: "TOAST"
|
|
2130
|
+
},
|
|
2131
|
+
/* @__PURE__ */ React.createElement(View, { style: styles$l.toastContainer }, /* @__PURE__ */ React.createElement(View, { style: styles$l.innerContainer }, /* @__PURE__ */ React.createElement(Pressable, { onPress: hideToast }, isSuccess ? sucessIcon : errorIcon), /* @__PURE__ */ React.createElement(
|
|
2132
|
+
CustomTypography,
|
|
2133
|
+
{
|
|
2134
|
+
variant: "L2_REGULAR",
|
|
2135
|
+
text: message,
|
|
2136
|
+
style: styles$l.messageText
|
|
2117
2137
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
showToast
|
|
2121
|
-
}));
|
|
2122
|
-
return visible ? /* @__PURE__ */ React.createElement(
|
|
2123
|
-
Animated.View,
|
|
2138
|
+
), btnText && /* @__PURE__ */ React.createElement(
|
|
2139
|
+
Pressable,
|
|
2124
2140
|
{
|
|
2125
|
-
style:
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
{ backgroundColor: isSuccess ? "#00B578" : "#EB0542" },
|
|
2129
|
-
containerStyle
|
|
2130
|
-
],
|
|
2131
|
-
testID: "TOAST"
|
|
2141
|
+
style: styles$l.button,
|
|
2142
|
+
onPress: onBtnPress || void 0,
|
|
2143
|
+
testID: "TOAST-BTN"
|
|
2132
2144
|
},
|
|
2133
|
-
/* @__PURE__ */ React.createElement(View, { style: styles$l.toastContainer }, /* @__PURE__ */ React.createElement(View, { style: styles$l.innerContainer }, /* @__PURE__ */ React.createElement(Pressable, { onPress: hideToast }, isSuccess ? sucessIcon : errorIcon), /* @__PURE__ */ React.createElement(
|
|
2134
|
-
CustomTypography,
|
|
2135
|
-
{
|
|
2136
|
-
variant: "L2_REGULAR",
|
|
2137
|
-
text: message,
|
|
2138
|
-
style: styles$l.messageText
|
|
2139
|
-
}
|
|
2140
|
-
), btnText && /* @__PURE__ */ React.createElement(
|
|
2141
|
-
Pressable,
|
|
2142
|
-
{
|
|
2143
|
-
style: styles$l.button,
|
|
2144
|
-
onPress: onBtnPress || void 0,
|
|
2145
|
-
testID: "TOAST-BTN"
|
|
2146
|
-
},
|
|
2147
|
-
/* @__PURE__ */ React.createElement(
|
|
2148
|
-
CustomTypography,
|
|
2149
|
-
{
|
|
2150
|
-
variant: "L2_BOLD",
|
|
2151
|
-
text: btnText,
|
|
2152
|
-
style: styles$l.buttonText
|
|
2153
|
-
}
|
|
2154
|
-
)
|
|
2155
|
-
))),
|
|
2156
2145
|
/* @__PURE__ */ React.createElement(
|
|
2157
|
-
|
|
2146
|
+
CustomTypography,
|
|
2158
2147
|
{
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
color: isSuccess ? "#024324" : "#851D41",
|
|
2163
|
-
borderColor: "transparent"
|
|
2148
|
+
variant: "L2_BOLD",
|
|
2149
|
+
text: btnText,
|
|
2150
|
+
style: styles$l.buttonText
|
|
2164
2151
|
}
|
|
2165
2152
|
)
|
|
2166
|
-
)
|
|
2167
|
-
|
|
2168
|
-
|
|
2153
|
+
))),
|
|
2154
|
+
/* @__PURE__ */ React.createElement(
|
|
2155
|
+
Progress.Bar,
|
|
2156
|
+
{
|
|
2157
|
+
progress,
|
|
2158
|
+
width: width - horizontalScale(48),
|
|
2159
|
+
height: 3,
|
|
2160
|
+
color: isSuccess ? "#024324" : "#851D41",
|
|
2161
|
+
borderColor: "transparent"
|
|
2162
|
+
}
|
|
2163
|
+
)
|
|
2164
|
+
) : null;
|
|
2165
|
+
});
|
|
2169
2166
|
Toast.displayName = "Toast";
|
|
2170
2167
|
|
|
2171
2168
|
const styles$k = StyleSheet.create({
|