feat(package): interface definitions

This commit is contained in:
Luke
2022-09-14 13:50:32 +02:00
parent 863ac03ca3
commit 4f0cc4c7c5
17 changed files with 355 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
export * from './interface/alert';
export * from './interface/clipboard';
export * from './interface/context';
export * from './interface/input';
export * from './interface/menu';
export * from './interface/notify';
export * from './interface/progress';
export * from './interface/textui';

View File

@@ -0,0 +1,10 @@
interface AlertDialogProps {
header: string;
content: string;
centered?: boolean;
cancel?: boolean;
}
type alertDialog = (data: AlertDialogProps) => Promise<'cancel' | 'confirm'>;
export const alertDialog: alertDialog = async (data) => await exports.ox_lib.alertDialog(data);

View File

@@ -0,0 +1 @@
export const setClipboard = (value: string) => exports.ox_lib.setClipboard(value);

View File

@@ -0,0 +1,36 @@
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
interface ContextMenuItem {
menu?: string;
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
onSelect?: () => void;
arrow?: boolean;
description?: boolean;
metadata?: string | { [key: string]: any } | string[];
event?: string;
serverEvent?: string;
args?: any;
}
interface ContextMenuArrayItem extends ContextMenuItem {
title: string;
}
interface ContextMenuProps {
id: string;
title: string;
menu?: string;
onExit?: () => void;
canClose?: boolean;
options: { [key: string]: ContextMenuItem } | ContextMenuArrayItem[];
}
type registerContext = (context: ContextMenuProps) => void;
export const registerContext: registerContext = (context) => exports.ox_lib.registerContext(context);
export const showContext = (id: string): void => exports.ox_lib.showContext(id);
export const hideContext = (onExit: boolean): void => exports.ox_lib.hideContext(onExit);
export const getOpenContextMenu = (): string | null => exports.ox_lib.getOpenContextMenu();

View File

@@ -0,0 +1,22 @@
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
interface InputDialogRowProps {
type: 'input' | 'number' | 'checkbox' | 'select' | 'slider';
label: string;
options?: { value: string; label: string; default?: string }[];
password?: boolean;
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
placeholder?: string;
default?: string | number;
checked?: boolean;
min?: number;
max?: number;
step?: number;
}
type inputDialog = (
heading: string,
rows: string[] | InputDialogRowProps[]
) => Promise<Array<string | number | boolean> | undefined>;
export const inputDialog: inputDialog = async (heading, rows) => await exports.ox_lib.inputDialog(heading, rows);

View File

@@ -0,0 +1,36 @@
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
type MenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
type ChangeFunction = (selected: number, scrollIndex: number | null, args: any | null) => void;
interface MenuOptions {
label: string;
icon?: IconName | [IconPrefix, IconName];
values?: string[];
description?: string;
defaultIndex?: number;
args?: any;
}
interface MenuProps {
id: string;
title: string;
options: MenuOptions[];
position?: MenuPosition;
disableInput?: boolean;
onClose?: () => void;
onSelected?: ChangeFunction;
onSideScroll?: ChangeFunction;
}
type registerMenu = (data: MenuProps, cb: ChangeFunction) => void;
export const registerMenu: registerMenu = (data, cb) => exports.ox_lib.registerMenu(data, cb);
export const showMenu = (id: string): string => exports.ox_lib.showMenu(id);
export const hideMenu = (onExit: boolean): void => exports.ox_lib.hideMenu(onExit);
export const getOpenMenu = (): string | null => exports.ox_lib.getOpenMenu();
type setMenuOptions = (id: string, options: MenuOptions | MenuOptions[], index?: number) => void;
export const setMenuOptions: setMenuOptions = (id, options, index) => exports.ox_lib.setMenuOptions(id, options, index);

View File

@@ -0,0 +1,30 @@
import { CSSProperties } from 'react';
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
type NotificationPosition = 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left';
type NotificationType = 'inform' | 'error' | 'success';
interface NotifyProps {
id?: string;
title?: string;
description?: string;
duration?: number;
position?: NotificationPosition;
type: NotificationType;
style?: CSSProperties;
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
}
export const notify = (data: NotifyProps): void => exports.ox_lib.notify(data);
interface DefaultNotifyProps {
title?: string;
description?: string;
duration?: number;
position?: NotificationPosition;
status: 'info' | 'warning' | 'success' | 'error';
id?: number;
}
export const defaultNotify = (data: DefaultNotifyProps): void => exports.ox_lib.defaultNotify(data);

View File

@@ -0,0 +1,54 @@
type Position = {
x: number;
y: number;
z: number;
};
interface PropProps {
model: string;
bone?: number;
pos: Position;
rot: Position;
}
interface ProgressProps {
duration: number;
useWhileDead?: boolean;
allowRagdoll?: boolean;
allowCuffed?: boolean;
allowFalling?: boolean;
canCancel?: boolean;
anim?: {
dict?: string;
clip: string;
flag?: number;
blendIn?: number;
blendOut?: number;
duration?: number;
playbackRate?: number;
lockX?: boolean;
lockY?: boolean;
lockZ?: boolean;
scenario?: string;
playEnter?: boolean;
};
prop?: PropProps | PropProps[];
disable?: {
move?: boolean;
car?: boolean;
combat?: boolean;
mouse?: boolean;
};
}
interface ProgressbarProps extends ProgressProps {
label: string;
}
export const progressBar = async (data: ProgressbarProps): Promise<boolean> => exports.ox_lib.progressBar(data);
export const progressCircle = async (data: ProgressProps): Promise<boolean> => exports.ox_lib.progressCircle(data);
export const progressActive = (): boolean => exports.ox_lib.progressActive();
export const cancelProgress = (): void => exports.ox_lib.cancelProgress();

View File

@@ -0,0 +1,12 @@
import { IconLookup, IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
import { CSSProperties } from 'react';
interface OptionsProps {
position?: 'right-center' | 'left-center' | 'top-center';
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
style?: CSSProperties;
}
export const showTextUI = (text: string, options?: OptionsProps): void => exports.ox_lib.showTextUI(text, options);
export const hideTextUI = (): void => exports.ox_lib.hideTextUI();