import { useCombinedAnimationDisabledState } from '../../helpers/hooks'; import { getAnimationValueProperty, getIsAnimationDisabledValue, getRootAnimationState, } from '../../helpers/utils/animation'; import { ENTERING_ANIMATION_CONFIG, EXITING_ANIMATION_CONFIG, } from './error-view.constants'; import type { ErrorViewRootAnimation } from './error-view.types'; // -------------------------------------------------- /** * Animation hook for ErrorView root component * Handles entering and exiting animations for error messages */ export function useErrorViewRootAnimation(options: { animation: ErrorViewRootAnimation | undefined; }) { const { animation } = options; const { animationConfig, isAnimationDisabled } = getRootAnimationState(animation); const isAllAnimationsDisabled = useCombinedAnimationDisabledState(animation); const isAnimationDisabledValue = getIsAnimationDisabledValue({ isAnimationDisabled, isAllAnimationsDisabled, }); // Entering animation const enteringValue = getAnimationValueProperty({ animationValue: animationConfig?.entering, property: 'value', defaultValue: ENTERING_ANIMATION_CONFIG, }); // Exiting animation const exitingValue = getAnimationValueProperty({ animationValue: animationConfig?.exiting, property: 'value', defaultValue: EXITING_ANIMATION_CONFIG, }); return { entering: isAnimationDisabledValue ? undefined : enteringValue, exiting: isAnimationDisabledValue ? undefined : exitingValue, }; }