import React from 'react'; interface INewLoadingDefault { /** * A message description */ text: Array; /** * Open a lightbox with loading progress */ show: boolean; } interface IWithAnimationOnly extends INewLoadingDefault { percentage?: never; setPercentage?: never; } interface IWithDownloadSupport extends INewLoadingDefault { /** * Percentage of completed download request * `content-length` is required. * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length */ percentage: number; /** * If percentage download is supported * then `setPercentage` is required to change download status */ setPercentage: (progress: React.SetStateAction) => void; } declare type TNewLoading = IWithAnimationOnly | IWithDownloadSupport; /** * Enable to use only if there is progress status from API. * Otherwise it just works like any other animation. * * @example * ## Fake progress (Only animated progress) * * ```js * * ``` * * @example * ## With progress percentage (if this is supported) * `content-length` is required * * ```js * * ``` * * ### Request with Axios * ```js * const [show, setShow] = useState(false); * const [percentage, setPercentage] = useState(0); * const request = async () => { * setPercentage(0); * await axios({ * url: `http://universities.hipolabs.com/search?country=United+States`, * method: 'GET', * responseType: 'json', * onDownloadProgress: (progressEvent) => { * const percentCompleted = Math.round( * (progressEvent.loaded * 100) / progressEvent.total * ); * setPercentage(percentCompleted); * if (percentCompleted === 100) { * setTimeout(() => { * setShow(false); * }, 5000); * } * }, * }); * }; * ``` * */ export declare const NewLoading: ({ text, show, percentage, setPercentage, }: TNewLoading) => JSX.Element; export {};