/// <reference types="react" />
import type { Method } from 'axios';
import type { DropzoneContentProps } from '../Dropzone/Dropzone.types';
import type { UNSAFE_UploadFile } from '../_hooks/useFileUploader';
import type { DivAttributes } from '../_utils/types';
import type { LocalSourceProps } from './LocalSource/LocalSource.types';
import type { ThumbnailListItem } from './ThumbnailList/ThumbnailList.types';
export declare type FileSelectValue = FileSelectValueEntry[];
export interface FileSelectSource {
    /**
     * @since 10.19.0
     */
    sourceId: FileSelectSourceIdType;
    /**
     * @since 10.19.0
     */
    title: string;
    /**
     * @since 10.19.0
     */
    icon: React.ReactNode;
    /**
     * @since 10.19.0
     */
    hasError: boolean;
    /**
     * @since 10.19.0
     */
    isUploading: boolean;
    /**
     * @since 10.19.0
     */
    value: SourceValueEntry[];
}
export declare type ValueId = string | number;
export interface FileSelectValueEntry {
    /**
     * @since 10.19.0
     */
    id: ValueId;
    /**
     * @since 10.19.0
     */
    name: string;
    /**
     * @since 10.19.0
     */
    src?: File | string;
    /**
     * @since 10.19.0
     */
    error?: string;
    /**
     * @since 10.19.0
     */
    origin?: unknown;
    /**
     * @since 10.19.0
     */
    response?: unknown;
    /**
     * @since 10.19.0
     */
    sourceId?: string;
}
export declare type SetFileSelectValue = React.Dispatch<React.SetStateAction<FileSelectValue>>;
export interface FileSelectRef {
    /**
     * @since 10.19.0
     */
    setValue: SetFileSelectValue;
    /**
     * @since 10.19.0
     */
    open: (sourceId: FileSelectSourceIdType) => void;
    /**
     * @since 10.19.0
     */
    rootEl: React.RefObject<HTMLDivElement | null>;
    /**
     * @since 10.19.0
     */
    modalEl: React.RefObject<HTMLDivElement | null>;
    /**
     * @since 11.1.0
     */
    resetSources: () => void;
}
export interface FileSelectContextApi {
    /**
     * @since 10.19.0
     */
    register: (sourceId: FileSelectSourceIdType, source: Partial<Pick<FileSelectSource, 'title' | 'icon'>>) => () => void;
    /**
     * @since 10.19.0
     */
    currentSource: FileSelectSourceIdType;
    /**
     * @since 10.19.0
     */
    isModalOpen: boolean;
    /**
     * @since 10.19.0
     */
    onChange: (sourceId: FileSelectSourceIdType, value: SourceValueEntry[]) => void;
    /**
     * @since 10.19.0
     */
    onResetValue: (listener: () => void) => () => void;
    /**
     * @since 10.19.0
     */
    setIsUploading: (sourceId: FileSelectSourceIdType, isUploading: boolean) => void;
    /**
     * @since 10.19.0
     */
    setHasError: (sourceId: FileSelectSourceIdType, isError: boolean) => void;
    /**
     * @since 10.19.0
     */
    maxFileNumber: number;
}
export interface DropzoneContentRendererProps {
    /**
     * Enable/disable the dropzone
     * @since 10.19.0
     */
    disabled: DropzoneContentProps['disabled'];
    /**
     * @since 10.19.0
     */
    errorMessage?: DropzoneContentProps['errorMessage'];
    /**
     * @since 10.19.0
     */
    openLocalFiles: () => void;
    /**
     * @since 10.19.0
     */
    openFileExplorer: () => void;
}
export declare type FileSelectSourceIdType = string;
export declare type SourceValueEntry = any;
export interface QaTags {
    /**
     * @since 10.19.0
     */
    localSource?: LocalSourceProps['qa'];
    /**
     * @since 10.19.0
     */
    attachButton?: string;
    /**
     * @since 10.19.0
     */
    removeEntry?: string;
}
export interface FileSelectProps extends Omit<DivAttributes, 'onError' | 'onProgress'> {
    /**
     * To be called every time when the files are uploaded directly or
     * attached via file explorer. The input data should be appended to the
     * current value. Files with upload errors are omitted.
     * @since 10.19.0
     */
    onAdd?: (value: FileSelectValue) => void;
    /**
     * To be called whenever the file is removed by user from the primary token
     * list. Removed item should be deleted from the current value by `id` key
     * @since 10.19.0
     */
    onRemove?: (valueEntry: FileSelectValueEntry) => void;
    /**
     * To be called whenever the upload progress is changed
     * @since 10.19.0
     */
    onProgress?: (fileId: ValueId, progress: number) => void;
    /**
     * Optional async function that is invoked when selecting or dropping in a
     * local file. If you want to restrict certain uploads, you can use this
     * callback. Returning true continues the upload, while false will prevent
     * upload.
     * @since 10.19.0
     */
    beforeLocalFileUpload?: (files: ThumbnailListItem[]) => Promise<boolean>;
    /**
     * To be called whenever upload state is changed
     * @since 10.19.0
     */
    onUploadStateChange?: (isPendingUpload: boolean) => void;
    /**
     * To be called whenever an upload error occurs
     * @since 10.19.0
     */
    onError?: (fileId: ValueId, error: unknown) => void;
    /**
     * To be called when attached file receives a click
     * @since 10.19.0
     */
    onFileTokenClick?: (file: FileSelectValueEntry) => void;
    /**
     * An optional content renderer for the dropzone. Accepts
     * `{ openLocalFiles, openFileExplorer, disabled, errorMessage }` as a single argument,
     * allowing to control the dropzone and display different content depending
     * on dropzone state
     * @since 10.19.0
     */
    dropzoneContentRenderer?: (dropzoneProps: DropzoneContentRendererProps) => React.ReactNode;
    /**
     * Hide dropzone and render only default "Attach File(s)" button.
     * @default false
     * @since 10.19.0
     */
    hideDropzone?: boolean;
    /**
     * Hide local files source in file explorer modal
     * @since 10.19.0
     */
    hideLocalSource?: boolean;
    /**
     * Customize the token label for a given source value. By default,
     * `sourceValueEntry.name` is returned.
     * @since 10.19.0
     */
    getTokenLabel?: (sourceId: string, sourceValueEntry: unknown) => string;
    localSourceDropzoneContentRenderer?: (dropzoneProps: DropzoneContentProps) => React.ReactNode;
    /**
     * A function returning an upload URL for a given file. An
     * alternative to `uploadFile` which allows manual control of
     * the network request for file upload.
     * @since 10.19.0
     */
    getEndpoint?: (file: File) => string;
    /**
     * A function returning an upload HTTP method for a given file.
     * Returns `POST` by default.
     * @since 10.19.0
     */
    getMethod?: (file: File) => Method;
    /**
     * A function returning an upload payload `FormData` key
     * for a given file. Returns `file` by default.
     * @since 10.19.0
     */
    getPayloadKey?: (file: File) => string;
    /**
     * A function returning an upload payload `FormData`
     * object for a given file. When defined, `getPayloadKey` is
     * ignored.
     * @since 10.19.0
     */
    getPayload?: (file: File) => FormData;
    /**
     * A function returning an upload request headers. Returns empty
     * object by default.
     * @since 10.19.0
     */
    getHeaders?: (file: File) => Record<string, string>;
    /**
     * A function for manually controlling the network request for file
     * upload. An alternative to using `getEndpoint` which handles
     * the network request itself.
     * @since 10.19.0
     */
    uploadFile?: UNSAFE_UploadFile;
    /**
     * Maximum number of files that can be selected
     * @since 10.19.0
     */
    maxFileNumber?: number;
    /**
     * Maximum file size (in bytes)
     * @since 10.19.0
     */
    maxFileSize?: number;
    /**
     * Minimum file size (in bytes)
     * @since 10.19.0
     */
    minFileSize?: number;
    /**
     * Set accepted file types. Accepts everything if left undefined
     * @since 10.19.0
     */
    accept?: string | string[];
    /**
     * A callback to be invoked after the file explorer modal closes
     * @since 11.1.0
     */
    afterHide?: (reason: 'cancel' | 'submit') => void;
    /**
     * @ignore
     * @since 10.19.0
     */
    qa?: QaTags;
}
