UNPKG

@kvaser/canking-api

Version:

CanKing API to communicate with the CanKing service using Node.js.

45 lines (44 loc) 1.53 kB
/** * This module includes a context menu UI control. * * To be able to use these controls the CanKingDataProvider component must be present in the * component tree above your component. Normally the CanKingDataProvider is added * at the root of the component tree. * * @packageDocumentation */ import React, { JSX } from 'react'; /** * Menu option that describes one menu item. */ export type ContextMenuOption = { /** A unique value that identifies this menu item. */ value: number; /** The text to be displayed in the context menu. */ displayText: string; /** An optional icon to be displayed together with the displayText. */ icon?: React.ReactNode; /** An optional shortcut string to be displayed together with the displayText. */ shortcut?: string; }; /** * Properties of the ContextMenu React component. */ export interface ContextMenuProps { /** The menu item options. */ options: ContextMenuOption[]; /** * A callback that will be called when the user selects one of the menu items in this context menu. * @param value - Value of the selected menu option. */ onSelect: (value: number) => void; /** Children nodes that will be using this context menu. */ children?: React.ReactNode; } /** * Creates a context menu UI control. * @param props - Component properties. * @returns The ContextMenu React component. */ declare function ContextMenu({ options, onSelect, children }: ContextMenuProps): JSX.Element; export default ContextMenu;