import{n as a}from"./index-009d300e.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(l){this.filename=l}},mounted(){this.filename=this.value},methods:{getFormData(l){const e=[];for(const t of l){const i=new FormData;i.append("data",t,t.name),e.push(i)}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(l){const e=l.target.files||l.dataTransfer.files,t=this.getFormData(e);e?e.length>0?this.filename=[...e].map(i=>i.name).join(", "):this.filename=null:this.filename=l.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(i){e.filename=i},expression:"filename"}}),t("v-btn",{staticStyle:{margin:"0"},attrs:{icon:""},on:{click:function(i){return i.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,null,null);const p=o.exports;export{p as default};
