From 8d375569ab4e68af8cb4078c52ae19acdacda794 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 14:41:07 +0200 Subject: [PATCH 1/6] fix(nui): Fix incorrect string typing and remove tsignore --- .../features/notifications/NotificationWrapper.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/web/src/features/notifications/NotificationWrapper.tsx b/web/src/features/notifications/NotificationWrapper.tsx index 77920df..2549031 100644 --- a/web/src/features/notifications/NotificationWrapper.tsx +++ b/web/src/features/notifications/NotificationWrapper.tsx @@ -63,13 +63,12 @@ const Notifications: React.FC = () => { useNuiEvent("customNotify", (data) => { if (data.id && toast.isActive(data.id)) return; if (!data.icon) { - //@ts-expect-error because amazing types data.icon = data.type === "error" - ? "fa-circle-xmark" + ? "circle-xmark" : data.type === "success" - ? "fa-circle-check" - : "fa-circle-info"; + ? "circle-check" + : "circle-info"; } toast({ @@ -84,15 +83,14 @@ const Notifications: React.FC = () => { boxShadow="md" > - { + {data.icon && ( - } + )} {data.title && {data.title}} {data.description && {data.description}} From 3d3a7075d26509a4bdda483ee4b14dddc3867552 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 14:51:28 +0200 Subject: [PATCH 2/6] fix(nui): Make description optional --- web/src/features/notifications/NotificationWrapper.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/features/notifications/NotificationWrapper.tsx b/web/src/features/notifications/NotificationWrapper.tsx index 2549031..97469e7 100644 --- a/web/src/features/notifications/NotificationWrapper.tsx +++ b/web/src/features/notifications/NotificationWrapper.tsx @@ -12,7 +12,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; interface Props { title?: string; - description: string; + description?: string; duration?: number; position?: ToastPositionWithLogical; status?: "info" | "warning" | "success" | "error"; @@ -21,7 +21,7 @@ interface Props { interface CustomProps { style?: React.CSSProperties; - description: string; + description?: string; title?: string; duration?: number; icon?: IconProp; @@ -47,7 +47,6 @@ debugData([ action: "customNotify", data: { description: "Dunak is nerd", - title: "Dunak", icon: "basket-shopping", style: { backgroundColor: "#2D3748", @@ -61,6 +60,7 @@ const Notifications: React.FC = () => { const toast = useToast(); useNuiEvent("customNotify", (data) => { + if (!data.title && !data.description) return; if (data.id && toast.isActive(data.id)) return; if (!data.icon) { data.icon = @@ -102,6 +102,7 @@ const Notifications: React.FC = () => { }); useNuiEvent("notify", (data) => { + if (!data.title && !data.description) return; if (data.id && toast.isActive(data.id)) return; toast({ title: data.title, From ff71a7d033be133b809cabef2934d0f9cdd63faa Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 15:26:10 +0200 Subject: [PATCH 3/6] feat(client): Input dialog function --- resource/interface/client/input.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 resource/interface/client/input.lua diff --git a/resource/interface/client/input.lua b/resource/interface/client/input.lua new file mode 100644 index 0000000..d1f03d0 --- /dev/null +++ b/resource/interface/client/input.lua @@ -0,0 +1,22 @@ +function lib.inputDialog(heading, rows) + if input then return end + input = promise.new() + + SetNuiFocus(true, true) + SendNUIMessage({ + action = 'openDialog', + data = { + heading = heading, + inputs = rows + } + }) + return Citizen.Await(input) +end + +RegisterNUICallback('inputData', function(data, cb) + cb(1) + if not input then return end + if not data then input:resolve() else input:resolve(data) end + SetNuiFocus(false, false) + input = nil +end) From ed75b683d5a39908c47f0946926f32dfe75fa780 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 15:59:18 +0200 Subject: [PATCH 4/6] feat(client): Text UI functions --- resource/interface/client/textui.lua | 14 ++++++++++++++ web/src/features/textui/TextUI.tsx | 1 + 2 files changed, 15 insertions(+) create mode 100644 resource/interface/client/textui.lua diff --git a/resource/interface/client/textui.lua b/resource/interface/client/textui.lua new file mode 100644 index 0000000..56bd3e2 --- /dev/null +++ b/resource/interface/client/textui.lua @@ -0,0 +1,14 @@ +function lib.showTextUI(text, options) + if not options then options = {} end + options.text = text + SendNUIMessage({ + action = 'textUi', + data = options + }) +end + +function lib.hideTextUI() + SendNUIMessage({ + action = 'textUiHide' + }) +end diff --git a/web/src/features/textui/TextUI.tsx b/web/src/features/textui/TextUI.tsx index 9e79bf2..90be1c6 100644 --- a/web/src/features/textui/TextUI.tsx +++ b/web/src/features/textui/TextUI.tsx @@ -33,6 +33,7 @@ const TextUI: React.FC = () => { const [visible, setVisible] = React.useState(false); useNuiEvent("textUi", (data) => { + if (!data.position) data.position = "right-center"; // Default right position setData(data); setVisible(true); }); From 128fb86954dd1ca99de14bc568149872f488c280 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 16:14:32 +0200 Subject: [PATCH 5/6] fix(client): Add missing NUI callbacks --- resource/interface/client/context.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resource/interface/client/context.lua b/resource/interface/client/context.lua index 5e0625b..0b64565 100644 --- a/resource/interface/client/context.lua +++ b/resource/interface/client/context.lua @@ -24,11 +24,13 @@ function lib.registerContext(context) end end -RegisterNUICallback('openContext', function(id) +RegisterNUICallback('openContext', function(id, cb) + cb(1) lib.showContext(id) end) -RegisterNUICallback('clickContext', function(data) +RegisterNUICallback('clickContext', function(data, cb) + cb(1) if data.event then TriggerEvent(data.event, data.args) end if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end SetNuiFocus(false, false) @@ -37,6 +39,7 @@ RegisterNUICallback('clickContext', function(data) }) end) -RegisterNUICallback('closeContext', function() +RegisterNUICallback('closeContext', function(_, cb) + cb(1) SetNuiFocus(false, false) end) From 7996e913dc07051a9fb9d768fd5e8aab8eb83d9b Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 12 Apr 2022 14:38:01 +0200 Subject: [PATCH 6/6] fix(nui): Update input dialog font --- web/src/features/dialog/InputDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/features/dialog/InputDialog.tsx b/web/src/features/dialog/InputDialog.tsx index 5a039b1..bcb437d 100644 --- a/web/src/features/dialog/InputDialog.tsx +++ b/web/src/features/dialog/InputDialog.tsx @@ -76,7 +76,7 @@ const InputDialog: React.FC = () => { {inputOptions.heading} - + {inputOptions.inputs.map((input: string, index: number) => ( {input}