11<template >
2- <!-- tag form used to reset the input (method .reset() in claer () function) -->
2+ <!-- tag form used to reset the input (method .reset() in clear () function) -->
33 <form class =" flex items-center justify-center w-full"
44 @dragover.prevent =" dragging = true"
55 @dragleave.prevent =" dragging = false"
2020 :id =" id"
2121 type =" file"
2222 class =" hidden"
23- :accept =" props.extensions .join(',')"
23+ :accept =" normalizedExtensions .join(',')"
2424 @change =" $event.target && doEmit(($event.target as HTMLInputElement).files!)"
2525 :multiple =" props.multiple || false"
2626 />
8080 </p >
8181
8282 <p class =" text-xs text-lightDropzoneText dark:text-darkDropzoneText" >
83- {{ props.extensions .join(', ').toUpperCase().replace(/\./g, '') }}
83+ {{ normalizedExtensions .join(', ').toUpperCase().replace(/\./g, '') }}
8484 <template v-if =" props .maxSizeBytes " >
8585 (Max size: {{ humanifySize(props.maxSizeBytes) }})
8686 </template >
9292
9393<script setup lang="ts">
9494import { humanifySize } from ' @/utils' ;
95- import { ref , type Ref } from ' vue' ;
95+ import { ref , type Ref , computed } from ' vue' ;
9696import { IconFileSolid } from ' @iconify-prerendered/vue-flowbite' ;
9797import { watch } from ' vue' ;
9898import adminforth from ' @/adminforth' ;
@@ -108,6 +108,13 @@ const emit = defineEmits(['update:modelValue']);
108108
109109const id = ` afcl-dropzone-${Math .random ().toString (36 ).substring (7 )} ` ;
110110
111+ const normalizedExtensions = computed (() => {
112+ return props .extensions .map (ext => {
113+ const trimmed = ext .trim ().toLowerCase ();
114+ return trimmed .startsWith (' .' ) ? trimmed : ` .${trimmed } ` ;
115+ });
116+ });
117+
111118const selectedFiles: Ref <{
112119 name: string ,
113120 size: number ,
@@ -131,7 +138,7 @@ function doEmit(filesIn: FileList) {
131138
132139 const multiple = props .multiple || false ;
133140 const files = Array .from (filesIn );
134- const allowedExtensions = props . extensions . map ( ext => ext . toLowerCase ()) ;
141+ const allowedExtensions = normalizedExtensions . value ;
135142 const maxSizeBytes = props .maxSizeBytes ;
136143
137144 if (! files .length ) return ;
0 commit comments