import React, { useMemo } from 'react';
/**
 *  Split a decimal number into a string, separated the integer part and the decimal
 *  e.g "125.46"
 *  return { mainLabel: '125', decimalLabel: '46' }
 */
export const useSplitDecimal = (value, decimals = 2) => {
    const textValue = useMemo(() => {
        // 1. Verify if value is a number
        if (isNaN(value))
            return { mainLabel: value };
        // 2. Get integer part of label
        const integerLabel = parseInt(value, 10);
        // 3. Get decimal part
        let decimalLabel = (parseFloat(value) % 1).toFixed(decimals);
        decimalLabel = decimalLabel.substring(decimals);
        return { mainLabel: integerLabel, decimalLabel };
    }, [decimals, value]);
    return {
        textValue
    };
};
//# sourceMappingURL=useSplitDecimal.js.map