mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 07:26:02 +01:00
feat(package): interface definitions
This commit is contained in:
10
package/client/resource/interface/alert.ts
Normal file
10
package/client/resource/interface/alert.ts
Normal 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);
|
||||
1
package/client/resource/interface/clipboard.ts
Normal file
1
package/client/resource/interface/clipboard.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const setClipboard = (value: string) => exports.ox_lib.setClipboard(value);
|
||||
36
package/client/resource/interface/context.ts
Normal file
36
package/client/resource/interface/context.ts
Normal 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();
|
||||
22
package/client/resource/interface/input.ts
Normal file
22
package/client/resource/interface/input.ts
Normal 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);
|
||||
36
package/client/resource/interface/menu.ts
Normal file
36
package/client/resource/interface/menu.ts
Normal 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);
|
||||
30
package/client/resource/interface/notify.ts
Normal file
30
package/client/resource/interface/notify.ts
Normal 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);
|
||||
54
package/client/resource/interface/progress.ts
Normal file
54
package/client/resource/interface/progress.ts
Normal 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();
|
||||
12
package/client/resource/interface/textui.ts
Normal file
12
package/client/resource/interface/textui.ts
Normal 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();
|
||||
Reference in New Issue
Block a user