import { Slot } from '@blockeditor/global/utils';
import { type AutoUpdateOptions, type ComputePositionConfig, type ComputePositionReturn, type ReferenceElement } from '@floating-ui/dom';
import { LitElement, type RenderOptions, type TemplateResult } from 'lit';
/**
* Renders a template into a portal. Defaults to `document.body`.
*
* Note that every time the parent component re-renders, the portal will be re-called.
*
* See https://lit.dev/docs/components/rendering/#writing-a-good-render()-method
*
* @example
* ```ts
* render() {
* return html`${showPortal
* ? html``
* : null}`;
* };
* ```
*/
export declare class Portal extends LitElement {
container: HTMLElement;
template: TemplateResult<1>;
shadowDom: boolean | ShadowRootInit;
private _portalRoot;
disconnectedCallback(): void;
createRenderRoot(): ShadowRoot | HTMLDivElement;
render(): TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'blockeditor-portal': Portal;
}
}
/**
* See https://lit.dev/docs/templates/expressions/#child-expressions
*/
type Renderable = TemplateResult<1> | HTMLElement | number | boolean | string | null | undefined;
type PortalOptions = {
template: Renderable | ((ctx: {
updatePortal: () => void;
}) => Renderable);
container?: Element;
/**
* The portal is removed when the AbortSignal is aborted.
*/
signal?: AbortSignal;
/**
* Defaults to `true`.
*/
shadowDom?: boolean | ShadowRootInit;
renderOptions?: RenderOptions;
/**
* Defaults to `true`.
* If true, the portalRoot will be added a class `blockeditor-portal`. It's useful for finding the portalRoot.
*/
identifyWrapper?: boolean;
};
/**
* Similar to ``, but only renders once when called.
*
* The template should be a **static** template since it will not be re-rendered unless `updatePortal` is called.
*
* See {@link Portal} for more details.
*/
export declare function createSimplePortal({ template, container, signal, renderOptions, shadowDom, identifyWrapper, }: PortalOptions): HTMLDivElement;
type ComputePositionOptions = {
referenceElement: ReferenceElement;
/**
* Default `false`.
*/
autoUpdate?: true | AutoUpdateOptions;
/**
* Default `true`. Only work when `referenceElement` is an `Element`. Check when position update (`autoUpdate` is `true` or first tick)
*/
abortWhenRefRemoved?: boolean;
} & Partial;
export type AdvancedPortalOptions = Omit & {
abortController: AbortController;
template: Renderable | ((context: {
positionSlot: Slot;
updatePortal: () => void;
}) => Renderable);
/**
* See https://floating-ui.com/docs/computePosition
*/
computePosition?: ComputePositionOptions | ((portalRoot: Element) => ComputePositionOptions);
/**
* Whether to close the portal when click away(click outside).
* @default false
*/
closeOnClickAway?: boolean;
};
/**
* Similar to `createSimplePortal`, but supports auto update position.
*
* The template should be a **static** template since it will not be re-rendered.
*
* See {@link createSimplePortal} for more details.
*
* @example
* ```ts
* createLitPortal({
* template: RenameModal({
* model,
* abortController: renameAbortController,
* }),
* computePosition: {
* referenceElement: anchor,
* placement: 'top-end',
* middleware: [flip(), offset(4)],
* autoUpdate: true,
* },
* abortController: renameAbortController,
* });
* ```
*/
export declare function createLitPortal({ computePosition: positionConfigOrFn, abortController, closeOnClickAway, ...portalOptions }: AdvancedPortalOptions): HTMLDivElement;
export {};
//# sourceMappingURL=portal.d.ts.map