diff --git a/apps/client/src/widgets/react/FormFileUpload.tsx b/apps/client/src/widgets/react/FormFileUpload.tsx index e97e73184b..42d9c908eb 100644 --- a/apps/client/src/widgets/react/FormFileUpload.tsx +++ b/apps/client/src/widgets/react/FormFileUpload.tsx @@ -3,8 +3,9 @@ import { useEffect, useRef } from "preact/hooks"; import ActionButton, { ActionButtonProps } from "./ActionButton"; import Button, { ButtonProps } from "./Button"; +import { FormListItem, FormListItemOpts } from "./FormList"; -interface FormFileUploadProps { +export interface FormFileUploadProps { name?: string; onChange: (files: FileList | null) => void; multiple?: boolean; @@ -75,3 +76,25 @@ export function FormFileUploadActionButton({ onChange, ...buttonProps }: Omit ); } + +/** + * Similar to {@link FormFileUploadButton}, but uses an {@link FormListItem} instead of a normal {@link Button}. + * @param param the change listener for the file upload and the properties for the button. + */ +export function FormFileUploadFormListItem({ onChange, children, ...buttonProps }: Omit & Pick) { + const inputRef = useRef(null); + + return ( + <> + inputRef.current?.click()} + >{children} +