Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: move default props to Dropzone component for react-docgen #1015

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 44 additions & 21 deletions src/index.js
Expand Up @@ -47,6 +47,24 @@ const Dropzone = forwardRef(({ children, ...params }, ref) => {
})

Dropzone.displayName = 'Dropzone'

// Add default props for react-docgen
const DefaultProps = {
samuelfullerthomas marked this conversation as resolved.
Show resolved Hide resolved
disabled: false,
getFilesFromEvent: fromEvent,
maxSize: Infinity,
minSize: 0,
multiple: true,
maxFiles: 0,
preventDropOnDocument: true,
noClick: false,
noKeyboard: false,
noDrag: false,
noDragEventsBubbling: false
}

Dropzone.defaultProps = DefaultProps

Dropzone.propTypes = {
/**
* Render function that exposes the dropzone state and prop getter fns
Expand Down Expand Up @@ -360,27 +378,32 @@ const initialState = {
*
* @returns {DropzoneState}
*/
export function useDropzone({
accept,
disabled = false,
getFilesFromEvent = fromEvent,
maxSize = Infinity,
minSize = 0,
multiple = true,
maxFiles = 0,
onDragEnter,
onDragLeave,
onDragOver,
onDrop,
onDropAccepted,
onDropRejected,
onFileDialogCancel,
preventDropOnDocument = true,
noClick = false,
noKeyboard = false,
noDrag = false,
noDragEventsBubbling = false
} = {}) {
export function useDropzone(options = {}) {
const {
accept,
disabled,
getFilesFromEvent,
maxSize,
minSize,
multiple,
maxFiles,
onDragEnter,
onDragLeave,
onDragOver,
onDrop,
onDropAccepted,
onDropRejected,
onFileDialogCancel,
preventDropOnDocument,
noClick,
noKeyboard,
noDrag,
noDragEventsBubbling
} = {
...DefaultProps,
...options
}

const rootRef = useRef(null)
const inputRef = useRef(null)

Expand Down