@engie-group/fluid-design-system
Version:
The Fluid Design System is ENGIE’s open-source library to create, build and deliver ENGIE digital services in a more efficient way.
40 lines (39 loc) • 2.03 kB
TypeScript
import { FlipOptions, HideOptions, OffsetOptions, Placement, ShiftOptions } from '@floating-ui/dom';
export interface IMenuOptions {
placement?: Placement;
offsetOptions?: OffsetOptions;
flipOptions?: FlipOptions;
shiftOptions?: ShiftOptions;
hideOptions?: HideOptions;
}
interface IReturn {
menu: HTMLDivElement;
unmount: () => void;
}
/**
* Opens a menu at the given coordinates or anchor element.
* @param coordinate The coordinate on which the menu should open
* @param content Element which will be rendered in the menu
* @param appendTo Element or element id on which the menu will be appended in DOM. This element must be positioned (not `position: static`)
* @param options Options to configure how the menu should behave (see. [Floating UI Documentation](https://floating-ui.com/docs/middleware) to understand middleware options)
*
* @returns the generated menu `HTMLDivElement` and a function to unmount it, call the unmount function to hide the menu.
*/
export declare function openMenu(coordinate: {
x: number;
y: number;
}, content: Element, appendTo?: Element | string, options?: IMenuOptions): IReturn;
/**
* Opens a menu at the given coordinates or anchor element.
* @param anchor The reference element on which the menu should open
* @param content Element which will be rendered in the menu
* @param appendTo Element or element id on which the menu will be appended in DOM. This element must be positioned (not `position: static`)
* @param options Options to configure how the menu should behave (see. [Floating UI Documentation](https://floating-ui.com/docs/middleware) to understand middleware options)
*
* @returns the generated menu `HTMLDivElement` and a function to unmount it, call the unmount function to hide the menu.
*/
export declare function openMenu(anchor: Element, content: Element, appendTo?: Element | string | 'parent', options?: IMenuOptions): IReturn;
declare const _default: {
openMenu: typeof openMenu;
};
export default _default;