@momo-kits/foundation 0.152.4-beta.4 → 0.152.4-beta.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/Application/types.ts +2 -0
- package/Layout/SnackBar.tsx +16 -0
- package/package.json +1 -1
package/Application/types.ts
CHANGED
|
@@ -19,10 +19,12 @@ export type SnackBarCustom = {
|
|
|
19
19
|
type: 'custom';
|
|
20
20
|
content: () => React.ReactNode;
|
|
21
21
|
heightContent?: number;
|
|
22
|
+
duration?: number;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export type SnackBarToast = {
|
|
25
26
|
type: 'toast';
|
|
27
|
+
duration?: number;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export type SnackBar = SnackBarCustom | SnackBarToast;
|
package/Layout/SnackBar.tsx
CHANGED
|
@@ -82,6 +82,22 @@ export const useScreenSnackBar = ({
|
|
|
82
82
|
[animateSnackBar],
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
+
const navigatorRef = useRef(navigator);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
navigatorRef.current = navigator;
|
|
89
|
+
}, [navigator]);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!snackBarConfig?.duration) return;
|
|
93
|
+
|
|
94
|
+
const timer = setTimeout(() => {
|
|
95
|
+
navigatorRef.current?.hideSnackBar();
|
|
96
|
+
}, snackBarConfig.duration);
|
|
97
|
+
|
|
98
|
+
return () => clearTimeout(timer);
|
|
99
|
+
}, [snackBarConfig?.duration]);
|
|
100
|
+
|
|
85
101
|
useEffect(() => {
|
|
86
102
|
navigator?.setSnackBarHost?.({
|
|
87
103
|
show: showSnackBar,
|