import { FavoritePropertiesScope } from "@itwin/presentation-frontend"; import type { PropsWithChildren, ReactNode } from "react"; import type { PropertyRecord } from "@itwin/appui-abstract"; import type { PropertyGridContextMenuArgs } from "@itwin/components-react"; import type { IModelConnection } from "@itwin/core-frontend"; import type { Field } from "@itwin/presentation-common"; import type { IPresentationPropertyDataProvider } from "@itwin/presentation-components"; /** * Props for single context menu item. * @public */ export interface ContextMenuItemProps { /** iModelConnection used by property grid. */ imodel: IModelConnection; /** Data provider used by property grid. */ dataProvider: IPresentationPropertyDataProvider; /** Property record for which menu is opened. */ record: PropertyRecord; /** Field for which context menu is opened. */ field: Field | undefined; } /** * Props for configuring property grid context menu. * @public */ export interface ContextMenuProps { /** List of items to render in context menu. For consistent style recommend using `PropertyGridContextMenuItem` component. */ contextMenuItems?: Array<(props: ContextMenuItemProps) => ReactNode>; } /** * Props for `PropertyGridContextMenuItem`. * @public */ export interface PropertyGridContextMenuItemProps { /** Unique id of the context menu item. */ id: string; /** Description of the context menu item. */ title?: string; /** Callback that is invoked when context menu item is clicked. */ onSelect: () => void; } /** * Base component for rendering single context menu item. * @public */ export declare function PropertyGridContextMenuItem({ id, children, title, onSelect }: PropsWithChildren): import("react/jsx-runtime").JSX.Element; /** * Props for default context menu items. * @public */ export interface DefaultContextMenuItemProps extends ContextMenuItemProps { /** * Callback that is invoked when context menu item is clicked. `defaultAction` argument passed to * this callback can be invoked to persist default behavior or omitted to completely override it. */ onSelect?: (defaultAction: () => Promise) => Promise; } /** * Props for `Add/Remove` favorite properties context menu items. * @public */ export interface FavoritePropertiesContextMenuItemProps extends DefaultContextMenuItemProps { /** Scope in which favorite property should be stored. Defaults to `FavoritePropertiesScope.IModel`. */ scope?: FavoritePropertiesScope; } /** * Renders `Add to Favorite` context menu item if property field is not favorite. Otherwise renders nothing. * @public */ export declare function AddFavoritePropertyContextMenuItem({ field, imodel, scope, onSelect }: FavoritePropertiesContextMenuItemProps): import("react/jsx-runtime").JSX.Element | null; /** * Renders `Remove from Favorite` context menu item if property field is favorite. Otherwise renders nothing. * @public */ export declare function RemoveFavoritePropertyContextMenuItem({ field, imodel, scope, onSelect }: FavoritePropertiesContextMenuItemProps): import("react/jsx-runtime").JSX.Element | null; /** * Renders `Copy Text` context menu item. * @public */ export declare function CopyPropertyTextContextMenuItem({ record, onSelect, onCopy }: DefaultContextMenuItemProps & { onCopy?: (text: string) => void; }): import("react/jsx-runtime").JSX.Element; /** * Props for `useContextMenu` hook. * @internal */ export interface UseContentMenuProps extends ContextMenuProps { imodel: IModelConnection; dataProvider: IPresentationPropertyDataProvider; } /** * Custom hook for rendering property grid context menu. * @internal */ export declare function useContextMenu({ dataProvider, imodel, contextMenuItems }: UseContentMenuProps): { onPropertyContextMenu: (args: PropertyGridContextMenuArgs) => Promise; renderContextMenu: () => import("react/jsx-runtime").JSX.Element | undefined; }; //# sourceMappingURL=UseContextMenu.d.ts.map