Skip to content

Commit

Permalink
Merge pull request #601 from madeindjs/WF-41
Browse files Browse the repository at this point in the history
feat(ui): add allow file type for `CoreFileInput` - WF-41
  • Loading branch information
ramedina86 authored Oct 28, 2024
2 parents 1e1da6f + 9268825 commit 7e3fa36
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ui/src/components/core/input/CoreFileInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ref="fileEl"
type="file"
:multiple="allowMultipleFilesFlag"
:accept="allowFileTypes"
@change="fileChange($event as InputEvent)"
/>
<div>
Expand Down Expand Up @@ -80,6 +81,18 @@ export default {
init: "Input Label",
type: FieldType.Text,
},
allowFileTypes: {
name: "Allowed file types",
type: FieldType.Text,
init: [
".pdf",
".txt",
".doc",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
].join(", "),
desc: "Provides hints for browsers to select the correct file types. You can specify extensions and MIME types separated by comma, or leave empty to accept any file.",
},
allowMultipleFiles: {
name: "Allow multiple files",
default: "no",
Expand Down Expand Up @@ -129,6 +142,8 @@ const selectedFiles = computed<SavedFile[]>(() =>
Array.isArray(formValue.value) ? formValue.value : [],
);
const allowFileTypes = computed(() => fields.allowFileTypes?.value ?? "");
const allowMultipleFilesFlag = computed(() => {
return fields.allowMultipleFiles.value == "yes" ? true : undefined;
});
Expand Down

0 comments on commit 7e3fa36

Please sign in to comment.