import { FloatingUIPlacement, FloatingUIRelation, FloatingUIStrategy } from "../type/floating-ui"; import { HTMLStencilElement } from '../stencil-public-runtime'; export interface FloatingElement extends PositionOptions { host: HTMLFloatingElement; } export interface HTMLFloatingElement extends HTMLStencilElement, PositionOptions { visible: boolean; /** what a tooltip is to its caller: its description (the default) or its name */ relation?: FloatingUIRelation; } export interface PositionOptions { hideArrow: boolean; arrowPadding: number; disableAutoPlacement: boolean; flip: boolean; offset: number; placement: FloatingUIPlacement; disableShift: boolean; shiftPadding: number; strategy: FloatingUIStrategy; } /** * ARIA role the floating element takes when the markup does not name one: a `menu` is a popup its * caller controls, a `tooltip` only describes it. A panel that holds anything other than a list of * actions declares its own role and keeps it, `setAttributeIfEmpty` never overwriting it. */ export type FloatingRole = 'menu' | 'tooltip'; /** * The offset parent of an element in the composed tree, the box the layout places it against: the * nearest ancestor across slots and shadow roots that is positioned or filtered, else `body`; none * when an ancestor is not displayed. The native `offsetParent` never returns a node of a shadow tree * the element is not inside, so a panel slotted into a positioned part of a component (the window * of mds-modal, the menu of mds-header) or rendered in the shadow root of a control slotted there * (mds-pref-language in that menu) was placed against the page while that part held it, and landed * as far from its caller as the part is from the page (#1336). Floating UI takes such a function in * place of the native property (`platform.getOffsetParent`, "Shadow DOM" in its docs); the rule is * the one of composed-offset-position, the ponyfill those docs point to, written here instead of a * dependency. Floating UI then skips the static table elements and falls back to the containing * block, as it does with the native one. */ export declare const composedOffsetParent: (element: Element) => Element | null; export declare class FloatingController { private _caller; private _wired; /** what was written on the caller, to be taken back when the target moves to another one: * an attribute that was already there belongs to whoever wrote it and is none of our business */ private _written; private _labelledByOurs; private readonly _host; private readonly _role; arrowEl: HTMLElement | undefined; private cleanupAutoUpdate; constructor(host: HTMLFloatingElement, arrowEl?: HTMLElement, role?: FloatingRole); updateCaller(target: string): HTMLElement | null; /** * Takes back what the wiring wrote on the caller and writes it again, for a change of the host * that changes what is written: the relation of a tooltip. */ rewire(): void; /** * Lets go of the caller the target no longer names. Left alone it keeps pointing at a panel * that is not its own, with a state frozen on the last time it was open, and the panel keeps * being labelled by it - `setAttributeIfEmpty` writes the label once and the second caller * would never get it. */ private readonly unwireCaller; private readonly writeOnCaller; /** An IDREF does not cross a shadow boundary: a caller the host shares no tree with keeps the * attributes that need no reference and loses the ones that do */ private readonly sameRoot; private readonly callerAcceptsWiring; /** * Ties caller and popup to each other with real IDREFs - the wiring used to write the selector * of the caller, which names no element at all, on both sides and towards the caller itself. * Our own callers are waited for first: an `mds-button` writes its `role="button"` in its own * `componentDidLoad`, and which of the two components loads first is not guaranteed. */ private readonly wireCaller; /** Whether the popup is open is state, not a default: it is rewritten at every change, so it * cannot go through `setAttributeIfEmpty` */ syncExpanded(visible: boolean): void; private readonly arrowInset; private readonly arrowTransform; private readonly arrowTransformOrigin; /** * The pivot of the opening animation is the arrow, which the `arrow` middleware * parks wherever it has to sit to keep pointing at the caller: after a shift it * is nowhere near the centre of the panel. `convertToTransformOrigin` only knows * the placement, so it answers `center top` for every bottom placement and the * panel grows from a point that has nothing to do with the arrow - measured on a * 408px panel pushed against the left edge, the two were 165px apart. */ private readonly arrowOrigin; private convertToTransformOrigin; private readonly calculatePosition; /** * Starts positioning only once the panel has a box to measure. A closed panel is * `display: none`, and Stencil reflects `visible` on its own render, so the tick * that asks for the position still sees a panel of zero width: floating-ui then * places a box that does not exist. On a `bottom` placement that lands it half a * panel off; on `left` or `right` it lands it a whole panel off, which reads as * the panel opening on the wrong side of the caller and sliding across to its * place, because the correction that follows is transitioned like any other * move. */ private readonly startWhenMeasurable; updatePosition(): void; dismiss(): void; } /** The values a component resolves for its backdrop: the backdrop hangs from the body, where * nothing set on the component reaches it. An empty one keeps the backdrop of the page. */ export interface BackdropStyle { duration?: string; zIndex?: string; } export declare class Backdrop { private readonly defaultBackdropId; private readonly backdropBackgroundVisible; private readonly backdropBackgroundHidden; private readonly backdropId; private readonly cssBackdropZIndex; private readonly cssBackdropDuration; private backdropEl; private backdropTimer; private duration; constructor(backdropId?: string); attachBackdrop(style?: BackdropStyle): void; detachBackdrop(): void; }