UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

162 lines (161 loc) 4.48 kB
import { HTMLProps, PropGetter } from "../../core/components/index.types.js"; import "../../core/index.js"; import { FieldProps } from "../field/field.js"; import { RefObject } from "react"; import * as file_selector0 from "file-selector"; import * as react_dropzone0 from "react-dropzone"; import { Accept, DropzoneOptions } from "react-dropzone"; //#region src/components/dropzone/use-dropzone.d.ts interface UseDropzoneProps extends Omit<HTMLProps, "onDrop" | "onError">, FieldProps { /** * The HTML `name` attribute used for forms. */ name?: string; /** * Set accepted file types. */ accept?: Accept | string[]; /** * Set to true to focus the root element on render. * * @default false */ autoFocus?: boolean; /** * Use this to provide a custom file aggregator. */ getFilesFromEvent?: DropzoneOptions["getFilesFromEvent"]; /** * If `true`, display the dropzone loading icon. * * @default false */ loading?: boolean; /** * Maximum accepted number of files. * The default value is 0 which means there is no limitation to how many files are accepted. * * @default 0 */ maxFiles?: number; /** * Maximum file size (in bytes). * * @default Infinity */ maxSize?: number; /** * Minimum file size (in bytes). * * @default 0 */ minSize?: number; /** * Allow drag and drop (or selection from the file dialog) of multiple files. * * @default false */ multiple?: boolean; /** * If true, disables click to open the native file selection dialog. * * @default false */ noClick?: boolean; /** * If true, disables drag and drop. * * @default false */ noDrag?: boolean; /** * If true, stops drag event propagation to parents. * * @default false */ noDragEventsBubbling?: boolean; /** * If true, disables `space` and `enter` to open the native file selection dialog. * Note that it also stops tracking the focus state. * * @default false */ noKeyboard?: boolean; /** * Ref to a open function. */ openRef?: RefObject<() => void>; /** * If false, allow dropped items to take over the current browser window. * * @default true */ preventDropOnDocument?: boolean; /** * If true, use the [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) to read files. * * @default false */ useFsAccessApi?: boolean; /** * Custom validation function. * It must return null if there's no errors. */ validator?: DropzoneOptions["validator"]; /** * Callback for when the dragenter event occurs. */ onDragEnter?: DropzoneOptions["onDragEnter"]; /** * Callback for when the dragleave event occurs. */ onDragLeave?: DropzoneOptions["onDragLeave"]; /** * Callback for when the dragover event occurs. */ onDragOver?: DropzoneOptions["onDragOver"]; /** * Callback for when the drop event occurs. * Note that this callback is invoked after the `getFilesFromEvent` callback is done. */ onDrop?: DropzoneOptions["onDrop"]; /** * Callback for when the drop event occurs. * Note that if no files are accepted, this callback is not invoked. */ onDropAccepted?: DropzoneOptions["onDropAccepted"]; /** * Callback for when the drop event occurs. * Note that if no files are rejected, this callback is not invoked. */ onDropRejected?: DropzoneOptions["onDropRejected"]; /** * Callback for when there's some error from any of the promises. */ onError?: DropzoneOptions["onError"]; /** * Callback for when closing the file dialog with no selection. */ onFileDialogCancel?: DropzoneOptions["onFileDialogCancel"]; /** * Callback for when opening the file dialog. */ onFileDialogOpen?: DropzoneOptions["onFileDialogOpen"]; } declare const useDropzone: (props?: UseDropzoneProps) => { acceptedFiles: readonly file_selector0.FileWithPath[]; dragAccept: boolean; dragActive: boolean; dragIdle: boolean; dragReject: boolean; fileRejections: readonly react_dropzone0.FileRejection[]; focused: boolean; loading: boolean | undefined; open: () => void; getInputProps: PropGetter<"input", undefined, undefined>; getRootProps: PropGetter<"div", undefined, undefined>; }; type UseDropzoneReturn = ReturnType<typeof useDropzone>; //#endregion export { UseDropzoneProps, UseDropzoneReturn, useDropzone }; //# sourceMappingURL=use-dropzone.d.ts.map