File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
packages/core/useFileDialog Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { useFileDialog } from '@vueuse/core'
13
13
14
14
const { files, open, reset, onChange } = useFileDialog ({
15
15
accept: ' image/*' , // Set to accept only image files
16
+ directory: true , // Select directories instead of files if set true
16
17
})
17
18
18
19
onChange ((files ) => {
Original file line number Diff line number Diff line change @@ -23,12 +23,19 @@ export interface UseFileDialogOptions extends ConfigurableDocument {
23
23
* @default false
24
24
*/
25
25
reset ?: boolean
26
+ /**
27
+ * Select directories instead of files.
28
+ * @see [HTMLInputElement webkitdirectory](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)
29
+ * @default false
30
+ */
31
+ directory ?: boolean
26
32
}
27
33
28
34
const DEFAULT_OPTIONS : UseFileDialogOptions = {
29
35
multiple : true ,
30
36
accept : '*' ,
31
37
reset : false ,
38
+ directory : false ,
32
39
}
33
40
34
41
export interface UseFileDialogReturn {
@@ -79,6 +86,8 @@ export function useFileDialog(options: UseFileDialogOptions = {}): UseFileDialog
79
86
}
80
87
input . multiple = _options . multiple !
81
88
input . accept = _options . accept !
89
+ // webkitdirectory key is not stabled, maybe replaced in the future.
90
+ input . webkitdirectory = _options . directory !
82
91
if ( hasOwn ( _options , 'capture' ) )
83
92
input . capture = _options . capture !
84
93
if ( _options . reset )
You can’t perform that action at this time.
0 commit comments