import type { FC } from '../../lib/teact/teact'; import React, { memo, useCallback } from '../../lib/teact/teact'; import { formatCardExpiry } from '../middle/helpers/inputFormatters'; import InputText from '../ui/InputText'; import useLang from '../../hooks/useLang'; const MAX_FIELD_LENGTH = 5; export type OwnProps = { value: string; error?: string; onChange: (value: string) => void; }; const ExpiryInput : FC = ({ value, error, onChange }) => { const lang = useLang(); const handleChange = useCallback((e) => { const newValue = e.target.value; // Allow deleting separator if (value.endsWith('/') && value.length > newValue.length) { onChange(newValue); } else { onChange(formatCardExpiry(e.target.value)); } }, [onChange, value]); return ( ); }; export default memo(ExpiryInput);