UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

10 lines (7 loc) 1.15 kB
import toast, { useToasterStore } from 'react-hot-toast'; import { Toast } from './Toast.native.js'; import { logger } from '../../utils/logger/logger.js'; import { jsx } from 'react/jsx-runtime'; var useToast=function useToast(){var _useToasterStore=useToasterStore(),toasts=_useToasterStore.toasts;var show=function show(props){var _props$type;props.type=(_props$type=props.type)!=null?_props$type:'informational';if(toasts.find(function(t){return t.type==='promotional';})&&props.type==='promotional'){if(__DEV__){logger({message:'There can only be one promotional toast at a time',type:'warn',moduleName:'Toast'});}return '';}var isPromoToast=props.type==='promotional';if(props.autoDismiss===undefined){props.autoDismiss=!isPromoToast;}if(props.duration===undefined){if(isPromoToast){props.duration=8000;}else {props.duration=4000;}}if(!props.autoDismiss){props.duration=Infinity;}return toast.custom(function(_ref){var visible=_ref.visible,id=_ref.id;return jsx(Toast,Object.assign({},props,{id:id,isVisible:visible}));},props);};return {toasts:toasts,show:show,dismiss:toast.dismiss};}; export { useToast }; //# sourceMappingURL=useToast.js.map