@molecule/app-file-dropzone-react 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -0
- package/package.json +14 -8
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:50:43.367Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-file-dropzone-react
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
File dropzone — drag-drop + click-to-browse file picker with
|
|
16
|
+
accept / max-size filtering. Pure UI: it emits the chosen `File[]`
|
|
17
|
+
and the host app performs the actual upload.
|
|
18
|
+
|
|
19
|
+
Exports `<FileDropzone>` and its `FileDropzoneProps`.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { FileDropzone } from '@molecule/app-file-dropzone-react'
|
|
25
|
+
|
|
26
|
+
function AvatarUpload() {
|
|
27
|
+
return (
|
|
28
|
+
<FileDropzone
|
|
29
|
+
accept="image/*"
|
|
30
|
+
multiple={false}
|
|
31
|
+
maxSize={5 * 1024 * 1024}
|
|
32
|
+
onFiles={(files) => uploadAvatar(files[0])}
|
|
33
|
+
onRejected={(files) => showError(files[0].name)}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Type
|
|
40
|
+
|
|
41
|
+
`feature`
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @molecule/app-file-dropzone-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
|
|
47
|
+
npm install -D @types/react
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### Interfaces
|
|
53
|
+
|
|
54
|
+
#### `FileDropzoneProps`
|
|
55
|
+
|
|
56
|
+
Props for {@link FileDropzone}.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface FileDropzoneProps {
|
|
60
|
+
/** Called with the File[] the user selected or dropped. */
|
|
61
|
+
onFiles: (files: File[]) => void
|
|
62
|
+
/** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
|
|
63
|
+
accept?: string
|
|
64
|
+
/** Allow multi-file selection. Defaults to false. */
|
|
65
|
+
multiple?: boolean
|
|
66
|
+
/** Max file size in bytes. Files exceeding are rejected. */
|
|
67
|
+
maxSize?: number
|
|
68
|
+
/** Called with rejected files (wrong type or size). */
|
|
69
|
+
onRejected?: (files: File[]) => void
|
|
70
|
+
/** Optional content rendered inside the dropzone (defaults to standard upload copy). */
|
|
71
|
+
children?: ReactNode
|
|
72
|
+
/** Disabled state. */
|
|
73
|
+
disabled?: boolean
|
|
74
|
+
/** Extra classes on the dropzone wrapper. */
|
|
75
|
+
className?: string
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Functions
|
|
80
|
+
|
|
81
|
+
#### `FileDropzone(props)`
|
|
82
|
+
|
|
83
|
+
Drag-drop + click-to-browse file upload zone. Pure UI — apps handle
|
|
84
|
+
the actual upload.
|
|
85
|
+
|
|
86
|
+
Rejects files exceeding `maxSize` or not matching `accept` (best-effort
|
|
87
|
+
extension/MIME check) via `onRejected`.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
function FileDropzone({
|
|
91
|
+
onFiles,
|
|
92
|
+
accept,
|
|
93
|
+
multiple = false,
|
|
94
|
+
maxSize,
|
|
95
|
+
onRejected,
|
|
96
|
+
children,
|
|
97
|
+
disabled,
|
|
98
|
+
className,
|
|
99
|
+
}: FileDropzoneProps): JSX.Element
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- `props` — Component props (see {@link FileDropzoneProps}).
|
|
103
|
+
|
|
104
|
+
## Injection Notes
|
|
105
|
+
|
|
106
|
+
### Requirements
|
|
107
|
+
|
|
108
|
+
Peer dependencies:
|
|
109
|
+
|
|
110
|
+
- `@molecule/app-react` ^1.0.1
|
|
111
|
+
- `@molecule/app-ui` ^1.0.1
|
|
112
|
+
- `@molecule/app-ui-react` ^1.0.1
|
|
113
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
114
|
+
|
|
115
|
+
### Runtime Dependencies
|
|
116
|
+
|
|
117
|
+
- `@molecule/app-react`
|
|
118
|
+
- `@molecule/app-ui`
|
|
119
|
+
- `@molecule/app-ui-react`
|
|
120
|
+
- `react`
|
|
121
|
+
|
|
122
|
+
With `multiple={false}` (the default) only the FIRST accepted file is
|
|
123
|
+
delivered to `onFiles`, even when the user drops several at once.
|
|
124
|
+
|
|
125
|
+
The `accept` filter is a best-effort client-side check (file
|
|
126
|
+
extension or MIME prefix match) — treat it as UX sugar and always
|
|
127
|
+
re-validate on the server. Files failing `accept` or `maxSize` go to
|
|
128
|
+
`onRejected` (both rejection causes arrive in the same callback).
|
|
129
|
+
|
|
130
|
+
Pass `children` to replace the default "Drop files here or click to
|
|
131
|
+
browse" copy; the default copy translates via
|
|
132
|
+
`@molecule/app-locales-file-dropzone`.
|
|
133
|
+
|
|
134
|
+
The zone is a keyboard-activatable `role="button"` (`tabIndex={0}`):
|
|
135
|
+
pressing Enter or Space opens the native file dialog, matching a click.
|
|
136
|
+
|
|
137
|
+
## Translations
|
|
138
|
+
|
|
139
|
+
Translation strings are provided by `@molecule/app-locales-file-dropzone`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-file-dropzone-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Drag-drop file upload area with click fallback and preview slot",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"molecule",
|
|
@@ -25,16 +26,21 @@
|
|
|
25
26
|
"react"
|
|
26
27
|
],
|
|
27
28
|
"license": "Apache-2.0",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
32
|
+
"directory": "packages/app/features/file-dropzone-react"
|
|
33
|
+
},
|
|
28
34
|
"peerDependencies": {
|
|
29
|
-
"@molecule/app-react": "^1.0.
|
|
30
|
-
"@molecule/app-ui": "^1.0.
|
|
31
|
-
"@molecule/app-ui-react": "^1.0.
|
|
35
|
+
"@molecule/app-react": "^1.0.1",
|
|
36
|
+
"@molecule/app-ui": "^1.0.1",
|
|
37
|
+
"@molecule/app-ui-react": "^1.0.1",
|
|
32
38
|
"react": "^18.0.0 || ^19.0.0"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
|
-
"@molecule/app-react": "1.0.
|
|
36
|
-
"@molecule/app-ui": "1.0.
|
|
37
|
-
"@molecule/app-ui-react": "1.0.
|
|
41
|
+
"@molecule/app-react": "1.0.1",
|
|
42
|
+
"@molecule/app-ui": "1.0.1",
|
|
43
|
+
"@molecule/app-ui-react": "1.0.1",
|
|
38
44
|
"@testing-library/react": "16.3.2",
|
|
39
45
|
"@types/node": "26.1.2",
|
|
40
46
|
"@types/react": "19.2.17",
|