dhre-ui-kit 0.0.264 → 0.0.266
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 +4 -4
- package/lib/index.js +92 -87
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +92 -87
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -373,14 +373,14 @@ interface ToastProps {
|
|
|
373
373
|
errorIcon: React$1.ReactElement;
|
|
374
374
|
}
|
|
375
375
|
interface ToastRef {
|
|
376
|
-
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null) => void;
|
|
376
|
+
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null, height?: number) => void;
|
|
377
377
|
}
|
|
378
378
|
interface ToastRef {
|
|
379
|
-
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null) => void;
|
|
379
|
+
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null, height?: number) => void;
|
|
380
380
|
}
|
|
381
381
|
interface ToastServiceInterface {
|
|
382
382
|
setRef: (ref: ToastRef | null) => void;
|
|
383
|
-
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null) => void;
|
|
383
|
+
showToast: (message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null, height?: number) => void;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
declare const Toast: React$1.ForwardRefExoticComponent<ToastProps & React$1.RefAttributes<ToastRef>>;
|
|
@@ -665,7 +665,7 @@ declare const CustomSwitchBtn: ({ value, onValueChange, disabled, activeText, ac
|
|
|
665
665
|
declare class ToastService implements ToastServiceInterface {
|
|
666
666
|
private toastRef;
|
|
667
667
|
setRef(ref: ToastRef | null): void;
|
|
668
|
-
showToast(message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null): void;
|
|
668
|
+
showToast(message: string, duration?: number, isSuccess?: boolean, buttonText?: string | null, buttonAction?: (() => void) | null, height?: number): void;
|
|
669
669
|
}
|
|
670
670
|
declare const toastService: ToastService;
|
|
671
671
|
|
package/lib/index.js
CHANGED
|
@@ -2078,7 +2078,6 @@ const styles$l = reactNative.StyleSheet.create({
|
|
|
2078
2078
|
container: {
|
|
2079
2079
|
position: "absolute",
|
|
2080
2080
|
alignSelf: "center",
|
|
2081
|
-
height: verticalScale(80),
|
|
2082
2081
|
width: width - horizontalScale(32),
|
|
2083
2082
|
top: 56,
|
|
2084
2083
|
borderRadius: moderateScale(8),
|
|
@@ -2108,97 +2107,102 @@ const styles$l = reactNative.StyleSheet.create({
|
|
|
2108
2107
|
}
|
|
2109
2108
|
});
|
|
2110
2109
|
|
|
2111
|
-
const Toast = React__default["default"].forwardRef(
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
showToast
|
|
2156
|
-
}));
|
|
2157
|
-
return visible ? /* @__PURE__ */ React__default["default"].createElement(
|
|
2158
|
-
reactNative.Animated.View,
|
|
2159
|
-
{
|
|
2160
|
-
style: [
|
|
2161
|
-
styles$l.container,
|
|
2162
|
-
{ bottom },
|
|
2163
|
-
{ backgroundColor: isSuccess ? "#00B578" : "#EB0542" }
|
|
2164
|
-
],
|
|
2165
|
-
testID: "TOAST"
|
|
2166
|
-
},
|
|
2167
|
-
/* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$l.toastContainer }, /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$l.innerContainer }, /* @__PURE__ */ React__default["default"].createElement(reactNative.Pressable, { onPress: hideToast }, isSuccess ? sucessIcon : errorIcon), /* @__PURE__ */ React__default["default"].createElement(
|
|
2168
|
-
CustomTypography,
|
|
2169
|
-
{
|
|
2170
|
-
variant: "L2_REGULAR",
|
|
2171
|
-
text: message,
|
|
2172
|
-
style: styles$l.messageText
|
|
2110
|
+
const Toast = React__default["default"].forwardRef(
|
|
2111
|
+
({ sucessIcon, errorIcon }, ref) => {
|
|
2112
|
+
const [visible, setVisible] = React.useState(false);
|
|
2113
|
+
const [message, setMessage] = React.useState("");
|
|
2114
|
+
const [isSuccess, setIsSuccess] = React.useState(true);
|
|
2115
|
+
const [btnText, setBtnText] = React.useState(null);
|
|
2116
|
+
const [onBtnPress, setOnBtnPress] = React.useState(null);
|
|
2117
|
+
const [progress, setProgress] = React.useState(0);
|
|
2118
|
+
const [height, setHeight] = React.useState(72);
|
|
2119
|
+
const bottom = React.useRef(new reactNative.Animated.Value(-80)).current;
|
|
2120
|
+
const showToast = (toastMessage, duration = 3e3, success = true, buttonText = null, buttonAction = null, height2 = 72) => {
|
|
2121
|
+
setMessage(toastMessage);
|
|
2122
|
+
setIsSuccess(success);
|
|
2123
|
+
setBtnText(buttonText);
|
|
2124
|
+
setOnBtnPress(() => buttonAction);
|
|
2125
|
+
setVisible(true);
|
|
2126
|
+
setHeight(height2);
|
|
2127
|
+
reactNative.Animated.timing(bottom, {
|
|
2128
|
+
toValue: 20,
|
|
2129
|
+
duration: 500,
|
|
2130
|
+
useNativeDriver: false
|
|
2131
|
+
}).start();
|
|
2132
|
+
setTimeout(() => {
|
|
2133
|
+
hideToast();
|
|
2134
|
+
}, duration);
|
|
2135
|
+
};
|
|
2136
|
+
const hideToast = () => {
|
|
2137
|
+
reactNative.Animated.timing(bottom, {
|
|
2138
|
+
toValue: -80,
|
|
2139
|
+
duration: 500,
|
|
2140
|
+
useNativeDriver: false
|
|
2141
|
+
}).start(() => {
|
|
2142
|
+
setVisible(false);
|
|
2143
|
+
setMessage("");
|
|
2144
|
+
});
|
|
2145
|
+
};
|
|
2146
|
+
const simulateProgress = () => {
|
|
2147
|
+
setProgress((prev) => prev + 0.1 > 1 ? 1 : prev + 0.1);
|
|
2148
|
+
};
|
|
2149
|
+
React.useEffect(() => {
|
|
2150
|
+
if (visible) {
|
|
2151
|
+
setProgress(0);
|
|
2152
|
+
const interval = setInterval(simulateProgress, 180);
|
|
2153
|
+
return () => clearInterval(interval);
|
|
2173
2154
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2155
|
+
}, [visible]);
|
|
2156
|
+
React__default["default"].useImperativeHandle(ref, () => ({
|
|
2157
|
+
showToast
|
|
2158
|
+
}));
|
|
2159
|
+
return visible ? /* @__PURE__ */ React__default["default"].createElement(
|
|
2160
|
+
reactNative.Animated.View,
|
|
2176
2161
|
{
|
|
2177
|
-
style:
|
|
2178
|
-
|
|
2179
|
-
|
|
2162
|
+
style: [
|
|
2163
|
+
styles$l.container,
|
|
2164
|
+
{ bottom },
|
|
2165
|
+
{ backgroundColor: isSuccess ? "#00B578" : "#EB0542" },
|
|
2166
|
+
{ height: verticalScale(height) }
|
|
2167
|
+
],
|
|
2168
|
+
testID: "TOAST"
|
|
2180
2169
|
},
|
|
2181
|
-
/* @__PURE__ */ React__default["default"].createElement(
|
|
2170
|
+
/* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$l.toastContainer }, /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: styles$l.innerContainer }, /* @__PURE__ */ React__default["default"].createElement(reactNative.Pressable, { onPress: hideToast }, isSuccess ? sucessIcon : errorIcon), /* @__PURE__ */ React__default["default"].createElement(
|
|
2182
2171
|
CustomTypography,
|
|
2183
2172
|
{
|
|
2184
|
-
variant: "
|
|
2185
|
-
text:
|
|
2186
|
-
style: styles$l.
|
|
2173
|
+
variant: "L2_REGULAR",
|
|
2174
|
+
text: message,
|
|
2175
|
+
style: styles$l.messageText
|
|
2176
|
+
}
|
|
2177
|
+
), btnText && /* @__PURE__ */ React__default["default"].createElement(
|
|
2178
|
+
reactNative.Pressable,
|
|
2179
|
+
{
|
|
2180
|
+
style: styles$l.button,
|
|
2181
|
+
onPress: onBtnPress || void 0,
|
|
2182
|
+
testID: "TOAST-BTN"
|
|
2183
|
+
},
|
|
2184
|
+
/* @__PURE__ */ React__default["default"].createElement(
|
|
2185
|
+
CustomTypography,
|
|
2186
|
+
{
|
|
2187
|
+
variant: "L2_BOLD",
|
|
2188
|
+
text: btnText,
|
|
2189
|
+
style: styles$l.buttonText
|
|
2190
|
+
}
|
|
2191
|
+
)
|
|
2192
|
+
))),
|
|
2193
|
+
/* @__PURE__ */ React__default["default"].createElement(
|
|
2194
|
+
Progress__namespace.Bar,
|
|
2195
|
+
{
|
|
2196
|
+
progress,
|
|
2197
|
+
width: width - horizontalScale(48),
|
|
2198
|
+
height: 3,
|
|
2199
|
+
color: isSuccess ? "#024324" : "#851D41",
|
|
2200
|
+
borderColor: "transparent"
|
|
2187
2201
|
}
|
|
2188
2202
|
)
|
|
2189
|
-
)
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
{
|
|
2193
|
-
progress,
|
|
2194
|
-
width: width - horizontalScale(48),
|
|
2195
|
-
height: 3,
|
|
2196
|
-
color: isSuccess ? "#024324" : "#851D41",
|
|
2197
|
-
borderColor: "transparent"
|
|
2198
|
-
}
|
|
2199
|
-
)
|
|
2200
|
-
) : null;
|
|
2201
|
-
});
|
|
2203
|
+
) : null;
|
|
2204
|
+
}
|
|
2205
|
+
);
|
|
2202
2206
|
Toast.displayName = "Toast";
|
|
2203
2207
|
|
|
2204
2208
|
const styles$k = reactNative.StyleSheet.create({
|
|
@@ -3743,14 +3747,15 @@ class ToastService {
|
|
|
3743
3747
|
setRef(ref) {
|
|
3744
3748
|
this.toastRef = ref;
|
|
3745
3749
|
}
|
|
3746
|
-
showToast(message, duration = 3e3, isSuccess = true, buttonText = null, buttonAction = null) {
|
|
3750
|
+
showToast(message, duration = 3e3, isSuccess = true, buttonText = null, buttonAction = null, height = 72) {
|
|
3747
3751
|
if (this.toastRef) {
|
|
3748
3752
|
this.toastRef.showToast(
|
|
3749
3753
|
message,
|
|
3750
3754
|
duration,
|
|
3751
3755
|
isSuccess,
|
|
3752
3756
|
buttonText,
|
|
3753
|
-
buttonAction
|
|
3757
|
+
buttonAction,
|
|
3758
|
+
height
|
|
3754
3759
|
);
|
|
3755
3760
|
}
|
|
3756
3761
|
}
|