import React from 'react'; import PropTypes from 'prop-types'; import Item from './Item'; import { ComponentProps } from '../utils/types'; /** @public */ type FileRequestAddHandler = (files: globalThis.File[], data: { name?: string; }) => void; /** @public */ type FileRequestRemoveHandler = (data: { event: { itemId?: string; name: string; }; filename: string; index: number; itemId?: string; name?: string; }) => void; type FileRequestRetryHandler = (data: { event: { itemId?: string; name: string; }; filename: string; index: number; itemId?: string; name?: string; }) => void; interface FilePropsBase { /** The accept attribute for the file browser. This does not filter dropped items, * which must be filtered manually. File will create a default "supports" message based on this value. */ accept?: string; /** Allow the user to upload multiple files. */ allowMultiple?: boolean; children?: React.ReactNode; /** File can be dropped anywhere on the page. */ dropAnywhere?: boolean; /** Prevents user from dropping files. */ disabled?: 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. This has no effect on the full-screen File. * Note: File.Item has a separate error property. */ error?: boolean; /** There can only be one File component on the page as it will take all files dropped on the page. */ fullscreen?: boolean; /** Show help text. */ help?: React.ReactNode; /** * An id for the input, which may be necessary for accessibility, such as for aria * attributes. */ inputId?: string; /** The name is returned with onRequestAdd and onRequestRemove events, * which can be used to identify the * control when multiple controls share an onChange callback. */ name?: string; /** A callback for when the user selects one or more files. The function is * passed a file reference, which can then be used to read the file. This may * be used to enforce file constraints or upload the file. */ onRequestAdd?: FileRequestAddHandler; /** A callback for when the user requests to remove a file. The function is passed * the event and an object with the Item's index and name: `(event, {index, name})`. */ onRequestRemove?: FileRequestRemoveHandler; /** A callback for when the user requests to retry the upload after upload resulted in error. The function is passed * the event and an object with the Item's index and name: `(event, {index, name})`. */ onRequestRetry?: FileRequestRetryHandler; /** A message for which file types are supported. */ /** @private. */ required?: boolean; supportsMessage?: React.ReactNode; } type FileProps = ComponentProps; /** * File provides the ability to accept files and present uploaded files. It does not provide * file readers, only a reference to the file. This can be used to post binary content, or * upload using an array buffer. */ declare function File({ accept, allowMultiple, children, disabled, dropAnywhere, elementRef, error, fullscreen, help, inputId: inputIdProp, name, onRequestAdd, onRequestRemove, onRequestRetry, required, supportsMessage: supportsMessageProp, ...otherProps }: FileProps): React.JSX.Element; declare namespace File { var propTypes: { accept: PropTypes.Requireable; allowMultiple: PropTypes.Requireable; children: PropTypes.Requireable; disabled: PropTypes.Requireable; dropAnywhere: PropTypes.Requireable; elementRef: PropTypes.Requireable; fullscreen: PropTypes.Requireable; error: PropTypes.Requireable; help: PropTypes.Requireable; inputId: PropTypes.Requireable; name: PropTypes.Requireable; onRequestAdd: PropTypes.Requireable<(...args: any[]) => any>; onRequestRemove: PropTypes.Requireable<(...args: any[]) => any>; onRequestRetry: PropTypes.Requireable<(...args: any[]) => any>; /** @private. */ required: PropTypes.Requireable; supportsMessage: PropTypes.Requireable; }; var componentType: string; var Item: typeof import("./Item").default; } export default File; export { FileRequestAddHandler, FileRequestRemoveHandler, FileRequestRetryHandler, Item }; export type { FilePropsBase };