Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/NeFileInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface FileInputProps {
dropzoneLabel: string
progress: number
showProgress: boolean
accept: string | undefined
}

const props = withDefaults(defineProps<FileInputProps>(), {
Expand All @@ -24,7 +25,8 @@ const props = withDefaults(defineProps<FileInputProps>(), {
invalidMessage: '',
progress: 0,
showProgress: false,
dropzoneLabel: 'Drag and drop or click to upload'
dropzoneLabel: 'Drag and drop or click to upload',
accept: undefined
})

const emit = defineEmits(['update:modelValue', 'select'])
Expand Down Expand Up @@ -105,7 +107,7 @@ const dragOverHandler = (event: Event) => {
{{ dropZoneText }}
</p>
</div>
<input class="hidden" type="file" />
<input class="hidden" type="file" :accept="accept" />
<!-- progress bar -->
<NeProgressBar
v-if="showProgress"
Expand Down
16 changes: 15 additions & 1 deletion stories/NeFileInput.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const meta = {
progress: 0,
showProgress: false,
dropzoneLabel: 'Drag and drop or click to upload',
modelValue: null
modelValue: null,
accept: undefined
} // default values
} satisfies Meta<typeof NeFileInput>

Expand Down Expand Up @@ -57,3 +58,16 @@ export const Progress: Story = {
}),
args: { showProgress: true, progress: 75 }
}

export const Accept: Story = {
render: (args) => ({
components: { NeFileInput },
setup() {
return { args }
},
template: template
}),
args: {
accept: 'image/*,.pdf'
}
}