@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
82 lines (80 loc) • 3.32 kB
TypeScript
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import { type PolymorphicForwardRefExoticComponent } from '../_common/types';
import { type DividerProps } from '../divider';
import { type PlacementOptions } from '../popover';
export interface MenuItemProps {
title: React.ReactNode;
icon?: React.ReactNode;
description?: React.ReactNode;
isDisabled?: boolean;
className?: string;
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
id?: string;
children?: React.ReactNode;
}
declare const MenuItem: PolymorphicForwardRefExoticComponent<'button', MenuItemProps>;
export type NestedMenuItemProps = Omit<React.ComponentProps<typeof MenuItem>, 'children'>;
export interface ContextMenuProps {
isOpen?: boolean;
onClose?: (event: Event | undefined, closeReason: {
type: 'backdropClick' | 'itemClick' | 'escapeKeyDown';
id?: string;
}) => void;
anchorRef?: React.RefObject<HTMLElement | null>;
children?: React.ReactNode;
isRoot?: boolean;
/** The placement of the floating element is determined by two sets of words. The first set of words specifies the point on the anchor element where the floating element will be attached. The second set of coordinates specifies the point on the floating element that will attach to the anchor element.*/
placement?: PlacementOptions;
minWidth?: number;
className?: string;
title?: string;
isDisabled?: boolean;
description?: React.ReactNode;
icon?: React.ReactNode;
isPortaled?: boolean;
portalTarget?: HTMLElement | null;
strategy?: 'absolute' | 'fixed';
}
export interface MenuItemsProps {
children: React.ReactNode;
}
export interface MenuSubheaderProps {
title: string;
}
export interface MenuHeaderProps {
/** Header title text */
title: React.ReactNode;
/** Header description text */
description?: React.ReactNode;
/** Additional classes */
className?: string;
}
declare const Menu: React.ForwardRefExoticComponent<ContextMenuProps & React.RefAttributes<HTMLDivElement>> & {
Divider: React.ForwardRefExoticComponent<DividerProps & React.RefAttributes<HTMLDivElement>>;
Header: PolymorphicForwardRefExoticComponent<"div", MenuHeaderProps>;
Item: PolymorphicForwardRefExoticComponent<"button", MenuItemProps>;
Items: PolymorphicForwardRefExoticComponent<"div", MenuItemsProps>;
Subheader: (props: MenuSubheaderProps) => import("react/jsx-runtime").JSX.Element;
};
export { Menu };