@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
101 lines (100 loc) • 5.7 kB
TypeScript
import React from "react";
import { Portal } from "../../portal";
import { FocusBoundary } from "../../util/focus-boundary/FocusBoundary";
import { DismissableLayer } from "../dismissablelayer/DismissableLayer";
import { Floating } from "../floating/Floating";
import { RovingFocusProps } from "./parts/RovingFocus";
import { SlottedDivElementRef, SlottedDivProps } from "./parts/SlottedDivElement";
type CheckedState = boolean | "indeterminate";
interface MenuProps {
children?: React.ReactNode;
open?: boolean;
onOpenChange?: (open: boolean) => void;
modal?: boolean;
}
interface MenuComponent extends React.FC<MenuProps> {
Anchor: typeof MenuAnchor;
Portal: typeof MenuPortal;
Content: typeof MenuContent;
Group: typeof MenuGroup;
Item: typeof MenuItem;
CheckboxItem: typeof MenuCheckboxItem;
RadioGroup: typeof MenuRadioGroup;
RadioItem: typeof MenuRadioItem;
Divider: typeof MenuDivider;
Sub: typeof MenuSub;
SubTrigger: typeof MenuSubTrigger;
SubContent: typeof MenuSubContent;
ItemIndicator: typeof MenuItemIndicator;
}
declare const Menu: MenuComponent;
type MenuAnchorProps = React.ComponentPropsWithoutRef<typeof Floating.Anchor>;
declare const MenuAnchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
type MenuContentProps = MenuContentInternalTypeProps;
declare const MenuContent: React.ForwardRefExoticComponent<MenuContentInternalTypeProps & React.RefAttributes<HTMLDivElement>>;
type FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusBoundary>;
type DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;
type MenuContentInternalPrivateProps = {
onOpenAutoFocus?: FocusScopeProps["onMountAutoFocus"];
onDismiss?: DismissableLayerProps["onDismiss"];
disableOutsidePointerEvents?: DismissableLayerProps["disableOutsidePointerEvents"];
};
interface MenuContentInternalProps extends MenuContentInternalPrivateProps, Omit<React.ComponentPropsWithoutRef<typeof Floating.Content>, "dir" | "onPlaced"> {
/**
* Event handler called when auto-focusing after close.
* Can be prevented.
*/
onCloseAutoFocus?: FocusScopeProps["onUnmountAutoFocus"];
onEntryFocus?: RovingFocusProps["onEntryFocus"];
onEscapeKeyDown?: DismissableLayerProps["onEscapeKeyDown"];
onPointerDownOutside?: DismissableLayerProps["onPointerDownOutside"];
onFocusOutside?: DismissableLayerProps["onFocusOutside"];
onInteractOutside?: DismissableLayerProps["onInteractOutside"];
safeZone?: DismissableLayerProps["safeZone"];
}
type MenuContentInternalTypeProps = Omit<MenuContentInternalProps, keyof MenuContentInternalPrivateProps>;
type MenuItemElement = MenuItemInternalElement;
interface MenuItemProps extends Omit<MenuItemInternalProps, "onSelect"> {
onSelect?: (event: Event) => void;
}
declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>;
type MenuItemInternalElement = SlottedDivElementRef;
interface MenuItemInternalProps extends SlottedDivProps {
disabled?: boolean;
}
type MenuGroupProps = SlottedDivProps;
declare const MenuGroup: React.ForwardRefExoticComponent<SlottedDivProps & React.RefAttributes<HTMLDivElement>>;
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
type MenuPortalProps = PortalProps & {
children: React.ReactElement;
};
declare const MenuPortal: React.ForwardRefExoticComponent<MenuPortalProps & React.RefAttributes<HTMLDivElement>>;
interface MenuRadioGroupProps extends MenuGroupProps {
value?: string;
onValueChange?: (value: string) => void;
}
declare const MenuRadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
type MenuItemIndicatorProps = SlottedDivProps;
declare const MenuItemIndicator: React.ForwardRefExoticComponent<SlottedDivProps & React.RefAttributes<HTMLDivElement>>;
interface MenuRadioItemProps extends MenuItemProps {
value: string;
}
declare const MenuRadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
interface MenuCheckboxItemProps extends MenuItemProps {
checked?: CheckedState;
onCheckedChange?: (checked: boolean) => void;
}
declare const MenuCheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
type MenuDividerProps = SlottedDivProps;
declare const MenuDivider: React.ForwardRefExoticComponent<SlottedDivProps & React.RefAttributes<HTMLDivElement>>;
interface MenuSubProps {
children?: React.ReactNode;
open?: boolean;
onOpenChange?: (open: boolean) => void;
}
declare const MenuSub: React.FC<MenuSubProps>;
type MenuSubTriggerProps = MenuItemInternalProps;
declare const MenuSubTrigger: React.ForwardRefExoticComponent<MenuItemInternalProps & React.RefAttributes<HTMLDivElement>>;
type MenuSubContentProps = Omit<MenuContentInternalProps, keyof MenuContentInternalPrivateProps | "onCloseAutoFocus" | "onEntryFocus" | "side" | "align">;
declare const MenuSubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
export { Menu, MenuAnchor, MenuCheckboxItem, MenuContent, MenuDivider, MenuGroup, MenuItem, MenuItemIndicator, MenuPortal, MenuRadioGroup, MenuRadioItem, MenuSub, MenuSubContent, MenuSubTrigger, type MenuAnchorProps, type MenuCheckboxItemProps, type MenuContentProps, type MenuDividerProps, type MenuGroupProps, type MenuItemElement, type MenuItemIndicatorProps, type MenuPortalProps, type MenuProps, type MenuRadioGroupProps, type MenuRadioItemProps, type MenuSubContentProps, type MenuSubProps, type MenuSubTriggerProps, };