import * as React from 'react'; import { ElementBoundingBox } from '../lib/dom'; export declare type InlineStyles = React.CSSProperties; export interface TargetProps { style: InlineStyles; className?: string; } export interface TargetPropsFunc { style?: (previous: InlineStyles) => InlineStyles | undefined; className?: (previous: string | undefined) => string | undefined; } export declare type setChildProps = (props: TargetPropsFunc) => void; /** * AnimationCallback * * Return JSX if you want to add a new element to the DOM, * call onFinish() when you've finished the animation, * call setChildProps() if you want to update the target props. */ export declare type AnimationCallback = (elements: AnimationData, onFinish: () => void, setChildProps: setChildProps) => React.ReactNode | undefined | void; export declare enum CollectorActions { animation = "animation", wait = "wait" } export interface WaitAction { action: CollectorActions.wait; } export interface AnimationAction { action: CollectorActions.animation; payload: { animate: AnimationCallback; beforeAnimate?: AnimationCallback; afterAnimate?: AnimationCallback; abort?: () => void; }; } export declare type CollectorData = AnimationAction | WaitAction; export declare type SupplyRefHandler = (ref: HTMLElement | null) => void; export declare type SupplyRenderChildrenHandler = (reactNode: CollectorChildrenAsFunction) => void; export declare type SupplyDataHandler = (data: CollectorData[]) => void; export declare type CollectorChildrenAsFunction = (props: { ref: SupplyRefHandler; style: InlineStyles; className?: string; }) => React.ReactNode; export interface AnimationData { origin: ElementData; destination: ElementData; } export interface ElementData { element: HTMLElement; elementBoundingBox: ElementBoundingBox; focalTargetElement: HTMLElement | null | undefined; focalTargetElementBoundingBox: ElementBoundingBox | undefined; render: CollectorChildrenAsFunction; } export interface CollectorChildrenProps { children: CollectorChildrenAsFunction | React.ReactElement; } export interface CollectorProps extends CollectorChildrenProps { receiveRef?: SupplyRefHandler; receiveFocalTargetRef?: SupplyRefHandler; receiveRenderChildren?: SupplyRenderChildrenHandler; receiveData?: SupplyDataHandler; data?: CollectorData; style?: InlineStyles; className?: string; topMostCollector?: boolean; } export interface Collect { ref: SupplyRefHandler; /** * Used for more complex animations when there is a child in the container * that is needed for the animation calculation. */ focalTargetRef: SupplyRefHandler; data: SupplyDataHandler; renderChildren: SupplyRenderChildrenHandler; style: InlineStyles; className?: string; } export declare const CollectorContext: React.Context; declare const Collector: React.FC; export default Collector;