update file field
This commit is contained in:
parent
0b49c447e0
commit
0682e64bd3
|
|
@ -10,7 +10,7 @@ import { Accept } from "react-dropzone";
|
||||||
* @param props.accept - Array of supported file extensions.
|
* @param props.accept - Array of supported file extensions.
|
||||||
* @returns {JSX.Element} The rendered file input field.
|
* @returns {JSX.Element} The rendered file input field.
|
||||||
*/
|
*/
|
||||||
export function FileField({ single, accept, ...props }: FieldHookConfig<File | File[]> & { single?: boolean, accept?: Accept }) {
|
export function FileField({ single, accept, ...props }: FieldHookConfig<File | File[]> & { single?: boolean, accept?: Accept | string }) {
|
||||||
const [field, meta, helpers] = useField(props);
|
const [field, meta, helpers] = useField(props);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ import { HTMLAttributes, useMemo } from "react";
|
||||||
* @param {string} props.text - The text to be displayed in the dropzone.
|
* @param {string} props.text - The text to be displayed in the dropzone.
|
||||||
* @returns {JSX.Element} - NejDropzone component.
|
* @returns {JSX.Element} - NejDropzone component.
|
||||||
*/
|
*/
|
||||||
export default function NejDropzone({ value, accept, onDrop, validator, single, text, css, children, ...props }: HTMLAttributes<HTMLDivElement> & { value: File | File[], accept?: Accept, onDrop: (files: File[]) => void, validator?: (file: File) => FileError | FileError[] | null, single?: boolean, text?: string, css?: any, children?: any }) {
|
export default function NejDropzone({ value, accept, onDrop, validator, single, text, css, children, ...props }: HTMLAttributes<HTMLDivElement> & { value: File | File[], accept?: Accept | string, onDrop: (files: File[]) => void, validator?: (file: File) => FileError | FileError[] | null, single?: boolean, text?: string, css?: any, children?: any }) {
|
||||||
|
|
||||||
const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
|
const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
|
||||||
//validator: validator,
|
//validator: validator,
|
||||||
onDropAccepted: onDrop,
|
onDropAccepted: onDrop,
|
||||||
accept: accept,
|
accept: typeof (accept) === "string" ? { [accept]: ["*.*"] } : accept,
|
||||||
validator: validator,
|
validator: validator,
|
||||||
maxFiles: single ? 1 : undefined,
|
maxFiles: single ? 1 : undefined,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user