import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type ImageImageChangeHandler = (data: { filename: string | null; imageDataURI: string | null; }) => void; interface ImagePropsBase { /** Specify the allowed image extensions. Should be an array * of image extensions, e.g., ['gif', 'jpg', 'png']. */ allowExtensions?: string[]; /** The default file name of the selected image. In order to render selected image preview, * need to set valid defaultFilename (end with allowed image extensions, e.g., 'default.png') * and defaultImageDataURI at the same time. */ defaultFilename?: string; /** The default selected image data (as data URI). Need to set with defaultFilename at the same time. */ defaultImageDataURI?: string; /** Prevents user from selecting or dropping images. */ disabled?: boolean; /** Image can be dropped anywhere on the page. */ dropAnywhere?: boolean; /** A React ref which is set to the DOM element when the component mounts and * null when it unmounts. */ elementRef?: React.Ref; /** Show the component in an error state. */ error?: boolean; /** A callback for when the image changes. The function is passed an * object containing two keys: `filename` and `imageDataURI`. Both are * `null` if the image was removed. */ onImageChange?: ImageImageChangeHandler; } type ImageProps = ComponentProps; declare const isAllowedFilename: (filename: string, allowExtensions: string[]) => boolean; /** * Image provides the ability to accept image files and present a preview of the image. */ declare function Image({ allowExtensions, defaultFilename: defaultFilenameProp, defaultImageDataURI, disabled, error, onImageChange, ...otherProps }: ImageProps): React.JSX.Element; declare namespace Image { var propTypes: { allowExtensions: PropTypes.Requireable<(string | null | undefined)[]>; defaultFilename: PropTypes.Requireable; defaultImageDataURI: PropTypes.Requireable; disabled: PropTypes.Requireable; dropAnywhere: PropTypes.Requireable; elementRef: PropTypes.Requireable; error: PropTypes.Requireable; onImageChange: PropTypes.Requireable<(...args: any[]) => any>; }; } export default Image; export { ImageImageChangeHandler, isAllowedFilename }; export type { ImagePropsBase };