"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const useLogic = (props) => {
    const { onChange, value } = props;
    const handleMaskFieldAccept = (_, maskEvent) => {
        if (maskEvent.value === '') {
            onChange?.(null);
        }
        else {
            onChange?.(maskEvent.typedValue);
        }
    };
    const newValue = (0, react_1.useMemo)(() => {
        return value === null ? '' : value;
    }, [value]);
    return {
        maskProps: {
            typedValue: newValue,
            value: newValue,
            onAccept: handleMaskFieldAccept,
        },
    };
};
exports.useLogic = useLogic;
