Skip to content

Commit 4e2ed8f

Browse files
authored
Merge pull request #7611 from marmelab/Fix-FileIpnut
Fix FileInput doesn't accept options prop
2 parents 1eaae89 + b43f44e commit 4e2ed8f

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

packages/ra-ui-materialui/src/input/FileInput.tsx

+23-21
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export const FileInput = (props: FileInputProps) => {
2727
format,
2828
helperText,
2929
inputProps: inputPropsOptions,
30-
label,
31-
labelMultiple = 'ra.input.file.upload_several',
32-
labelSingle = 'ra.input.file.upload_single',
3330
maxSize,
3431
minSize,
3532
multiple = false,
36-
onDrop: onDropProp,
33+
label,
34+
labelMultiple = 'ra.input.file.upload_several',
35+
labelSingle = 'ra.input.file.upload_single',
36+
options = {},
3737
onRemove: onRemoveProp,
3838
parse,
3939
placeholder,
@@ -43,6 +43,7 @@ export const FileInput = (props: FileInputProps) => {
4343
validateFileRemoval,
4444
...rest
4545
} = props;
46+
const { onDrop: onDropProp } = options;
4647
const translate = useTranslate();
4748

4849
// turn a browser dropped file structure into expected structure
@@ -142,8 +143,8 @@ export const FileInput = (props: FileInputProps) => {
142143
maxSize,
143144
minSize,
144145
multiple,
146+
...options,
145147
onDrop,
146-
...rest,
147148
});
148149

149150
return (
@@ -207,10 +208,7 @@ export const FileInput = (props: FileInputProps) => {
207208
};
208209

209210
FileInput.propTypes = {
210-
accept: PropTypes.oneOfType([
211-
PropTypes.string,
212-
PropTypes.arrayOf(PropTypes.string),
213-
]),
211+
accept: PropTypes.string,
214212
children: PropTypes.element,
215213
className: PropTypes.string,
216214
id: PropTypes.string,
@@ -252,15 +250,19 @@ const StyledLabeled = styled(Labeled, {
252250
[`& .${FileInputClasses.removeButton}`]: {},
253251
}));
254252

255-
export type FileInputProps = DropzoneOptions &
256-
CommonInputProps & {
257-
className?: string;
258-
children?: ReactNode;
259-
labelMultiple?: string;
260-
labelSingle?: string;
261-
onRemove?: Function;
262-
placeholder?: ReactNode;
263-
inputProps?: any;
264-
validateFileRemoval?(file): boolean | Promise<boolean>;
265-
sx?: SxProps;
266-
};
253+
export type FileInputProps = CommonInputProps & {
254+
accept?: DropzoneOptions['accept'];
255+
className?: string;
256+
children?: ReactNode;
257+
labelMultiple?: string;
258+
labelSingle?: string;
259+
maxSize?: DropzoneOptions['maxSize'];
260+
minSize?: DropzoneOptions['minSize'];
261+
multiple?: DropzoneOptions['multiple'];
262+
options?: DropzoneOptions;
263+
onRemove?: Function;
264+
placeholder?: ReactNode;
265+
inputProps?: any;
266+
validateFileRemoval?(file): boolean | Promise<boolean>;
267+
sx?: SxProps;
268+
};

0 commit comments

Comments
 (0)