import React, { type ReactNode } from 'react'; import { type SharedValue } from 'react-native-reanimated'; import type { AnimationDirection, ExitAnimationTrigger, PendingEntryAnimation } from '../types'; /** * Context value for coordinating entry/exit animations across list items. * * This enables: * 1. Direct O(1) animation triggers from subscription handlers * 2. Entry animation coordination when items appear in new locations * 3. Layout animation coordination when items are removed * 4. Decoupled animation state from React render cycle */ export interface ListAnimationContextValue { /** * Register an exit animation trigger for an item. * Called by useListExitAnimation on mount. */ registerAnimationTrigger: (itemId: string, trigger: ExitAnimationTrigger) => void; /** * Unregister an exit animation trigger. * Called by useListExitAnimation on unmount. */ unregisterAnimationTrigger: (itemId: string) => void; /** * Trigger exit animation for a specific item. * Returns true if animation was triggered, false if item not found. */ triggerExitAnimation: (itemId: string, direction: AnimationDirection, onComplete: () => void) => boolean; /** * Queue an entry animation for an item that's about to appear. * Call this before the item is added to the list. */ queueEntryAnimation: (itemId: string, direction: AnimationDirection) => void; /** * Check and claim a pending entry animation for an item. * Returns the animation info if found, null otherwise. * Calling this consumes the pending animation. */ claimEntryAnimation: (itemId: string) => PendingEntryAnimation | null; /** * Register an item that is currently exiting (for layout compensation). * Called when exit animation starts. */ registerExitingItem: (itemId: string, index: number, height: number) => void; /** * Unregister an exiting item (called when removal is complete). */ unregisterExitingItem: (itemId: string) => void; /** * Get info about items currently exiting above a given index. * Returns the total height of exiting items above. */ getExitingHeightAbove: (index: number) => number; /** * SharedValue that increments when exiting items change. * Used to trigger useDerivedValue re-evaluation. */ exitingItemsVersion: SharedValue; /** * Duration for layout animations (ms). */ layoutAnimationDuration: number; } /** * Hook to access list animation context. * Throws if used outside ListAnimationProvider. */ export declare const useListAnimation: () => ListAnimationContextValue; /** * Hook to optionally access list animation context. * Returns null if used outside ListAnimationProvider. * Useful for components that can work with or without animations. */ export declare const useListAnimationOptional: () => ListAnimationContextValue | null; interface ListAnimationProviderProps { children: ReactNode; /** * How long pending entry animations are valid (ms) * @default 5000 */ entryAnimationTimeout?: number; /** * Duration for layout animations when items are removed (ms). * This controls how fast remaining items animate into their new positions * after an item is removed from the list. * Lower values = faster/snappier, higher values = smoother/more gradual * @default 300 */ layoutAnimationDuration?: number; /** * Whether to enable native LayoutAnimation for remaining items * @default true */ enableLayoutAnimation?: boolean; } /** * Provider for coordinating entry/exit animations across list items. * * Features: * - O(1) exit animation triggers via Map lookup * - Entry animation queuing with automatic expiration * - Layout animation coordination when items are removed * - Decoupled from React render cycle for performance */ export declare const ListAnimationProvider: React.FC; export {}; //# sourceMappingURL=ListAnimationContext.d.ts.map