@molecule/app-file-dropzone-vue 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 +16 -9
- package/dist/FileDropzone.d.ts +1 -1
- package/dist/FileDropzone.d.ts.map +1 -1
- package/dist/FileDropzone.js +7 -82
- package/dist/FileDropzone.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- 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:22.145Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-file-dropzone-vue
|
|
10
10
|
|
|
11
11
|
Vue 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 Vue
|
|
@@ -24,6 +24,7 @@ DOM for the same input.
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
import { defineComponent, h } from 'vue'
|
|
27
|
+
import type { PickedFile } from '@molecule/app-filesystem'
|
|
27
28
|
import { FileDropzone } from '@molecule/app-file-dropzone-vue'
|
|
28
29
|
|
|
29
30
|
const AvatarUpload = defineComponent({
|
|
@@ -33,8 +34,8 @@ const AvatarUpload = defineComponent({
|
|
|
33
34
|
accept: 'image/*',
|
|
34
35
|
multiple: false,
|
|
35
36
|
maxSize: 5 * 1024 * 1024,
|
|
36
|
-
onFiles: (files:
|
|
37
|
-
onRejected: (files:
|
|
37
|
+
onFiles: (files: readonly PickedFile[]) => uploadAvatar(files[0]),
|
|
38
|
+
onRejected: (files: readonly PickedFile[]) => showError(files[0].name),
|
|
38
39
|
})
|
|
39
40
|
},
|
|
40
41
|
})
|
|
@@ -47,7 +48,7 @@ const AvatarUpload = defineComponent({
|
|
|
47
48
|
## Installation
|
|
48
49
|
|
|
49
50
|
```bash
|
|
50
|
-
npm install @molecule/app-file-dropzone-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
|
|
51
|
+
npm install @molecule/app-file-dropzone-vue @molecule/app-filesystem @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
## API
|
|
@@ -60,8 +61,8 @@ Props for {@link FileDropzone}.
|
|
|
60
61
|
|
|
61
62
|
```typescript
|
|
62
63
|
interface FileDropzoneProps {
|
|
63
|
-
/** Called with the
|
|
64
|
-
onFiles: (files:
|
|
64
|
+
/** Called with the files the user selected or dropped, in selection order. */
|
|
65
|
+
onFiles: (files: readonly PickedFile[]) => void
|
|
65
66
|
/** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
|
|
66
67
|
accept?: string
|
|
67
68
|
/** Allow multi-file selection. Defaults to false. */
|
|
@@ -69,7 +70,7 @@ interface FileDropzoneProps {
|
|
|
69
70
|
/** Max file size in bytes. Files exceeding are rejected. */
|
|
70
71
|
maxSize?: number
|
|
71
72
|
/** Called with rejected files (wrong type or size). */
|
|
72
|
-
onRejected?: (files:
|
|
73
|
+
onRejected?: (files: readonly PickedFile[]) => void
|
|
73
74
|
/**
|
|
74
75
|
* Optional content rendered inside the dropzone (defaults to standard upload
|
|
75
76
|
* copy). Passed as a prop or as the default slot — both work.
|
|
@@ -126,7 +127,11 @@ const FileDropzone: DefineComponent<
|
|
|
126
127
|
}>
|
|
127
128
|
> &
|
|
128
129
|
Readonly<{}>,
|
|
129
|
-
{
|
|
130
|
+
{
|
|
131
|
+
onRejected: ((files: readonly PickedFile[]) => void) | undefined
|
|
132
|
+
multiple: boolean
|
|
133
|
+
disabled: boolean
|
|
134
|
+
},
|
|
130
135
|
{},
|
|
131
136
|
{},
|
|
132
137
|
{},
|
|
@@ -148,6 +153,7 @@ const FileDropzone: DefineComponent<
|
|
|
148
153
|
|
|
149
154
|
Peer dependencies:
|
|
150
155
|
|
|
156
|
+
- `@molecule/app-filesystem` ^1.1.0
|
|
151
157
|
- `@molecule/app-ui` ^1.0.1
|
|
152
158
|
- `@molecule/app-ui-vue` ^1.1.0
|
|
153
159
|
- `@molecule/app-vue` ^3.13.0
|
|
@@ -155,6 +161,7 @@ Peer dependencies:
|
|
|
155
161
|
|
|
156
162
|
### Runtime Dependencies
|
|
157
163
|
|
|
164
|
+
- `@molecule/app-filesystem`
|
|
158
165
|
- `@molecule/app-ui`
|
|
159
166
|
- `@molecule/app-ui-vue`
|
|
160
167
|
- `@molecule/app-vue`
|
package/dist/FileDropzone.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare const FileDropzone: import("vue").DefineComponent<import("vue").E
|
|
|
62
62
|
};
|
|
63
63
|
className: StringConstructor;
|
|
64
64
|
}>> & Readonly<{}>, {
|
|
65
|
-
onRejected: ((files:
|
|
65
|
+
onRejected: ((files: readonly import("@molecule/app-filesystem").PickedFile[]) => void) | undefined;
|
|
66
66
|
multiple: boolean;
|
|
67
67
|
disabled: boolean;
|
|
68
68
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDropzone.d.ts","sourceRoot":"","sources":["../src/FileDropzone.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAO,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"FileDropzone.d.ts","sourceRoot":"","sources":["../src/FileDropzone.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAO,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;AAMzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;cAID,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;;;;;;;;;;cAUtC,QAAQ,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;;;;;;;;;UA4FlD,KAAK;;cAtGI,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;;;;;;;;;;cAUtC,QAAQ,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;;;;;;;;;;;;;4EAuI/D,CAAA"}
|
package/dist/FileDropzone.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { defineComponent, h, ref } from 'vue';
|
|
11
|
+
import { createBrowserFileInput, fromBrowserFile } from '@molecule/app-filesystem';
|
|
11
12
|
import { getClassMap } from '@molecule/app-ui';
|
|
12
13
|
import { toChildArray, useTranslation } from '@molecule/app-vue';
|
|
13
14
|
/**
|
|
@@ -54,62 +55,7 @@ export const FileDropzone = defineComponent({
|
|
|
54
55
|
const { t } = useTranslation();
|
|
55
56
|
const dragging = ref(false);
|
|
56
57
|
const inputEl = ref(null);
|
|
57
|
-
|
|
58
|
-
* Filters a file list into kept and rejected files, exactly as React does:
|
|
59
|
-
* a file over `maxSize` is rejected, then a file matching neither the
|
|
60
|
-
* accept extension nor the accept MIME token is rejected (`'*'` accepts
|
|
61
|
-
* everything).
|
|
62
|
-
*
|
|
63
|
-
* @param raw - The files the user dropped or picked.
|
|
64
|
-
* @returns The kept and rejected files.
|
|
65
|
-
*/
|
|
66
|
-
function filter(raw) {
|
|
67
|
-
const arr = Array.from(raw);
|
|
68
|
-
const kept = [];
|
|
69
|
-
const rejected = [];
|
|
70
|
-
for (const f of arr) {
|
|
71
|
-
if (props.maxSize && f.size > props.maxSize) {
|
|
72
|
-
rejected.push(f);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
// cheap accept check
|
|
76
|
-
if (props.accept) {
|
|
77
|
-
const okByExt = props.accept
|
|
78
|
-
.split(',')
|
|
79
|
-
.some((a) => a.trim() &&
|
|
80
|
-
f.name.toLowerCase().endsWith(a.trim().toLowerCase().replace(/^\./, '.')));
|
|
81
|
-
const okByMime = props.accept
|
|
82
|
-
.split(',')
|
|
83
|
-
.some((a) => a.trim() &&
|
|
84
|
-
f.type &&
|
|
85
|
-
(f.type === a.trim() ||
|
|
86
|
-
(a.trim().endsWith('/*') && f.type.startsWith(a.trim().replace('/*', '/')))));
|
|
87
|
-
if (!okByExt && !okByMime && props.accept !== '*') {
|
|
88
|
-
rejected.push(f);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
kept.push(f);
|
|
93
|
-
}
|
|
94
|
-
return { kept, rejected };
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Filters the given file list and dispatches kept/rejected files to the
|
|
98
|
-
* callbacks — only the first kept file unless `multiple` is set.
|
|
99
|
-
*
|
|
100
|
-
* @param list - The files from the drop or the hidden input.
|
|
101
|
-
*/
|
|
102
|
-
function dispatch(list) {
|
|
103
|
-
const { kept, rejected } = filter(list);
|
|
104
|
-
if (kept.length > 0)
|
|
105
|
-
props.onFiles(props.multiple ? kept : [kept[0]]);
|
|
106
|
-
if (rejected.length > 0)
|
|
107
|
-
props.onRejected?.(rejected);
|
|
108
|
-
}
|
|
109
|
-
/** Opens the native file dialog through the hidden input. */
|
|
110
|
-
function openDialog() {
|
|
111
|
-
inputEl.value?.click();
|
|
112
|
-
}
|
|
58
|
+
const handlers = createBrowserFileInput(() => inputEl.value, () => props, fromBrowserFile);
|
|
113
59
|
/**
|
|
114
60
|
* The default copy React renders when no children are given.
|
|
115
61
|
*
|
|
@@ -158,35 +104,18 @@ export const FileDropzone = defineComponent({
|
|
|
158
104
|
}
|
|
159
105
|
return () => h('div', {
|
|
160
106
|
onDragover: (event) => {
|
|
161
|
-
if (
|
|
162
|
-
event.preventDefault();
|
|
107
|
+
if (handlers.onDragOver(event))
|
|
163
108
|
dragging.value = true;
|
|
164
|
-
}
|
|
165
109
|
},
|
|
166
110
|
onDragleave: () => {
|
|
167
111
|
dragging.value = false;
|
|
168
112
|
},
|
|
169
113
|
onDrop: (event) => {
|
|
170
|
-
event.preventDefault();
|
|
171
114
|
dragging.value = false;
|
|
172
|
-
|
|
173
|
-
dispatch(event.dataTransfer.files);
|
|
174
|
-
},
|
|
175
|
-
onClick: () => {
|
|
176
|
-
if (!props.disabled)
|
|
177
|
-
openDialog();
|
|
178
|
-
},
|
|
179
|
-
onKeydown: (event) => {
|
|
180
|
-
// role="button" gets no native keyboard activation — wire
|
|
181
|
-
// Enter/Space to open the file dialog so keyboard users can
|
|
182
|
-
// browse (preventDefault stops Space from scrolling the page).
|
|
183
|
-
if (props.disabled)
|
|
184
|
-
return;
|
|
185
|
-
if (event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar') {
|
|
186
|
-
event.preventDefault();
|
|
187
|
-
openDialog();
|
|
188
|
-
}
|
|
115
|
+
handlers.onDrop(event);
|
|
189
116
|
},
|
|
117
|
+
onClick: handlers.onClick,
|
|
118
|
+
onKeydown: handlers.onKeyDown,
|
|
190
119
|
'data-mol-id': 'file-dropzone',
|
|
191
120
|
role: 'button',
|
|
192
121
|
tabindex: 0,
|
|
@@ -200,11 +129,7 @@ export const FileDropzone = defineComponent({
|
|
|
200
129
|
accept: props.accept,
|
|
201
130
|
multiple: props.multiple ? '' : undefined,
|
|
202
131
|
disabled: props.disabled ? '' : undefined,
|
|
203
|
-
onChange:
|
|
204
|
-
const files = event.target.files;
|
|
205
|
-
if (files)
|
|
206
|
-
dispatch(files);
|
|
207
|
-
},
|
|
132
|
+
onChange: handlers.onChange,
|
|
208
133
|
style: { display: 'none' },
|
|
209
134
|
}),
|
|
210
135
|
...content(),
|
package/dist/FileDropzone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDropzone.js","sourceRoot":"","sources":["../src/FileDropzone.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAiB,GAAG,EAA+B,MAAM,KAAK,CAAA;AAEzF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIhE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,IAAI,EAAE,QAAkD;YACxD,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;SACf;QACD,OAAO,EAAE,MAAM;QACf,UAAU,EAAE;YACV,IAAI,EAAE,QAAqD;YAC3D,OAAO,EAAE,SAAS;SACnB;QACD,4EAA4E;QAC5E,kEAAkE;QAClE,QAAQ,EAAE,IAAI;QACd,sEAAsE;QACtE,2EAA2E;QAC3E,kEAAkE;QAClE,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,SAAS;SACnB;QACD,SAAS,EAAE,MAAM;KAClB;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;QACxB,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;QAC9B,MAA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ACb,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAC9C,KAAK,CAAC,SAAS,CAChB;YACD,KAAK,EAAE,SAAS,EAAE;SACnB,EACD;YACE,CAAC,CAAC,OAAO,EAAE;gBACT,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACzC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACzC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;aAC3B,CAAC;YACF,GAAG,OAAO,EAAE;SACb,CACF,CAAA;IACL,CAAC;CACF,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vue 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 Vue
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { defineComponent, h } from 'vue'
|
|
13
|
+
* import type { PickedFile } from '@molecule/app-filesystem'
|
|
13
14
|
* import { FileDropzone } from '@molecule/app-file-dropzone-vue'
|
|
14
15
|
*
|
|
15
16
|
* const AvatarUpload = defineComponent({
|
|
@@ -19,8 +20,8 @@
|
|
|
19
20
|
* accept: 'image/*',
|
|
20
21
|
* multiple: false,
|
|
21
22
|
* maxSize: 5 * 1024 * 1024,
|
|
22
|
-
* onFiles: (files:
|
|
23
|
-
* onRejected: (files:
|
|
23
|
+
* onFiles: (files: readonly PickedFile[]) => uploadAvatar(files[0]),
|
|
24
|
+
* onRejected: (files: readonly PickedFile[]) => showError(files[0].name),
|
|
24
25
|
* })
|
|
25
26
|
* },
|
|
26
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vue 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 Vue
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { defineComponent, h } from 'vue'
|
|
13
|
+
* import type { PickedFile } from '@molecule/app-filesystem'
|
|
13
14
|
* import { FileDropzone } from '@molecule/app-file-dropzone-vue'
|
|
14
15
|
*
|
|
15
16
|
* const AvatarUpload = defineComponent({
|
|
@@ -19,8 +20,8 @@
|
|
|
19
20
|
* accept: 'image/*',
|
|
20
21
|
* multiple: false,
|
|
21
22
|
* maxSize: 5 * 1024 * 1024,
|
|
22
|
-
* onFiles: (files:
|
|
23
|
-
* onRejected: (files:
|
|
23
|
+
* onFiles: (files: readonly PickedFile[]) => uploadAvatar(files[0]),
|
|
24
|
+
* onRejected: (files: readonly PickedFile[]) => showError(files[0].name),
|
|
24
25
|
* })
|
|
25
26
|
* },
|
|
26
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import type { VNodeChild } from 'vue';
|
|
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
|
/**
|
|
21
22
|
* Optional content rendered inside the dropzone (defaults to standard upload
|
|
22
23
|
* copy). Passed as a prop or as the default slot — both work.
|
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,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC,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,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC,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;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,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-vue",
|
|
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-vue",
|
|
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-ui": "^1.0.1",
|
|
46
47
|
"@molecule/app-ui-vue": "^1.1.0",
|
|
47
48
|
"@molecule/app-vue": "^3.13.0",
|
|
48
49
|
"vue": "^3.4.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-ui": "1.
|
|
55
|
-
"@molecule/app-ui-vue": "1.
|
|
56
|
-
"@molecule/app-vue": "3.
|
|
56
|
+
"@molecule/app-ui": "1.14.0",
|
|
57
|
+
"@molecule/app-ui-vue": "1.9.0",
|
|
58
|
+
"@molecule/app-vue": "3.15.1",
|
|
57
59
|
"@types/node": "26.6.5",
|
|
58
60
|
"jsdom": "31.0.1",
|
|
59
61
|
"typescript": "6.0.3",
|