/* eslint-disable react/no-array-index-key */ import React, { useRef } from 'react'; import { CSSTransition } from 'react-transition-group'; import cn from 'classnames'; import { getDataTestId } from '@alfalab/core-components-shared'; import { useInputProgress } from './useInputProgress'; import styles from './index.module.css'; import transitions from './transitions.module.css'; export type InputProgressProps = { maxCodeLength: number; codeLength?: number; error: boolean; value?: string; dataTestId?: string; success?: boolean; }; const TRANSITION_DURATION = 150; export const InputProgress: React.FC = ({ value = '', maxCodeLength, codeLength, error, dataTestId, success, }) => { const { rawSuccess, resetSuccessAnimation } = useInputProgress(success); const nodeRef = useRef(null); return (
{codeLength ? new Array(codeLength).fill(null).map((_, i) => { const filled = Boolean(value[i]); return (
); }) : new Array(maxCodeLength).fill(null).map((_, i) => (
))}
); };