@ramses-superapp/ramses-ui
Version:
Skinless UI primitives for Ramses Built Apps
42 lines (41 loc) • 980 B
JavaScript
;
import { forwardRef, useEffect } from 'react';
import { Text, View } from 'react-native';
import { jsx as _jsx } from "react/jsx-runtime";
const RsToast = /*#__PURE__*/forwardRef(({
visible,
message,
duration = 3000,
position = 'bottom',
onDismiss,
style
}, ref) => {
useEffect(() => {
if (visible && duration > 0 && onDismiss) {
const timer = setTimeout(onDismiss, duration);
return () => clearTimeout(timer);
}
return undefined;
}, [visible, duration, onDismiss]);
if (!visible) return null;
return /*#__PURE__*/_jsx(View, {
ref: ref,
style: [{
position: 'absolute',
left: 0,
right: 0,
...(position === 'top' ? {
top: 0
} : {
bottom: 0
})
}, style],
accessibilityRole: "alert",
children: /*#__PURE__*/_jsx(Text, {
children: message
})
});
});
RsToast.displayName = 'RsToast';
export default RsToast;
//# sourceMappingURL=RsToast.js.map