UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

28 lines (27 loc) 1.29 kB
import React from 'react'; type SelectorOptions = { /** * The id used for the portal root element. Defaults to `eufemia-portal-root`. * If an element with this id already exists in the DOM, it will be reused. */ id?: string; /** * CSS selector for a container to place the portal root inside. The portal element is inserted as the first child of the matched element. */ insideSelector?: string; /** * CSS selector for a target element; the portal root will be inserted directly before the first matched element. */ beforeSelector?: string; }; export type PortalRootProps = { innerRef?: React.Ref<HTMLElement> | React.MutableRefObject<HTMLElement> | ((instance: HTMLElement) => void); } & SelectorOptions & Omit<React.HTMLProps<HTMLElement>, 'ref' | 'id'>; export type PortalRootProviderProps = React.PropsWithChildren<SelectorOptions>; export declare function PortalRootProvider(props: PortalRootProviderProps): JSX.Element | null; declare function PortalRoot(props?: PortalRootProps): JSX.Element; declare namespace PortalRoot { var Provider: typeof PortalRootProvider; } export declare function getOrCreatePortalElement({ id, insideSelector, beforeSelector, }: SelectorOptions): HTMLElement | null; export default PortalRoot;