mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
feat(package): interface definitions
This commit is contained in:
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);
|
||||
Reference in New Issue
Block a user