Files
ox_lib/package/client/resource/interface/context.ts

50 lines
1.5 KiB
TypeScript
Raw Normal View History

import type { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
2022-09-14 13:50:32 +02:00
type IconAnimation = 'spin' | 'spinPulse' | 'spinReverse' | 'pulse' | 'beat' | 'fade' | 'beatFade' | 'bounce' | 'shake';
2022-09-14 13:50:32 +02:00
interface ContextMenuItem {
menu?: string;
2023-02-15 13:51:46 +01:00
title?: string;
description?: string;
arrow?: boolean;
image?: string;
icon?: IconName | [IconPrefix, IconName] | string;
2022-09-14 13:50:32 +02:00
iconColor?: string;
iconAnimation?: IconAnimation;
2023-02-15 13:51:46 +01:00
progress?: number;
colorScheme?: string;
onSelect?: (args: any) => void;
2023-09-22 13:49:15 +02:00
readOnly?: boolean;
metadata?:
| string[]
| { [key: string]: any }
| { label: string; value: any; progress?: number; colorScheme?: 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;
onBack?: () => void;
2022-09-14 13:50:32 +02:00
canClose?: boolean;
options: { [key: string]: ContextMenuItem } | ContextMenuArrayItem[];
}
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();