/** * The class names for one transition, already split into lists. * * `enter` and `leave` carry the CSS `transition` or `animation` declaration and * stay on for the whole of their phase; the `*From` and `*To` pairs are the * start and end states swapped between them. `entered` is the resting state, * applied once entering has finished. */ export interface TransitionClasses { enter: string[]; enterFrom: string[]; enterTo: string[]; entered: string[]; leave: string[]; leaveFrom: string[]; leaveTo: string[]; } /** * Callbacks fired around a transition. * * A run that gets interrupted never reaches its `afterEnter` or `afterLeave`, * which is what keeps a caller from unmounting an element that is on its way * back in. */ export interface TransitionHooks { /** Fired for every phase change, including the ones a caller cannot hook. */ onTransition?: (state: TransitionStates) => void; beforeEnter?: () => void; afterEnter?: () => void; beforeLeave?: () => void; afterLeave?: () => void; } /** The phase a transition is in, published as the `tc-transition` attribute. */ export type TransitionStates = 'enter-from' | 'enter-to' | 'entered' | 'leave-from' | 'leave-to'; /** * Runs one element's enter and leave transitions. * * The state holds no reactivity of its own: a caller feeds it an element and a * set of classes, calls {@link show} or {@link hide}, and observes progress * through {@link TransitionHooks}. That is what lets the same machinery drive * both a `` and a ``. * * Each step waits on the element's running animations rather than on a * `transitionend` listener, so an element with nothing to animate simply moves * on to the next step instead of waiting for an event that never arrives. * * States nest: a parent enters before its children and leaves after them, so a * group animates in from the outside and out from the inside. */ export declare class TransitionState { visible: () => boolean; private readonly hooks; /** * @param visible Whether this state has finished entering. Children read it to * decide when they may mount. * @param hooks Called as the transition progresses. */ constructor(visible: () => boolean, hooks: TransitionHooks); private readonly children; register(child: TransitionState): void; unregister(child: TransitionState): void; private element?; /** * The element to transition. It arrives after construction, because the * caller only has a ref once its element has rendered, and it changes again * whenever an `unmount`ing element is rebuilt. */ setElement(element: HTMLElement): void; private classes?; /** * Classes are re-read on every transition rather than captured once, so * changing a class prop applies to the next transition instead of restarting * the current one. */ setClasses(classes: TransitionClasses): void; /** * Bumped whenever a transition starts. A run whose token no longer matches * has been superseded by one going the other way, and stops at its next step * instead of finishing and undoing the newer transition. */ private token; private showing?; private hiding?; /** * Enters, then lets the children enter behind it. * * Every wait is followed by a token check: if a leave has started in the * meantime, this run abandons its remaining steps rather than putting classes * back on an element that is now going the other way. */ private _show; /** * Enters, interrupting a leave if one is running. * * Resolves once this element and everything nested inside it has entered, or * as soon as the run is superseded by a {@link hide}. */ show(): Promise; /** * Lets the children leave first, then leaves. * * Waiting for the children is what keeps a group together: the parent is * still on screen, and still animating, until the last thing inside it has * gone. */ private _hide; /** * Leaves, interrupting an enter if one is running. * * Resolves once everything nested inside has left and this element has * finished its own leave, or as soon as the run is superseded by a * {@link show}. */ hide(): Promise; } //# sourceMappingURL=create-transition-state.d.ts.map