UNPKG

@carbon/react

Version:

React components for the Carbon Design System

46 lines (45 loc) 1.33 kB
/** * Copyright IBM Corp. 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { MouseEventHandler } from 'react'; /** * Array of two numbers either representing [left, right] or [top, bottom]. */ type TwoCoordinates = [number, number]; export interface UseAttachedMenuReturn { /** * Whether the menu is open or not. */ open: boolean; /** * The x position of the menu. */ x: TwoCoordinates; /** * The y position of the menu. */ y: TwoCoordinates; /** * A function to be called when the trigger element receives a click event. */ handleClick: () => void; /** * A function to be called when the trigger element receives a mousedown event. */ handleMousedown: MouseEventHandler; /** * A function to be called when the menu emits onClose. */ handleClose: () => void; } /** * This hook contains common code to be used when a menu should be visually attached to an anchor based on a click event. * * @param {Element|object} anchor The element or ref the menu should visually be attached to. * @returns {useAttachedMenuReturn} */ export declare function useAttachedMenu(anchor: any): UseAttachedMenuReturn; export {};