import { useMemo } from 'react';
export const useLogic = (props) => {
    const { onChange, value } = props;
    const handleMaskFieldAccept = (_, maskEvent) => {
        if (maskEvent.value === '') {
            onChange?.(null);
        }
        else {
            onChange?.(maskEvent.typedValue);
        }
    };
    const newValue = useMemo(() => {
        return value === null ? '' : value;
    }, [value]);
    return {
        maskProps: {
            typedValue: newValue,
            value: newValue,
            onAccept: handleMaskFieldAccept,
        },
    };
};
