Files
ox_lib/package/client/resource/interface/context.ts
Sam Shanks 2813bb288b feat(interface/context): context menu onBack function (#122)
* feat(interface/context): back button pressed

* fix(context): types
2022-10-11 13:48:59 +02:00

39 lines
1.1 KiB
TypeScript

import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
interface ContextMenuItem {
title?: string;
menu?: string;
icon?: IconName | [IconPrefix, IconName];
iconColor?: string;
onSelect?: (args: any) => void;
arrow?: boolean;
description?: string;
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;
onBack?: () => void;
canClose?: boolean;
options: { [key: string]: ContextMenuItem } | ContextMenuArrayItem[];
}
type registerContext = (context: ContextMenuProps | 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();