2022-09-14 13:50:32 +02:00
|
|
|
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
|
|
|
|
|
|
|
|
|
interface ContextMenuItem {
|
2022-09-16 16:06:04 +02:00
|
|
|
title?: string;
|
2022-09-14 13:50:32 +02:00
|
|
|
menu?: string;
|
|
|
|
|
icon?: IconName | [IconPrefix, IconName];
|
|
|
|
|
iconColor?: string;
|
2022-09-16 16:06:04 +02:00
|
|
|
onSelect?: (args: any) => void;
|
2023-02-08 04:05:30 -05:00
|
|
|
onHover?: (hoverState: boolean, args: any) => void;
|
2022-09-14 13:50:32 +02:00
|
|
|
arrow?: boolean;
|
2022-09-16 16:06:04 +02:00
|
|
|
description?: string;
|
2022-09-14 13:50:32 +02:00
|
|
|
metadata?: string | { [key: string]: any } | string[];
|
2022-11-06 11:01:39 +01:00
|
|
|
disabled?: boolean;
|
2022-09-14 13:50:32 +02:00
|
|
|
event?: string;
|
|
|
|
|
serverEvent?: string;
|
|
|
|
|
args?: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ContextMenuArrayItem extends ContextMenuItem {
|
|
|
|
|
title: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ContextMenuProps {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
menu?: string;
|
|
|
|
|
onExit?: () => void;
|
2022-10-11 12:48:59 +01:00
|
|
|
onBack?: () => void;
|
2022-09-14 13:50:32 +02:00
|
|
|
canClose?: boolean;
|
|
|
|
|
options: { [key: string]: ContextMenuItem } | ContextMenuArrayItem[];
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-16 16:06:04 +02:00
|
|
|
type registerContext = (context: ContextMenuProps | ContextMenuProps[]) => void;
|
2022-09-14 13:50:32 +02:00
|
|
|
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();
|