mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
Merge branch 'master' of https://github.com/overextended/ox_lib
This commit is contained in:
@@ -24,11 +24,13 @@ function lib.registerContext(context)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNUICallback('openContext', function(id)
|
RegisterNUICallback('openContext', function(id, cb)
|
||||||
|
cb(1)
|
||||||
lib.showContext(id)
|
lib.showContext(id)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNUICallback('clickContext', function(data)
|
RegisterNUICallback('clickContext', function(data, cb)
|
||||||
|
cb(1)
|
||||||
if data.event then TriggerEvent(data.event, data.args) end
|
if data.event then TriggerEvent(data.event, data.args) end
|
||||||
if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end
|
if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end
|
||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
@@ -37,6 +39,7 @@ RegisterNUICallback('clickContext', function(data)
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNUICallback('closeContext', function()
|
RegisterNUICallback('closeContext', function(_, cb)
|
||||||
|
cb(1)
|
||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
end)
|
end)
|
||||||
|
|||||||
22
resource/interface/client/input.lua
Normal file
22
resource/interface/client/input.lua
Normal file
@@ -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)
|
||||||
14
resource/interface/client/textui.lua
Normal file
14
resource/interface/client/textui.lua
Normal file
@@ -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
|
||||||
@@ -76,7 +76,7 @@ const InputDialog: React.FC = () => {
|
|||||||
<ModalOverlay />
|
<ModalOverlay />
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ModalHeader textAlign="center">{inputOptions.heading}</ModalHeader>
|
<ModalHeader textAlign="center">{inputOptions.heading}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody fontFamily="Poppins">
|
||||||
{inputOptions.inputs.map((input: string, index: number) => (
|
{inputOptions.inputs.map((input: string, index: number) => (
|
||||||
<Box mb={3} key={`input-${index}`}>
|
<Box mb={3} key={`input-${index}`}>
|
||||||
<Text>{input}</Text>
|
<Text>{input}</Text>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title?: string;
|
title?: string;
|
||||||
description: string;
|
description?: string;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
position?: ToastPositionWithLogical;
|
position?: ToastPositionWithLogical;
|
||||||
status?: "info" | "warning" | "success" | "error";
|
status?: "info" | "warning" | "success" | "error";
|
||||||
@@ -21,7 +21,7 @@ interface Props {
|
|||||||
|
|
||||||
interface CustomProps {
|
interface CustomProps {
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
description: string;
|
description?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
icon?: IconProp;
|
icon?: IconProp;
|
||||||
@@ -47,7 +47,6 @@ debugData<CustomProps>([
|
|||||||
action: "customNotify",
|
action: "customNotify",
|
||||||
data: {
|
data: {
|
||||||
description: "Dunak is nerd",
|
description: "Dunak is nerd",
|
||||||
title: "Dunak",
|
|
||||||
icon: "basket-shopping",
|
icon: "basket-shopping",
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: "#2D3748",
|
backgroundColor: "#2D3748",
|
||||||
@@ -61,15 +60,15 @@ const Notifications: React.FC = () => {
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
useNuiEvent<CustomProps>("customNotify", (data) => {
|
useNuiEvent<CustomProps>("customNotify", (data) => {
|
||||||
|
if (!data.title && !data.description) return;
|
||||||
if (data.id && toast.isActive(data.id)) return;
|
if (data.id && toast.isActive(data.id)) return;
|
||||||
if (!data.icon) {
|
if (!data.icon) {
|
||||||
//@ts-expect-error because amazing types
|
|
||||||
data.icon =
|
data.icon =
|
||||||
data.type === "error"
|
data.type === "error"
|
||||||
? "fa-circle-xmark"
|
? "circle-xmark"
|
||||||
: data.type === "success"
|
: data.type === "success"
|
||||||
? "fa-circle-check"
|
? "circle-check"
|
||||||
: "fa-circle-info";
|
: "circle-info";
|
||||||
}
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
@@ -84,15 +83,14 @@ const Notifications: React.FC = () => {
|
|||||||
boxShadow="md"
|
boxShadow="md"
|
||||||
>
|
>
|
||||||
<HStack spacing={0}>
|
<HStack spacing={0}>
|
||||||
{
|
{data.icon && (
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
//@ts-expect-error because amazing types
|
|
||||||
icon={data.icon}
|
icon={data.icon}
|
||||||
fontSize="1.3em"
|
fontSize="1.3em"
|
||||||
style={{ paddingRight: 8 }}
|
style={{ paddingRight: 8 }}
|
||||||
color={data.iconColor}
|
color={data.iconColor}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
<Box w="100%">
|
<Box w="100%">
|
||||||
{data.title && <Text as="b">{data.title}</Text>}
|
{data.title && <Text as="b">{data.title}</Text>}
|
||||||
{data.description && <Text>{data.description}</Text>}
|
{data.description && <Text>{data.description}</Text>}
|
||||||
@@ -104,6 +102,7 @@ const Notifications: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useNuiEvent<Props>("notify", (data) => {
|
useNuiEvent<Props>("notify", (data) => {
|
||||||
|
if (!data.title && !data.description) return;
|
||||||
if (data.id && toast.isActive(data.id)) return;
|
if (data.id && toast.isActive(data.id)) return;
|
||||||
toast({
|
toast({
|
||||||
title: data.title,
|
title: data.title,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const TextUI: React.FC = () => {
|
|||||||
const [visible, setVisible] = React.useState(false);
|
const [visible, setVisible] = React.useState(false);
|
||||||
|
|
||||||
useNuiEvent<Props>("textUi", (data) => {
|
useNuiEvent<Props>("textUi", (data) => {
|
||||||
|
if (!data.position) data.position = "right-center"; // Default right position
|
||||||
setData(data);
|
setData(data);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user