design-react-kit
Version:
Componenti React per Bootstrap 5
18 lines • 801 B
JavaScript
import { isValidElement } from 'react';
import { toast } from 'react-toastify';
import { createNotification } from './NotificationContent';
export function notify(title, bodyOrOptions, options) {
const body = isReactNode(bodyOrOptions) ? bodyOrOptions : undefined;
const safeOptions = isReactNode(bodyOrOptions) ? { ...options } : bodyOrOptions || {};
const NotificationContent = createNotification(title, body, safeOptions);
const internalOptions = {
...safeOptions,
autoClose: safeOptions.duration
};
return toast(NotificationContent, internalOptions);
}
function isReactNode(el) {
return el != null && (typeof el === 'string' || typeof el === 'number' || isValidElement(el));
}
notify.dismiss = (id) => toast.dismiss(id);
//# sourceMappingURL=core.js.map