2023-01-11 20:38:58 +01:00
|
|
|
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
2023-07-31 16:29:27 +10:00
|
|
|
---@alias NotificationType 'info' | 'warning' | 'success' | 'error'
|
2024-02-17 11:09:26 +00:00
|
|
|
---@alias IconAnimationType 'spin' | 'spinPulse' | 'spinReverse' | 'pulse' | 'beat' | 'fade' | 'beatFade' | 'bounce' | 'shake'
|
2022-04-16 12:03:50 +02:00
|
|
|
|
2022-09-18 09:06:32 +10:00
|
|
|
---@class NotifyProps
|
|
|
|
|
---@field id? string
|
|
|
|
|
---@field title? string
|
|
|
|
|
---@field description? string
|
|
|
|
|
---@field duration? number
|
|
|
|
|
---@field position? NotificationPosition
|
|
|
|
|
---@field type? NotificationType
|
2022-10-02 20:19:35 +11:00
|
|
|
---@field style? { [string]: any }
|
2023-03-10 19:38:34 +00:00
|
|
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
2024-02-17 11:09:26 +00:00
|
|
|
---@field iconAnimation? IconAnimationType;
|
2022-09-18 09:06:32 +10:00
|
|
|
---@field iconColor? string;
|
2023-11-15 14:30:33 +01:00
|
|
|
---@field alignIcon? 'top' | 'center';
|
2022-09-18 09:06:32 +10:00
|
|
|
|
2023-07-31 16:29:27 +10:00
|
|
|
---`client`
|
2022-09-18 09:06:32 +10:00
|
|
|
---@param data NotifyProps
|
2023-07-31 16:29:27 +10:00
|
|
|
---@diagnostic disable-next-line: duplicate-set-field
|
2022-04-11 03:52:18 +00:00
|
|
|
function lib.notify(data)
|
2022-09-18 09:06:32 +10:00
|
|
|
SendNUIMessage({
|
2023-01-11 20:38:58 +01:00
|
|
|
action = 'notify',
|
2022-09-18 09:06:32 +10:00
|
|
|
data = data
|
|
|
|
|
})
|
2022-04-11 03:52:18 +00:00
|
|
|
end
|
2022-04-11 04:59:21 +00:00
|
|
|
|
2022-09-18 09:06:32 +10:00
|
|
|
---@class DefaultNotifyProps
|
|
|
|
|
---@field title? string
|
|
|
|
|
---@field description? string
|
|
|
|
|
---@field duration? number
|
|
|
|
|
---@field position? NotificationPosition
|
|
|
|
|
---@field status? 'info' | 'warning' | 'success' | 'error'
|
|
|
|
|
---@field id? number
|
|
|
|
|
|
|
|
|
|
---@param data DefaultNotifyProps
|
2022-04-16 12:03:50 +02:00
|
|
|
function lib.defaultNotify(data)
|
2023-07-21 04:54:29 -07:00
|
|
|
-- Backwards compat for v3
|
2023-01-11 20:38:58 +01:00
|
|
|
data.type = data.status
|
2023-05-01 12:08:02 +02:00
|
|
|
if data.type == 'inform' then data.type = 'info' end
|
2023-07-31 16:29:27 +10:00
|
|
|
return lib.notify(data --[[@as NotifyProps]])
|
2022-04-16 12:03:50 +02:00
|
|
|
end
|
|
|
|
|
|
2022-04-11 04:59:21 +00:00
|
|
|
RegisterNetEvent('ox_lib:notify', lib.notify)
|
2023-07-21 04:54:29 -07:00
|
|
|
RegisterNetEvent('ox_lib:defaultNotify', lib.defaultNotify)
|