From 0682e64bd34260633489485f0dc026c6e83fb9b3 Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Mon, 31 Mar 2025 11:24:24 +0200 Subject: [PATCH] update file field --- Form/Core/FileField.tsx | 2 +- Form/Core/NejDropzone.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Form/Core/FileField.tsx b/Form/Core/FileField.tsx index e61bf5e..e9f4f04 100644 --- a/Form/Core/FileField.tsx +++ b/Form/Core/FileField.tsx @@ -10,7 +10,7 @@ import { Accept } from "react-dropzone"; * @param props.accept - Array of supported file extensions. * @returns {JSX.Element} The rendered file input field. */ -export function FileField({ single, accept, ...props }: FieldHookConfig & { single?: boolean, accept?: Accept }) { +export function FileField({ single, accept, ...props }: FieldHookConfig & { single?: boolean, accept?: Accept | string }) { const [field, meta, helpers] = useField(props); /** diff --git a/Form/Core/NejDropzone.tsx b/Form/Core/NejDropzone.tsx index 3283427..3891f81 100644 --- a/Form/Core/NejDropzone.tsx +++ b/Form/Core/NejDropzone.tsx @@ -13,12 +13,12 @@ import { HTMLAttributes, useMemo } from "react"; * @param {string} props.text - The text to be displayed in the dropzone. * @returns {JSX.Element} - NejDropzone component. */ -export default function NejDropzone({ value, accept, onDrop, validator, single, text, css, children, ...props }: HTMLAttributes & { 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 & { 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({ //validator: validator, onDropAccepted: onDrop, - accept: accept, + accept: typeof (accept) === "string" ? { [accept]: ["*.*"] } : accept, validator: validator, maxFiles: single ? 1 : undefined, });