@molecule/app-file-dropzone-solid 1.1.1 → 2.0.0
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 +13 -7
- package/dist/FileDropzone.d.ts.map +1 -1
- package/dist/FileDropzone.jsx +6 -80
- package/dist/FileDropzone.jsx.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-26T08:58:21.221Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-file-dropzone-solid
|
|
10
10
|
|
|
11
11
|
Solid file dropzone — drag-drop + click-to-browse file picker with
|
|
12
|
-
accept / max-size filtering. Pure UI: it emits
|
|
12
|
+
accept / max-size filtering. Pure UI: it emits `readonly PickedFile[]`
|
|
13
13
|
and the host app performs the actual upload.
|
|
14
14
|
|
|
15
15
|
Exports `FileDropzone` and its `FileDropzoneProps`. It is the Solid
|
|
@@ -31,7 +31,11 @@ export function AvatarUpload() {
|
|
|
31
31
|
accept="image/*"
|
|
32
32
|
multiple={false}
|
|
33
33
|
maxSize={5 * 1024 * 1024}
|
|
34
|
-
onFiles={(files) =>
|
|
34
|
+
onFiles={(files) => {
|
|
35
|
+
const form = new FormData()
|
|
36
|
+
files[0]?.appendTo(form, 'avatar')
|
|
37
|
+
uploadAvatar(form)
|
|
38
|
+
}}
|
|
35
39
|
onRejected={(files) => showError(files[0].name)}
|
|
36
40
|
/>
|
|
37
41
|
)
|
|
@@ -45,7 +49,7 @@ export function AvatarUpload() {
|
|
|
45
49
|
## Installation
|
|
46
50
|
|
|
47
51
|
```bash
|
|
48
|
-
npm install @molecule/app-file-dropzone-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
|
|
52
|
+
npm install @molecule/app-file-dropzone-solid @molecule/app-filesystem @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
|
|
49
53
|
```
|
|
50
54
|
|
|
51
55
|
## API
|
|
@@ -58,8 +62,8 @@ Props for {@link FileDropzone}.
|
|
|
58
62
|
|
|
59
63
|
```typescript
|
|
60
64
|
interface FileDropzoneProps {
|
|
61
|
-
/** Called with the
|
|
62
|
-
onFiles: (files:
|
|
65
|
+
/** Called with the files the user selected or dropped, in selection order. */
|
|
66
|
+
onFiles: (files: readonly PickedFile[]) => void
|
|
63
67
|
/** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
|
|
64
68
|
accept?: string
|
|
65
69
|
/** Allow multi-file selection. Defaults to false. */
|
|
@@ -67,7 +71,7 @@ interface FileDropzoneProps {
|
|
|
67
71
|
/** Max file size in bytes. Files exceeding are rejected. */
|
|
68
72
|
maxSize?: number
|
|
69
73
|
/** Called with rejected files (wrong type or size). */
|
|
70
|
-
onRejected?: (files:
|
|
74
|
+
onRejected?: (files: readonly PickedFile[]) => void
|
|
71
75
|
/** Optional content rendered inside the dropzone (defaults to standard upload copy). */
|
|
72
76
|
children?: JSX.Element
|
|
73
77
|
/** Disabled state. */
|
|
@@ -101,6 +105,7 @@ function FileDropzone(props: FileDropzoneProps): JSX.Element
|
|
|
101
105
|
|
|
102
106
|
Peer dependencies:
|
|
103
107
|
|
|
108
|
+
- `@molecule/app-filesystem` ^1.1.0
|
|
104
109
|
- `@molecule/app-solid` ^3.14.0
|
|
105
110
|
- `@molecule/app-ui` ^1.0.1
|
|
106
111
|
- `@molecule/app-ui-solid` ^1.1.0
|
|
@@ -108,6 +113,7 @@ Peer dependencies:
|
|
|
108
113
|
|
|
109
114
|
### Runtime Dependencies
|
|
110
115
|
|
|
116
|
+
- `@molecule/app-filesystem`
|
|
111
117
|
- `@molecule/app-solid`
|
|
112
118
|
- `@molecule/app-ui`
|
|
113
119
|
- `@molecule/app-ui-solid`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDropzone.d.ts","sourceRoot":"","sources":["../src/FileDropzone.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"FileDropzone.d.ts","sourceRoot":"","sources":["../src/FileDropzone.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,UAAU,CAAA;AAMvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,CAAC,iBAAiB,CAyGrD,CAAA"}
|
package/dist/FileDropzone.jsx
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { createSignal, Show } from 'solid-js';
|
|
11
|
+
import { createBrowserFileInput, fromBrowserFile } from '@molecule/app-filesystem';
|
|
11
12
|
import { ResolveNode, useTranslation } from '@molecule/app-solid';
|
|
12
13
|
import { getClassMap } from '@molecule/app-ui';
|
|
13
14
|
/**
|
|
@@ -25,61 +26,7 @@ export const FileDropzone = (props) => {
|
|
|
25
26
|
const { t } = useTranslation();
|
|
26
27
|
const [dragging, setDragging] = createSignal(false);
|
|
27
28
|
let inputEl;
|
|
28
|
-
|
|
29
|
-
* Filters a file list into kept and rejected files, exactly as React does:
|
|
30
|
-
* a file over `maxSize` is rejected, then a file matching neither the
|
|
31
|
-
* accept extension nor the accept MIME token is rejected (`'*'` accepts
|
|
32
|
-
* everything).
|
|
33
|
-
*
|
|
34
|
-
* @param raw - The files the user dropped or picked.
|
|
35
|
-
* @returns The kept and rejected files.
|
|
36
|
-
*/
|
|
37
|
-
const filter = (raw) => {
|
|
38
|
-
const arr = Array.from(raw);
|
|
39
|
-
const kept = [];
|
|
40
|
-
const rejected = [];
|
|
41
|
-
for (const f of arr) {
|
|
42
|
-
if (props.maxSize && f.size > props.maxSize) {
|
|
43
|
-
rejected.push(f);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
// cheap accept check
|
|
47
|
-
if (props.accept) {
|
|
48
|
-
const okByExt = props.accept
|
|
49
|
-
.split(',')
|
|
50
|
-
.some((a) => a.trim() && f.name.toLowerCase().endsWith(a.trim().toLowerCase().replace(/^\./, '.')));
|
|
51
|
-
const okByMime = props.accept
|
|
52
|
-
.split(',')
|
|
53
|
-
.some((a) => a.trim() &&
|
|
54
|
-
f.type &&
|
|
55
|
-
(f.type === a.trim() ||
|
|
56
|
-
(a.trim().endsWith('/*') && f.type.startsWith(a.trim().replace('/*', '/')))));
|
|
57
|
-
if (!okByExt && !okByMime && props.accept !== '*') {
|
|
58
|
-
rejected.push(f);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
kept.push(f);
|
|
63
|
-
}
|
|
64
|
-
return { kept, rejected };
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Filters the given file list and dispatches kept/rejected files to the
|
|
68
|
-
* callbacks — only the first kept file unless `multiple` is set.
|
|
69
|
-
*
|
|
70
|
-
* @param list - The files from the drop or the hidden input.
|
|
71
|
-
*/
|
|
72
|
-
function dispatch(list) {
|
|
73
|
-
const { kept, rejected } = filter(list);
|
|
74
|
-
if (kept.length > 0)
|
|
75
|
-
props.onFiles(props.multiple ? kept : [kept[0]]);
|
|
76
|
-
if (rejected.length > 0)
|
|
77
|
-
props.onRejected?.(rejected);
|
|
78
|
-
}
|
|
79
|
-
/** Opens the native file dialog through the hidden input. */
|
|
80
|
-
const openDialog = () => {
|
|
81
|
-
inputEl?.click();
|
|
82
|
-
};
|
|
29
|
+
const handlers = createBrowserFileInput(() => inputEl, () => props, fromBrowserFile);
|
|
83
30
|
/**
|
|
84
31
|
* The drop surface's inline style — React's dashed drop region, whose border
|
|
85
32
|
* thickens and whose fill tints on drag-over. The colours are theme tokens;
|
|
@@ -116,38 +63,17 @@ export const FileDropzone = (props) => {
|
|
|
116
63
|
</Show>
|
|
117
64
|
</>);
|
|
118
65
|
return (<div onDragOver={(event) => {
|
|
119
|
-
if (
|
|
120
|
-
event.preventDefault();
|
|
66
|
+
if (handlers.onDragOver(event))
|
|
121
67
|
setDragging(true);
|
|
122
|
-
}
|
|
123
68
|
}} onDragLeave={() => {
|
|
124
69
|
setDragging(false);
|
|
125
70
|
}} onDrop={(event) => {
|
|
126
|
-
event.preventDefault();
|
|
127
71
|
setDragging(false);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}} onClick={() => {
|
|
131
|
-
if (!props.disabled)
|
|
132
|
-
openDialog();
|
|
133
|
-
}} onKeyDown={(event) => {
|
|
134
|
-
// role="button" gets no native keyboard activation — wire Enter/Space
|
|
135
|
-
// to open the file dialog so keyboard users can browse (preventDefault
|
|
136
|
-
// stops Space from scrolling the page).
|
|
137
|
-
if (props.disabled)
|
|
138
|
-
return;
|
|
139
|
-
if (event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar') {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
openDialog();
|
|
142
|
-
}
|
|
143
|
-
}} data-mol-id="file-dropzone" role="button" tabIndex={0} aria-disabled={props.disabled} class={cm.cn(cm.flex({ direction: 'col', align: 'center', justify: 'center' }), cm.sp('p', 6), cm.textCenter, !props.disabled ? cm.cursorPointer : undefined, props.className)} style={zoneStyle()}>
|
|
72
|
+
handlers.onDrop(event);
|
|
73
|
+
}} onClick={handlers.onClick} onKeyDown={handlers.onKeyDown} data-mol-id="file-dropzone" role="button" tabIndex={0} aria-disabled={props.disabled} class={cm.cn(cm.flex({ direction: 'col', align: 'center', justify: 'center' }), cm.sp('p', 6), cm.textCenter, !props.disabled ? cm.cursorPointer : undefined, props.className)} style={zoneStyle()}>
|
|
144
74
|
<input ref={(element) => {
|
|
145
75
|
inputEl = element;
|
|
146
|
-
}} type="file" accept={props.accept} multiple={props.multiple} disabled={props.disabled} onChange={
|
|
147
|
-
const files = event.target.files;
|
|
148
|
-
if (files)
|
|
149
|
-
dispatch(files);
|
|
150
|
-
}} style={{ display: 'none' }}/>
|
|
76
|
+
}} type="file" accept={props.accept} multiple={props.multiple} disabled={props.disabled} onChange={handlers.onChange} style={{ display: 'none' }}/>
|
|
151
77
|
<ResolveNode node={props.children}>
|
|
152
78
|
{(content, hasContent) => (<Show when={hasContent()} fallback={defaultCopy()}>
|
|
153
79
|
{content()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDropzone.jsx","sourceRoot":"","sources":["../src/FileDropzone.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAkB,YAAY,EAAY,IAAI,EAAE,MAAM,UAAU,CAAA;AAEvE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAiC,CAAC,KAAK,EAAE,EAAE;IAClE,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;IACxB,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;IAC9B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;IACnD,IAAI,OAAqC,CAAA;IAEzC
|
|
1
|
+
{"version":3,"file":"FileDropzone.jsx","sourceRoot":"","sources":["../src/FileDropzone.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG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
|
|
2
2
|
* Solid file dropzone — drag-drop + click-to-browse file picker with
|
|
3
|
-
* accept / max-size filtering. Pure UI: it emits
|
|
3
|
+
* accept / max-size filtering. Pure UI: it emits `readonly PickedFile[]`
|
|
4
4
|
* and the host app performs the actual upload.
|
|
5
5
|
*
|
|
6
6
|
* Exports `FileDropzone` and its `FileDropzoneProps`. It is the Solid
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
* accept="image/*"
|
|
18
18
|
* multiple={false}
|
|
19
19
|
* maxSize={5 * 1024 * 1024}
|
|
20
|
-
* onFiles={(files) =>
|
|
20
|
+
* onFiles={(files) => {
|
|
21
|
+
* const form = new FormData()
|
|
22
|
+
* files[0]?.appendTo(form, 'avatar')
|
|
23
|
+
* uploadAvatar(form)
|
|
24
|
+
* }}
|
|
21
25
|
* onRejected={(files) => showError(files[0].name)}
|
|
22
26
|
* />
|
|
23
27
|
* )
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Solid file dropzone — drag-drop + click-to-browse file picker with
|
|
3
|
-
* accept / max-size filtering. Pure UI: it emits
|
|
3
|
+
* accept / max-size filtering. Pure UI: it emits `readonly PickedFile[]`
|
|
4
4
|
* and the host app performs the actual upload.
|
|
5
5
|
*
|
|
6
6
|
* Exports `FileDropzone` and its `FileDropzoneProps`. It is the Solid
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
* accept="image/*"
|
|
18
18
|
* multiple={false}
|
|
19
19
|
* maxSize={5 * 1024 * 1024}
|
|
20
|
-
* onFiles={(files) =>
|
|
20
|
+
* onFiles={(files) => {
|
|
21
|
+
* const form = new FormData()
|
|
22
|
+
* files[0]?.appendTo(form, 'avatar')
|
|
23
|
+
* uploadAvatar(form)
|
|
24
|
+
* }}
|
|
21
25
|
* onRejected={(files) => showError(files[0].name)}
|
|
22
26
|
* />
|
|
23
27
|
* )
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import type { JSX } from 'solid-js';
|
|
8
|
+
import type { PickedFile } from '@molecule/app-filesystem';
|
|
8
9
|
/** Props for {@link FileDropzone}. */
|
|
9
10
|
export interface FileDropzoneProps {
|
|
10
|
-
/** Called with the
|
|
11
|
-
onFiles: (files:
|
|
11
|
+
/** Called with the files the user selected or dropped, in selection order. */
|
|
12
|
+
onFiles: (files: readonly PickedFile[]) => void;
|
|
12
13
|
/** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
|
|
13
14
|
accept?: string;
|
|
14
15
|
/** Allow multi-file selection. Defaults to false. */
|
|
@@ -16,7 +17,7 @@ export interface FileDropzoneProps {
|
|
|
16
17
|
/** Max file size in bytes. Files exceeding are rejected. */
|
|
17
18
|
maxSize?: number;
|
|
18
19
|
/** Called with rejected files (wrong type or size). */
|
|
19
|
-
onRejected?: (files:
|
|
20
|
+
onRejected?: (files: readonly PickedFile[]) => void;
|
|
20
21
|
/** Optional content rendered inside the dropzone (defaults to standard upload copy). */
|
|
21
22
|
children?: JSX.Element;
|
|
22
23
|
/** Disabled state. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,KAAK,IAAI,CAAA;IAC/C,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,KAAK,IAAI,CAAA;IACnD,wFAAwF;IACxF,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACtB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-file-dropzone-solid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Drag-drop file upload area with click-to-browse, accept/size filtering, and a content slot",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-file-dropzone-solid",
|
|
6
6
|
"type": "module",
|
|
@@ -42,18 +42,20 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
+
"@molecule/app-filesystem": "^1.1.0",
|
|
45
46
|
"@molecule/app-solid": "^3.14.0",
|
|
46
47
|
"@molecule/app-ui": "^1.0.1",
|
|
47
48
|
"@molecule/app-ui-solid": "^1.1.0",
|
|
48
49
|
"solid-js": "^1.8.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
52
|
+
"@molecule/app-filesystem": "1.1.0",
|
|
51
53
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
52
|
-
"@molecule/app-i18n": "1.
|
|
54
|
+
"@molecule/app-i18n": "1.3.0",
|
|
53
55
|
"@molecule/app-icons": "1.0.4",
|
|
54
|
-
"@molecule/app-solid": "3.
|
|
55
|
-
"@molecule/app-ui": "1.
|
|
56
|
-
"@molecule/app-ui-solid": "1.
|
|
56
|
+
"@molecule/app-solid": "3.17.0",
|
|
57
|
+
"@molecule/app-ui": "1.14.0",
|
|
58
|
+
"@molecule/app-ui-solid": "1.10.0",
|
|
57
59
|
"@types/node": "26.6.5",
|
|
58
60
|
"jsdom": "31.0.1",
|
|
59
61
|
"solid-js": "1.9.17",
|