g-notification
Version:
A flexible and customizable React notification/toast component with TypeScript support
43 lines (40 loc) • 1.33 kB
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
import React, { ReactNode } from 'react';
type Toast = {
id: number;
icon?: React.ReactNode;
title?: string;
content: string;
duration?: number;
type?: "success" | "danger" | "warning" | "info" | "custom";
style?: React.CSSProperties;
cssAnimation?: {
animationName: string;
animationDuration?: string;
keyframes: string;
};
closeButton?: boolean;
closeButtonContent?: React.ReactNode;
onClick?: () => void;
onPress?: () => void;
link?: string;
persistent?: boolean;
customRender?: (props: {
close: () => void;
}) => React.ReactNode;
_pressTimeout?: ReturnType<typeof setTimeout>;
};
type GToastFn = (toast: Omit<Toast, "id">) => void;
interface GNotificationProviderProps {
children: ReactNode;
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
maxVisibleNotification?: number;
zIndex?: number;
progressBar?: boolean;
}
declare const GNotificationProvider: ({ children, position, maxVisibleNotification, zIndex, progressBar }: GNotificationProviderProps) => react_jsx_runtime.JSX.Element;
declare const useGNotification: () => {
g_toast: GToastFn;
};
export { GNotificationProvider, useGNotification };
export type { Toast };