-
-
{
- if (e.target.files && e.target.files.length > 0) {
- handleFileSelection(e.target.files)
- }
- }}
- ref={inputRef}
- type="file"
- />
-
+
+
+
+ {
+ if (e.target.files && e.target.files.length > 0) {
+ handleFileSelection(e.target.files)
+ }
+ }}
+ ref={inputRef}
+ type="file"
+ />
+ {t('general:or')}
+
+
+
+
+ {t('general:or')} {t('upload:dragAndDrop')}
+
)}
diff --git a/packages/ui/src/fields/Upload/Input.tsx b/packages/ui/src/fields/Upload/Input.tsx
index 1ad5dce38..1609b4a93 100644
--- a/packages/ui/src/fields/Upload/Input.tsx
+++ b/packages/ui/src/fields/Upload/Input.tsx
@@ -25,9 +25,11 @@ import type { ListDrawerProps } from '../../elements/ListDrawer/types.js'
import { useBulkUpload } from '../../elements/BulkUpload/index.js'
import { Button } from '../../elements/Button/index.js'
+import { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js'
import { Dropzone } from '../../elements/Dropzone/index.js'
import { useListDrawer } from '../../elements/ListDrawer/index.js'
import { ShimmerEffect } from '../../elements/ShimmerEffect/index.js'
+import { PlusIcon } from '../../icons/Plus/index.js'
import { useAuth } from '../../providers/Auth/index.js'
import { useLocale } from '../../providers/Locale/index.js'
import { useTranslation } from '../../providers/Translation/index.js'
@@ -143,8 +145,14 @@ export function UploadInput(props: UploadInputProps) {
collectionSlugs: typeof relationTo === 'string' ? [relationTo] : relationTo,
filterOptions,
})
+ const [
+ CreateDocDrawer,
+ _,
+ { closeDrawer: closeCreateDocDrawer, openDrawer: openCreateDocDrawer },
+ ] = useDocumentDrawer({
+ collectionSlug: activeRelationTo,
+ })
- const inputRef = React.useRef
(null)
const loadedValueDocsRef = React.useRef(false)
const canCreate = useMemo(() => {
@@ -242,7 +250,7 @@ export function UploadInput(props: UploadInputProps) {
[value, onChange, activeRelationTo, hasMany],
)
- const onFileSelection = React.useCallback(
+ const onLocalFileSelection = React.useCallback(
(fileList?: FileList) => {
let fileListToUse = fileList
if (!hasMany && fileList && fileList.length > 1) {
@@ -295,6 +303,24 @@ export function UploadInput(props: UploadInputProps) {
[activeRelationTo, closeListDrawer, onChange, populateDocs, value],
)
+ const onDocCreate = React.useCallback(
+ (data) => {
+ if (data.doc) {
+ setPopulatedDocs((currentDocs) => [
+ ...(currentDocs || []),
+ {
+ relationTo: activeRelationTo,
+ value: data.doc,
+ },
+ ])
+
+ onChange(data.doc.id)
+ }
+ closeCreateDocDrawer()
+ },
+ [closeCreateDocDrawer, activeRelationTo, onChange],
+ )
+
const onListSelect = React.useCallback>(
async ({ collectionSlug, docID }) => {
const loadedDocs = await populateDocs([docID], collectionSlug)
@@ -445,20 +471,18 @@ export function UploadInput(props: UploadInputProps) {
) : null}
{showDropzone ? (
-
+