mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
|
|
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);
|