import React from 'react'; import { Placement, OffsetOptions } from '@floating-ui/react'; import { ExpandProps, CommonProps, PropsWithHTMLElement, PolymorphicComponent, PolymorphicProps } from '@contentful/f36-core'; import { CaptionProps } from '@contentful/f36-typography'; type BaseMenuProps = { /** * Boolean to determine if the Popover should be the same width as * the trigger element * * @default false */ isFullWidth?: boolean; /** * If `true`, the Menu will be initially opened. This property has no influence on the uncontrolled status of the Menu */ defaultIsOpen?: boolean; /** * Callback fired when the Menu opens */ onOpen?: () => void; /** * Callback fired when the Menu closes */ onClose?: () => void; /** * Determines the preferred position of where the MenuList opens. This position is not * guaranteed, as the MenuList might be moved to fit the viewport. * * @default bottom-start OR right-start */ placement?: Placement | 'auto'; /** * Boolean to control if popover is allowed to change its placement automatically * based on available space in the viewport. * * For example: * If you set placement prop to bottom, but there isn't enough space to position the popover in that direction, * it will change the popper placement to top. As soon as enough space is detected, the placement will be reverted to the defined one. * * If you want the popover to strictly follow the placement prop you should set this prop to false. * * @default true */ isAutoalignmentEnabled?: boolean; /** * Single number as short hand for `mainAxis` * Or object which can contain `mainAxis`, `crossAxis` or `alignmentAxis` * * @default 0 */ offset?: OffsetOptions; /** * Defines if the menu list content should be rendered in the DOM only when it's open * or all the time (after the component has been mounted) * * @default true */ renderOnlyWhenOpen?: boolean; /** * If `true`, the Menu will close when a menu item is * clicked * * Note: This prop will be propagated to all submenus, * unless you will override it with props on submenu itself * * @default true */ closeOnSelect?: boolean; /** * If true, the menu will close when you blur out it by clicking outside * * Note: This prop will be propagated to all submenus, * unless you will override it with props on submenu itself * * @default true */ closeOnBlur?: boolean; /** * If true, the menu will close when you hit the Esc key * * Note: This prop will be propagated to all submenus, * unless you will override it with props on submenu itself * * @default true */ closeOnEsc?: boolean; /** * Boolean to control whether or not to render the Menu in a React Portal. * Rendering content inside a Portal allows the Menu to escape the bounds * of its parent while still being positioned correctly. Using a Portal is * necessary if an ancestor of the Menu hides overflow. * * @default true */ usePortal?: boolean; /** * Boolean to control wether or not to enable Typeahead functionality * which enables focus an item as the user types */ useTypeahead?: boolean; /** * If true, the Menu will be focused after opening * * @default true */ autoFocus?: boolean; /** * Menu compound children (Trigger, List, Item, etc.) */ children?: React.ReactNode; }; interface UncontrolledMenuProps extends BaseMenuProps { isOpen?: undefined; } type ControlledProps = BaseMenuProps & { isOpen: boolean; onOpen?: () => void; onClose?: () => void; } & ({ onOpen: () => void; } | { onClose: () => void; } | { onOpen: () => void; onClose: () => void; }); type MenuProps = UncontrolledMenuProps | ControlledProps; declare const Menu$1: { (props: ExpandProps): React.JSX.Element; displayName: string; }; interface MenuListInternalProps extends CommonProps { children?: React.ReactNode; } type MenuListProps = PropsWithHTMLElement; declare const MenuList: React.ForwardRefExoticComponent, HTMLDivElement>, "ref">, never>, keyof MenuListInternalProps> & MenuListInternalProps & React.RefAttributes>; type MenuListHeaderProps = PropsWithHTMLElement; declare const MenuListHeader: React.FC>; type MenuListFooterProps = PropsWithHTMLElement; declare const MenuListFooter: React.FC>; declare const MENU_ITEM_DEFAULT_TAG = "button"; interface MenuItemInternalProps extends CommonProps { children?: React.ReactNode; as?: 'a' | 'button'; /** * Marks item as active */ isActive?: boolean; /** * Marks item as disabled */ isDisabled?: boolean; /** * Sets focus on item */ isInitiallyFocused?: boolean; /** * Expects any of the icon components. Renders the icon aligned to the start */ icon?: React.ReactElement; } type MenuItemProps = PolymorphicProps; declare const MenuItem: PolymorphicComponent, typeof MENU_ITEM_DEFAULT_TAG>; interface MenuTriggerProps { children: React.ReactElement; } declare const MenuTrigger: React.ForwardRefExoticComponent>; type MenuDividerProps = PropsWithHTMLElement; declare const MenuDivider: { (props: ExpandProps): React.JSX.Element; displayName: string; }; type MenuSectionTitleProps = CaptionProps; declare const MenuSectionTitle: (props: ExpandProps) => React.JSX.Element; /** * @deprecated Submenu is deprecated. Use Menu component instead. * This component will be removed in a future version. * * Migration guide: * Replace `` with `` - the API is identical. */ declare const Submenu: { (props: MenuProps): React.JSX.Element; displayName: string; }; /** * @deprecated Use MenuProps instead. */ type SubmenuProps = MenuProps; type SubmenuTriggerProps = Omit, 'isInitiallyFocused' | 'as'>; declare const SubmenuTrigger: React.ForwardRefExoticComponent>; type CompoundMenu = typeof Menu$1 & { List: typeof MenuList; ListHeader: typeof MenuListHeader; ListFooter: typeof MenuListFooter; Item: typeof MenuItem; Trigger: typeof MenuTrigger; Divider: typeof MenuDivider; SectionTitle: typeof MenuSectionTitle; Submenu: typeof Submenu; SubmenuTrigger: typeof SubmenuTrigger; }; declare const Menu: CompoundMenu; export { Menu, MenuDivider, type MenuDividerProps, MenuItem, type MenuItemProps, MenuList, type MenuListProps, type MenuProps, MenuSectionTitle, type MenuSectionTitleProps, MenuTrigger, type MenuTriggerProps, Submenu, type SubmenuProps, SubmenuTrigger, type SubmenuTriggerProps };