Files
ox_lib/package/client/resource/interface/notify.ts

43 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Sx } from '@mantine/core';
2022-09-14 13:50:32 +02:00
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
2023-02-15 13:51:46 +01:00
type NotificationPosition =
| 'top'
| 'top-right'
| 'top-left'
| 'bottom'
| 'bottom-right'
| 'bottom-left'
| 'center-right'
| 'center-left';
2022-09-14 13:50:32 +02:00
type NotificationType = 'inform' | 'error' | 'success';
type IconAnimation = 'spin' | 'spinPulse' | 'spinReverse' | 'pulse' | 'beat' | 'fade' | 'beatFade' | 'bounce' | 'shake';
2022-09-14 13:50:32 +02:00
interface NotifyProps {
2023-02-15 13:51:46 +01:00
id?: string | number;
2022-09-14 13:50:32 +02:00
title?: string;
description?: string;
duration?: number;
position?: NotificationPosition;
type?: NotificationType;
style?: Sx;
2022-09-14 13:50:32 +02:00
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
iconAnimation?: IconAnimation;
alignIcon?: 'top' | 'center';
2022-09-14 13:50:32 +02:00
}
export const notify = (data: NotifyProps): void => exports.ox_lib.notify(data);
2023-02-15 13:51:46 +01:00
// Keep for backwards compat with v2
2022-09-14 13:50:32 +02:00
interface DefaultNotifyProps {
title?: string;
description?: string;
duration?: number;
position?: NotificationPosition;
status?: 'info' | 'warning' | 'success' | 'error';
2022-09-14 13:50:32 +02:00
id?: number;
}
export const defaultNotify = (data: DefaultNotifyProps): void => exports.ox_lib.defaultNotify(data);