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