import{n as a}from"./index-Ms_1iFoB.js";const n={props:{value:{type:[Array,String]},keyProp:{type:String},rules:{type:[Array]},accept:{type:String,default:"*"},label:{type:String,default:"choose_file"},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1}},data(){return{filename:""}},watch:{value(i){this.filename=i}},mounted(){this.filename=this.value},methods:{getFormData(i){const e=[];for(const t of i){const l=new FormData;l.append("data",t,t.name),e.push(l)}return e},clearInput(){this.filename=null,this.$emit("input",this.filename),this.$emit("onFileSelect",{files:[],key:this.keyProp}),this.$emit("formData",null)},onFocus(){this.disabled||this.$refs.fileInput.click()},onFileChange(i){const e=i.target.files||i.dataTransfer.files,t=this.getFormData(e);e?e.length>0?this.filename=[...e].map(l=>l.name).join(", "):this.filename=null:this.filename=i.target.value.split("\\").pop(),this.$emit("input",this.filename),this.$emit("onFileSelect",{files:e,key:this.keyProp}),this.$emit("formData",t)}}};var s=function(){var e=this,t=e._self._c;return t("v-row",{attrs:{"align-center":""}},[t("v-text-field",{ref:"fileTextField",attrs:{"prepend-icon":"attach_file","single-line":"",label:e.label.toUpperCase(),required:e.required,rules:e.rules,disabled:e.disabled},on:{click:e.onFocus},model:{value:e.filename,callback:function(l){e.filename=l},expression:"filename"}}),t("v-btn",{staticStyle:{margin:"0"},attrs:{icon:""},on:{click:function(l){return l.stopPropagation(),e.clearInput()}}},[t("v-icon",[e._v("clear")])],1),t("input",{ref:"fileInput",staticStyle:{position:"absolute",left:"-99999px"},attrs:{type:"file",accept:e.accept,multiple:e.multiple,disabled:e.disabled},on:{change:e.onFileChange}})],1)},r=[],o=a(n,s,r,!1,null,null);const p=o.exports;export{p as default};
