@davincihealthcare/elty-design-system-vue 1.73.1 → 1.73.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("./input.cjs.js"),k=require("./ElInputContainer.vue.cjs2.js"),x=require("../ElFile.vue.cjs2.js"),M=require("../ElIcon.vue.cjs2.js"),_=require("../ElToast.vue.cjs2.js"),F={class:"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20"},
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("./input.cjs.js"),k=require("./ElInputContainer.vue.cjs2.js"),x=require("../ElFile.vue.cjs2.js"),M=require("../ElIcon.vue.cjs2.js"),_=require("../ElToast.vue.cjs2.js"),F={class:"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20"},q=["for"],C={key:0,class:"text-xs"},V=["id","accept","disabled","name","multiple"],E=["image","document","csv","excel","any","zip","patientsImportDataFpfV5","patientsImportDataHippocrates","patientsImportDataIatros","patientsImportDataMdb2000","patientsImportDataMillewin","patientsImportDataPhronesis","patientsImportDataFastamb","patientsImportDataMedico2000","patientsImportDataTServe","patientsImportDataProfim","patientsImportDataMillewinAttachments","patientsImportDataAdvmednet"],A=e.defineComponent({__name:"ElInputFile",props:{...d.withCommonElInputProps(),modelValue:{type:Array,required:!0},content:{type:String,default:void 0},multiple:{type:Boolean,default:!1},fileType:{type:String,default:"document",required:!1}},emits:["update:modelValue"],setup(i,{emit:f}){const s=i,o=e.ref(!1),u=e.ref(),v=f,b=e.toRef(s.modelValue),c=e.computed(()=>{switch(s.fileType){case"patientsImportDataFpfV5":case"patientsImportDataMdb2000":case"patientsImportDataFastamb":case"patientsImportDataProfim":return[".mdb"];case"patientsImportDataHippocrates":return[".xml"];case"patientsImportDataIatros":return[".xml",".mdb",".sql",".backup"];case"patientsImportDataMillewin":return[".sql",".backup",".db3"];case"patientsImportDataPhronesis":return[".sqlite",".sqlite3",".db",".db3",".s3db",".sl3",".gz"];case"patientsImportDataTServe":case"patientsImportDataMedico2000":case"patientsImportDataMillewinAttachments":case"patientsImportDataAdvmednet":case"zip":return[".zip"];case"image":return["image/jpeg","image/png"];case"document":return[".doc",".docx",".xml","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document",".pdf"];case"csv":return[".csv"];case"excel":return[".xlsx"];default:return["*"]}}),g=e.computed(()=>{const t=[s.validation];switch(s.fileType){case"image":t.push("ext:jpg,png,jpeg");break;case"document":t.push("ext:doc,docs,xml,pdf");break;case"csv":t.push("ext:csv");break;case"excel":t.push("ext:xlsx");break;case"patientsImportDataFpfV5":case"patientsImportDataMdb2000":case"patientsImportDataFastamb":case"patientsImportDataProfim":t.push("ext:mdb");break;case"patientsImportDataHippocrates":t.push("ext:xml");break;case"patientsImportDataIatros":t.push("ext:xml,mdb,sql,backup");break;case"patientsImportDataMillewin":t.push("ext:sql,backup,.db3");break;case"patientsImportDataPhronesis":t.push("ext:sqlite,sqlite3,db,db3,s3db,sl3,gz");break;case"patientsImportDataTServe":case"patientsImportDataMedico2000":case"patientsImportDataMillewinAttachments":case"patientsImportDataAdvmednet":case"zip":t.push("ext:zip");break}return t}),{value:n,errorMessage:h,uuid:p}=d.useInput(b,g,s.name,t=>{v("update:modelValue",t)}),I=t=>{const a=t.target;a&&m(a.files)},D=t=>{t.dataTransfer&&(m(t.dataTransfer.files),o.value=!1)},m=t=>{var a;y(t),(a=u.value)!=null&&a.value&&(u.value.value=null)},y=t=>{if(!t)return;const a=[...t];if(!a.every(r=>c.value.some(l=>r.name.toLowerCase().endsWith(l)||r.type.toLowerCase()===l||l==="*")))return _.toast("Formato non supportato, verifica di aver inserito un file/s con il formato corretto",{state:"error"});n.value=[...n.value,...a],!s.multiple&&n.value.length>1&&(n.value=[n.value[0]])},w=t=>{n.value=n.value.filter((a,r)=>r!==t)};return(t,a)=>(e.openBlock(),e.createBlock(k.default,e.mergeProps(t.$attrs,{name:e.unref(p),label:t.label,"error-message":s.errorMessage===!1?!1:s.errorMessage||e.unref(h),"hidden-error-message":t.hiddenErrorMessage,class:"relative inline-block w-full"}),{default:e.withCtx(()=>[e.createElementVNode("div",F,[e.unref(n).length==0||i.multiple?(e.openBlock(),e.createElementBlock("label",{key:0,tabIndex:"0",for:e.unref(p),class:e.normalizeClass(["min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full",{"bg-white":!o.value,"bg-primary-light-hover":o.value,"hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused":!t.disabled,"border-gray-300 text-gray-300 cursor-not-allowed":t.disabled,"border-primary":!t.disabled&&!o.value,"border-primary-hover":!t.disabled&&o.value}]),onDragover:a[0]||(a[0]=e.withModifiers(r=>o.value=!0,["prevent"])),onDrop:e.withModifiers(D,["prevent"]),onDragenter:a[1]||(a[1]=e.withModifiers(r=>o.value=!0,["prevent"])),onDragleave:a[2]||(a[2]=e.withModifiers(r=>o.value=!1,["prevent"]))},[e.createVNode(M.default,{name:"ArrowUpCircleIcon",class:e.normalizeClass({"w-5 h-5":i.content,"w-7 h-7":!i.content,"cursor-pointer":!t.disabled})},null,8,["class"]),i.content?(e.openBlock(),e.createElementBlock("span",C,e.toDisplayString(i.content),1)):e.createCommentVNode("",!0)],42,q)):e.createCommentVNode("",!0),e.createElementVNode("input",{id:e.unref(p),ref_key:"inputField",ref:u,type:"file",class:"hidden",accept:c.value.join(","),disabled:t.disabled,name:s.name||e.unref(p),multiple:i.multiple,onChange:e.withModifiers(I,["prevent"])},null,40,V),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),(r,l)=>(e.openBlock(),e.createBlock(x.default,{key:`file-${l}`,variant:"primary",name:r.name,format:r.type,class:"w-full",disabled:t.disabled,onClose:B=>w(l)},null,8,["name","format","disabled","onClose"]))),128))])]),_:1},16,["name","label","error-message","hidden-error-message"]))}});exports.default=A;exports.elInputFileTypes=E;
|
|
2
2
|
//# sourceMappingURL=ElInputFile.vue.cjs2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElInputFile.vue.cjs2.js","sources":["../../src/forms/ElInputFile.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputFileTypes = [\n 'image',\n 'document',\n 'csv',\n 'excel',\n 'any',\n 'zip',\n 'patientsImportDataFpfV5',\n 'patientsImportDataHippocrates',\n 'patientsImportDataIatros',\n 'patientsImportDataMdb2000',\n 'patientsImportDataMillewin',\n 'patientsImportDataPhronesis',\n 'patientsImportDataFastamb',\n 'patientsImportDataMedico2000',\n 'patientsImportDataTServe',\n 'patientsImportDataProfim',\n 'patientsImportDataMillewinAttachments',\n 'patientsImportDataAdvmednet',\n] as const;\nexport type ElInputFileType = (typeof elInputFileTypes)[number];\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, toRef, PropType } from 'vue';\nimport { useInput, withCommonElInputProps } from '@/forms/input';\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport ElFile from '@/ElFile.vue';\nimport ElIcon from '@/ElIcon.vue';\nimport { toast } from '@/ElToast.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: Array as () => File[],\n required: true,\n },\n content: {\n type: String,\n default: undefined,\n },\n multiple: {\n type: Boolean,\n default: false,\n },\n fileType: {\n type: String as PropType<ElInputFileType>,\n default: 'document',\n required: false,\n },\n});\n\nconst dragging = ref(false);\nconst inputField = ref<HTMLFormElement>();\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', files: File[]): void;\n}>();\n\nconst modelValue = toRef(props.modelValue);\n\nconst computedAcceptedFileExtensionsOrMimeType = computed<string[]>(() => {\n switch (props.fileType) {\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n return ['.mdb', '.zip'];\n case 'patientsImportDataHippocrates':\n return ['.xml', '.zip'];\n case 'patientsImportDataIatros':\n return ['.xml', '.mdb', '.sql', '.backup', '.zip'];\n case 'patientsImportDataMillewin':\n return ['.sql', '.backup', '.db3', '.zip'];\n case 'patientsImportDataPhronesis':\n return ['.sqlite', '.sqlite3', '.db', '.db3', '.s3db', '.sl3', '.gz'];\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n return ['.zip'];\n case 'image':\n return ['image/jpeg', 'image/png'];\n case 'document':\n // any pdf or word-like document\n return [\n '.doc',\n '.docx',\n '.xml',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n '.pdf',\n ];\n case 'csv':\n return ['.csv'];\n case 'excel':\n return ['.xlsx'];\n default:\n return ['*'];\n }\n});\nconst computedValidation = computed(() => {\n const validations = [props.validation];\n switch (props.fileType) {\n case 'image':\n validations.push('ext:jpg,png,jpeg');\n break;\n case 'document':\n validations.push('ext:doc,docs,xml,pdf');\n break;\n case 'csv':\n validations.push('ext:csv');\n break;\n case 'excel':\n validations.push('ext:xlsx');\n break;\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n validations.push('ext:mdb,zip');\n break;\n case 'patientsImportDataHippocrates':\n validations.push('ext:xml,zip');\n break;\n case 'patientsImportDataIatros':\n validations.push('ext:xml,mdb,sql,backup,zip');\n break;\n case 'patientsImportDataMillewin':\n validations.push('ext:sql,backup,.db3,zip');\n break;\n case 'patientsImportDataPhronesis':\n validations.push('ext:sqlite,sqlite3,db,db3,s3db,sl3,gz');\n break;\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n validations.push('ext:zip');\n break;\n default:\n break;\n }\n return validations;\n});\n\nconst { value, errorMessage, uuid } = useInput(modelValue, computedValidation, props.name, (newValue: File[]) => {\n emit('update:modelValue', newValue);\n});\n\nconst onChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (!target) return;\n loadFilesAndClearInput(target.files);\n};\n\nconst onDrop = (event: DragEvent) => {\n if (!event.dataTransfer) return;\n loadFilesAndClearInput(event.dataTransfer.files);\n dragging.value = false;\n};\n\nconst loadFilesAndClearInput = (newFiles: FileList | null) => {\n loadFiles(newFiles);\n if (inputField.value?.value) inputField.value.value = null;\n};\n\nconst loadFiles = (newFiles: FileList | null) => {\n if (!newFiles) return;\n const newFilesArray = [...newFiles];\n\n if (\n !newFilesArray.every(file =>\n computedAcceptedFileExtensionsOrMimeType.value.some(\n extensionOrMimeType =>\n file.name.toLowerCase().endsWith(extensionOrMimeType) ||\n file.type.toLowerCase() === extensionOrMimeType ||\n extensionOrMimeType === '*',\n ),\n )\n ) {\n return toast('Formato non supportato, verifica di aver inserito un file/s con il formato corretto', { state: 'error' });\n }\n\n value.value = [...value.value, ...newFilesArray];\n if (!props.multiple && value.value.length > 1) {\n value.value = [value.value[0]];\n }\n};\n\nconst removeFile = (idx: number) => {\n value.value = value.value.filter((_, i) => i !== idx);\n};\n</script>\n\n<template>\n <ElInputContainer\n v-bind=\"$attrs\"\n :name=\"uuid\"\n :label=\"label\"\n :error-message=\"props.errorMessage === false ? false : props.errorMessage || errorMessage\"\n :hidden-error-message=\"hiddenErrorMessage\"\n class=\"relative inline-block w-full\"\n >\n <div class=\"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20\">\n <label\n v-if=\"value.length == 0 || multiple\"\n tabIndex=\"0\"\n :for=\"uuid\"\n class=\"min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full\"\n :class=\"{\n 'bg-white': !dragging,\n 'bg-primary-light-hover': dragging,\n 'hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused':\n !disabled,\n 'border-gray-300 text-gray-300 cursor-not-allowed': disabled,\n 'border-primary': !disabled && !dragging,\n 'border-primary-hover': !disabled && dragging,\n }\"\n @dragover.prevent=\"dragging = true\"\n @drop.prevent=\"onDrop\"\n @dragenter.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n >\n <ElIcon\n name=\"ArrowUpCircleIcon\"\n :class=\"{\n 'w-5 h-5': content,\n 'w-7 h-7': !content,\n 'cursor-pointer': !disabled,\n }\"\n ></ElIcon>\n <span v-if=\"content\" class=\"text-xs\">{{ content }}</span>\n </label>\n <input\n :id=\"uuid\"\n ref=\"inputField\"\n type=\"file\"\n class=\"hidden\"\n :accept=\"computedAcceptedFileExtensionsOrMimeType.join(',')\"\n :disabled=\"disabled\"\n :name=\"props.name || uuid\"\n :multiple=\"multiple\"\n @change.prevent=\"onChange\"\n />\n <ElFile\n v-for=\"(file, index) in value\"\n :key=\"`file-${index}`\"\n variant=\"primary\"\n :name=\"file.name\"\n :format=\"file.type\"\n class=\"w-full\"\n :disabled=\"disabled\"\n @close=\"removeFile(index)\"\n />\n </div>\n </ElInputContainer>\n</template>\n"],"names":["elInputFileTypes","props","__props","dragging","ref","inputField","emit","__emit","modelValue","toRef","computedAcceptedFileExtensionsOrMimeType","computed","computedValidation","validations","value","errorMessage","uuid","useInput","newValue","onChange","event","target","loadFilesAndClearInput","onDrop","newFiles","loadFiles","_a","newFilesArray","file","extensionOrMimeType","toast","removeFile","idx","_","i"],"mappings":"qcACaA,EAAmB,CAC9B,QACA,WACA,MACA,QACA,MACA,MACA,0BACA,gCACA,2BACA,4BACA,6BACA,8BACA,4BACA,+BACA,2BACA,2BACA,wCACA,6BACF,kSAYA,MAAMC,EAAQC,EAqBRC,EAAWC,MAAI,EAAK,EACpBC,EAAaD,EAAAA,MAEbE,EAAOC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../src/forms/ElInputFile.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputFileTypes = [\n 'image',\n 'document',\n 'csv',\n 'excel',\n 'any',\n 'zip',\n 'patientsImportDataFpfV5',\n 'patientsImportDataHippocrates',\n 'patientsImportDataIatros',\n 'patientsImportDataMdb2000',\n 'patientsImportDataMillewin',\n 'patientsImportDataPhronesis',\n 'patientsImportDataFastamb',\n 'patientsImportDataMedico2000',\n 'patientsImportDataTServe',\n 'patientsImportDataProfim',\n 'patientsImportDataMillewinAttachments',\n 'patientsImportDataAdvmednet',\n] as const;\nexport type ElInputFileType = (typeof elInputFileTypes)[number];\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, toRef, PropType } from 'vue';\nimport { useInput, withCommonElInputProps } from '@/forms/input';\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport ElFile from '@/ElFile.vue';\nimport ElIcon from '@/ElIcon.vue';\nimport { toast } from '@/ElToast.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: Array as () => File[],\n required: true,\n },\n content: {\n type: String,\n default: undefined,\n },\n multiple: {\n type: Boolean,\n default: false,\n },\n fileType: {\n type: String as PropType<ElInputFileType>,\n default: 'document',\n required: false,\n },\n});\n\nconst dragging = ref(false);\nconst inputField = ref<HTMLFormElement>();\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', files: File[]): void;\n}>();\n\nconst modelValue = toRef(props.modelValue);\n\nconst computedAcceptedFileExtensionsOrMimeType = computed<string[]>(() => {\n switch (props.fileType) {\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n return ['.mdb'];\n case 'patientsImportDataHippocrates':\n return ['.xml'];\n case 'patientsImportDataIatros':\n return ['.xml', '.mdb', '.sql', '.backup'];\n case 'patientsImportDataMillewin':\n return ['.sql', '.backup', '.db3'];\n case 'patientsImportDataPhronesis':\n return ['.sqlite', '.sqlite3', '.db', '.db3', '.s3db', '.sl3', '.gz'];\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n return ['.zip'];\n case 'image':\n return ['image/jpeg', 'image/png'];\n case 'document':\n // any pdf or word-like document\n return [\n '.doc',\n '.docx',\n '.xml',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n '.pdf',\n ];\n case 'csv':\n return ['.csv'];\n case 'excel':\n return ['.xlsx'];\n default:\n return ['*'];\n }\n});\nconst computedValidation = computed(() => {\n const validations = [props.validation];\n switch (props.fileType) {\n case 'image':\n validations.push('ext:jpg,png,jpeg');\n break;\n case 'document':\n validations.push('ext:doc,docs,xml,pdf');\n break;\n case 'csv':\n validations.push('ext:csv');\n break;\n case 'excel':\n validations.push('ext:xlsx');\n break;\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n validations.push('ext:mdb');\n break;\n case 'patientsImportDataHippocrates':\n validations.push('ext:xml');\n break;\n case 'patientsImportDataIatros':\n validations.push('ext:xml,mdb,sql,backup');\n break;\n case 'patientsImportDataMillewin':\n validations.push('ext:sql,backup,.db3');\n break;\n case 'patientsImportDataPhronesis':\n validations.push('ext:sqlite,sqlite3,db,db3,s3db,sl3,gz');\n break;\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n validations.push('ext:zip');\n break;\n default:\n break;\n }\n return validations;\n});\n\nconst { value, errorMessage, uuid } = useInput(modelValue, computedValidation, props.name, (newValue: File[]) => {\n emit('update:modelValue', newValue);\n});\n\nconst onChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (!target) return;\n loadFilesAndClearInput(target.files);\n};\n\nconst onDrop = (event: DragEvent) => {\n if (!event.dataTransfer) return;\n loadFilesAndClearInput(event.dataTransfer.files);\n dragging.value = false;\n};\n\nconst loadFilesAndClearInput = (newFiles: FileList | null) => {\n loadFiles(newFiles);\n if (inputField.value?.value) inputField.value.value = null;\n};\n\nconst loadFiles = (newFiles: FileList | null) => {\n if (!newFiles) return;\n const newFilesArray = [...newFiles];\n\n if (\n !newFilesArray.every(file =>\n computedAcceptedFileExtensionsOrMimeType.value.some(\n extensionOrMimeType =>\n file.name.toLowerCase().endsWith(extensionOrMimeType) ||\n file.type.toLowerCase() === extensionOrMimeType ||\n extensionOrMimeType === '*',\n ),\n )\n ) {\n return toast('Formato non supportato, verifica di aver inserito un file/s con il formato corretto', { state: 'error' });\n }\n\n value.value = [...value.value, ...newFilesArray];\n if (!props.multiple && value.value.length > 1) {\n value.value = [value.value[0]];\n }\n};\n\nconst removeFile = (idx: number) => {\n value.value = value.value.filter((_, i) => i !== idx);\n};\n</script>\n\n<template>\n <ElInputContainer\n v-bind=\"$attrs\"\n :name=\"uuid\"\n :label=\"label\"\n :error-message=\"props.errorMessage === false ? false : props.errorMessage || errorMessage\"\n :hidden-error-message=\"hiddenErrorMessage\"\n class=\"relative inline-block w-full\"\n >\n <div class=\"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20\">\n <label\n v-if=\"value.length == 0 || multiple\"\n tabIndex=\"0\"\n :for=\"uuid\"\n class=\"min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full\"\n :class=\"{\n 'bg-white': !dragging,\n 'bg-primary-light-hover': dragging,\n 'hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused':\n !disabled,\n 'border-gray-300 text-gray-300 cursor-not-allowed': disabled,\n 'border-primary': !disabled && !dragging,\n 'border-primary-hover': !disabled && dragging,\n }\"\n @dragover.prevent=\"dragging = true\"\n @drop.prevent=\"onDrop\"\n @dragenter.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n >\n <ElIcon\n name=\"ArrowUpCircleIcon\"\n :class=\"{\n 'w-5 h-5': content,\n 'w-7 h-7': !content,\n 'cursor-pointer': !disabled,\n }\"\n ></ElIcon>\n <span v-if=\"content\" class=\"text-xs\">{{ content }}</span>\n </label>\n <input\n :id=\"uuid\"\n ref=\"inputField\"\n type=\"file\"\n class=\"hidden\"\n :accept=\"computedAcceptedFileExtensionsOrMimeType.join(',')\"\n :disabled=\"disabled\"\n :name=\"props.name || uuid\"\n :multiple=\"multiple\"\n @change.prevent=\"onChange\"\n />\n <ElFile\n v-for=\"(file, index) in value\"\n :key=\"`file-${index}`\"\n variant=\"primary\"\n :name=\"file.name\"\n :format=\"file.type\"\n class=\"w-full\"\n :disabled=\"disabled\"\n @close=\"removeFile(index)\"\n />\n </div>\n </ElInputContainer>\n</template>\n"],"names":["elInputFileTypes","props","__props","dragging","ref","inputField","emit","__emit","modelValue","toRef","computedAcceptedFileExtensionsOrMimeType","computed","computedValidation","validations","value","errorMessage","uuid","useInput","newValue","onChange","event","target","loadFilesAndClearInput","onDrop","newFiles","loadFiles","_a","newFilesArray","file","extensionOrMimeType","toast","removeFile","idx","_","i"],"mappings":"qcACaA,EAAmB,CAC9B,QACA,WACA,MACA,QACA,MACA,MACA,0BACA,gCACA,2BACA,4BACA,6BACA,8BACA,4BACA,+BACA,2BACA,2BACA,wCACA,6BACF,kSAYA,MAAMC,EAAQC,EAqBRC,EAAWC,MAAI,EAAK,EACpBC,EAAaD,EAAAA,MAEbE,EAAOC,EAIPC,EAAaC,EAAAA,MAAMR,EAAM,UAAU,EAEnCS,EAA2CC,EAAAA,SAAmB,IAAM,CACxE,OAAQV,EAAM,SAAU,CACtB,IAAK,0BACL,IAAK,4BACL,IAAK,4BACL,IAAK,2BACH,MAAO,CAAC,MAAM,EAChB,IAAK,gCACH,MAAO,CAAC,MAAM,EAChB,IAAK,2BACH,MAAO,CAAC,OAAQ,OAAQ,OAAQ,SAAS,EAC3C,IAAK,6BACI,MAAA,CAAC,O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,OAChBC,GACLC,EAAuBD,EAAO,KAAK,CAAA,EAG/BE,EAAUH,GAAqB,CAC9BA,EAAM,eACYE,EAAAF,EAAM,aAAa,KAAK,EAC/CjB,EAAS,MAAQ,GAAA,EAGbmB,EAA0BE,GAA8B,OAC5DC,EAAUD,CAAQ,GACdE,EAAArB,EAAW,QAAX,MAAAqB,EAAkB,QAAOrB,EAAW,MAAM,MAAQ,KAAA,EAGlDoB,EAAaD,GAA8B,CAC/C,GAAI,CAACA,EAAU,OACT,MAAAG,EAAgB,CAAC,GAAGH,CAAQ,EAElC,GACE,CAACG,EAAc,MAAMC,GACnBlB,EAAyC,MAAM,KAE3CmB,GAAAD,EAAK,KAAK,YAAA,EAAc,SAASC,CAAmB,GACpDD,EAAK,KAAK,YAAY,IAAMC,GAC5BA,IAAwB,GAC5B,CAAA,EAGF,OAAOC,EAAM,MAAA,sFAAuF,CAAE,MAAO,OAAS,CAAA,EAGxHhB,EAAM,MAAQ,CAAC,GAAGA,EAAM,MAAO,GAAGa,CAAa,EAC3C,CAAC1B,EAAM,UAAYa,EAAM,MAAM,OAAS,IAC1CA,EAAM,MAAQ,CAACA,EAAM,MAAM,CAAC,CAAC,EAC/B,EAGIiB,EAAcC,GAAgB,CAC5BlB,EAAA,MAAQA,EAAM,MAAM,OAAO,CAACmB,EAAGC,IAAMA,IAAMF,CAAG,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as
|
|
1
|
+
import{defineComponent as $,ref as b,toRef as z,computed as g,openBlock as p,createBlock as h,mergeProps as P,unref as i,withCtx as T,createElementVNode as I,createElementBlock as c,normalizeClass as D,withModifiers as m,createVNode as E,toDisplayString as S,createCommentVNode as y,Fragment as j,renderList as B}from"vue";import{withCommonElInputProps as H,useInput as L}from"./input.esm.js";import N from"./ElInputContainer.vue.esm2.js";import R from"../ElFile.vue.esm2.js";import U from"../ElIcon.vue.esm2.js";import{toast as W}from"../ElToast.vue.esm2.js";const G={class:"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20"},J=["for"],K={key:0,class:"text-xs"},Q=["id","accept","disabled","name","multiple"],ae=["image","document","csv","excel","any","zip","patientsImportDataFpfV5","patientsImportDataHippocrates","patientsImportDataIatros","patientsImportDataMdb2000","patientsImportDataMillewin","patientsImportDataPhronesis","patientsImportDataFastamb","patientsImportDataMedico2000","patientsImportDataTServe","patientsImportDataProfim","patientsImportDataMillewinAttachments","patientsImportDataAdvmednet"],re=$({__name:"ElInputFile",props:{...H(),modelValue:{type:Array,required:!0},content:{type:String,default:void 0},multiple:{type:Boolean,default:!1},fileType:{type:String,default:"document",required:!1}},emits:["update:modelValue"],setup(n,{emit:w}){const r=n,o=b(!1),u=b(),x=w,k=z(r.modelValue),f=g(()=>{switch(r.fileType){case"patientsImportDataFpfV5":case"patientsImportDataMdb2000":case"patientsImportDataFastamb":case"patientsImportDataProfim":return[".mdb"];case"patientsImportDataHippocrates":return[".xml"];case"patientsImportDataIatros":return[".xml",".mdb",".sql",".backup"];case"patientsImportDataMillewin":return[".sql",".backup",".db3"];case"patientsImportDataPhronesis":return[".sqlite",".sqlite3",".db",".db3",".s3db",".sl3",".gz"];case"patientsImportDataTServe":case"patientsImportDataMedico2000":case"patientsImportDataMillewinAttachments":case"patientsImportDataAdvmednet":case"zip":return[".zip"];case"image":return["image/jpeg","image/png"];case"document":return[".doc",".docx",".xml","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document",".pdf"];case"csv":return[".csv"];case"excel":return[".xlsx"];default:return["*"]}}),F=g(()=>{const e=[r.validation];switch(r.fileType){case"image":e.push("ext:jpg,png,jpeg");break;case"document":e.push("ext:doc,docs,xml,pdf");break;case"csv":e.push("ext:csv");break;case"excel":e.push("ext:xlsx");break;case"patientsImportDataFpfV5":case"patientsImportDataMdb2000":case"patientsImportDataFastamb":case"patientsImportDataProfim":e.push("ext:mdb");break;case"patientsImportDataHippocrates":e.push("ext:xml");break;case"patientsImportDataIatros":e.push("ext:xml,mdb,sql,backup");break;case"patientsImportDataMillewin":e.push("ext:sql,backup,.db3");break;case"patientsImportDataPhronesis":e.push("ext:sqlite,sqlite3,db,db3,s3db,sl3,gz");break;case"patientsImportDataTServe":case"patientsImportDataMedico2000":case"patientsImportDataMillewinAttachments":case"patientsImportDataAdvmednet":case"zip":e.push("ext:zip");break}return e}),{value:s,errorMessage:M,uuid:d}=L(k,F,r.name,e=>{x("update:modelValue",e)}),C=e=>{const t=e.target;t&&v(t.files)},V=e=>{e.dataTransfer&&(v(e.dataTransfer.files),o.value=!1)},v=e=>{var t;A(e),(t=u.value)!=null&&t.value&&(u.value.value=null)},A=e=>{if(!e)return;const t=[...e];if(!t.every(a=>f.value.some(l=>a.name.toLowerCase().endsWith(l)||a.type.toLowerCase()===l||l==="*")))return W("Formato non supportato, verifica di aver inserito un file/s con il formato corretto",{state:"error"});s.value=[...s.value,...t],!r.multiple&&s.value.length>1&&(s.value=[s.value[0]])},q=e=>{s.value=s.value.filter((t,a)=>a!==e)};return(e,t)=>(p(),h(N,P(e.$attrs,{name:i(d),label:e.label,"error-message":r.errorMessage===!1?!1:r.errorMessage||i(M),"hidden-error-message":e.hiddenErrorMessage,class:"relative inline-block w-full"}),{default:T(()=>[I("div",G,[i(s).length==0||n.multiple?(p(),c("label",{key:0,tabIndex:"0",for:i(d),class:D(["min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full",{"bg-white":!o.value,"bg-primary-light-hover":o.value,"hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused":!e.disabled,"border-gray-300 text-gray-300 cursor-not-allowed":e.disabled,"border-primary":!e.disabled&&!o.value,"border-primary-hover":!e.disabled&&o.value}]),onDragover:t[0]||(t[0]=m(a=>o.value=!0,["prevent"])),onDrop:m(V,["prevent"]),onDragenter:t[1]||(t[1]=m(a=>o.value=!0,["prevent"])),onDragleave:t[2]||(t[2]=m(a=>o.value=!1,["prevent"]))},[E(U,{name:"ArrowUpCircleIcon",class:D({"w-5 h-5":n.content,"w-7 h-7":!n.content,"cursor-pointer":!e.disabled})},null,8,["class"]),n.content?(p(),c("span",K,S(n.content),1)):y("",!0)],42,J)):y("",!0),I("input",{id:i(d),ref_key:"inputField",ref:u,type:"file",class:"hidden",accept:f.value.join(","),disabled:e.disabled,name:r.name||i(d),multiple:n.multiple,onChange:m(C,["prevent"])},null,40,Q),(p(!0),c(j,null,B(i(s),(a,l)=>(p(),h(R,{key:`file-${l}`,variant:"primary",name:a.name,format:a.type,class:"w-full",disabled:e.disabled,onClose:X=>q(l)},null,8,["name","format","disabled","onClose"]))),128))])]),_:1},16,["name","label","error-message","hidden-error-message"]))}});export{re as default,ae as elInputFileTypes};
|
|
2
2
|
//# sourceMappingURL=ElInputFile.vue.esm2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElInputFile.vue.esm2.js","sources":["../../src/forms/ElInputFile.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputFileTypes = [\n 'image',\n 'document',\n 'csv',\n 'excel',\n 'any',\n 'zip',\n 'patientsImportDataFpfV5',\n 'patientsImportDataHippocrates',\n 'patientsImportDataIatros',\n 'patientsImportDataMdb2000',\n 'patientsImportDataMillewin',\n 'patientsImportDataPhronesis',\n 'patientsImportDataFastamb',\n 'patientsImportDataMedico2000',\n 'patientsImportDataTServe',\n 'patientsImportDataProfim',\n 'patientsImportDataMillewinAttachments',\n 'patientsImportDataAdvmednet',\n] as const;\nexport type ElInputFileType = (typeof elInputFileTypes)[number];\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, toRef, PropType } from 'vue';\nimport { useInput, withCommonElInputProps } from '@/forms/input';\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport ElFile from '@/ElFile.vue';\nimport ElIcon from '@/ElIcon.vue';\nimport { toast } from '@/ElToast.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: Array as () => File[],\n required: true,\n },\n content: {\n type: String,\n default: undefined,\n },\n multiple: {\n type: Boolean,\n default: false,\n },\n fileType: {\n type: String as PropType<ElInputFileType>,\n default: 'document',\n required: false,\n },\n});\n\nconst dragging = ref(false);\nconst inputField = ref<HTMLFormElement>();\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', files: File[]): void;\n}>();\n\nconst modelValue = toRef(props.modelValue);\n\nconst computedAcceptedFileExtensionsOrMimeType = computed<string[]>(() => {\n switch (props.fileType) {\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n return ['.mdb', '.zip'];\n case 'patientsImportDataHippocrates':\n return ['.xml', '.zip'];\n case 'patientsImportDataIatros':\n return ['.xml', '.mdb', '.sql', '.backup', '.zip'];\n case 'patientsImportDataMillewin':\n return ['.sql', '.backup', '.db3', '.zip'];\n case 'patientsImportDataPhronesis':\n return ['.sqlite', '.sqlite3', '.db', '.db3', '.s3db', '.sl3', '.gz'];\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n return ['.zip'];\n case 'image':\n return ['image/jpeg', 'image/png'];\n case 'document':\n // any pdf or word-like document\n return [\n '.doc',\n '.docx',\n '.xml',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n '.pdf',\n ];\n case 'csv':\n return ['.csv'];\n case 'excel':\n return ['.xlsx'];\n default:\n return ['*'];\n }\n});\nconst computedValidation = computed(() => {\n const validations = [props.validation];\n switch (props.fileType) {\n case 'image':\n validations.push('ext:jpg,png,jpeg');\n break;\n case 'document':\n validations.push('ext:doc,docs,xml,pdf');\n break;\n case 'csv':\n validations.push('ext:csv');\n break;\n case 'excel':\n validations.push('ext:xlsx');\n break;\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n validations.push('ext:mdb,zip');\n break;\n case 'patientsImportDataHippocrates':\n validations.push('ext:xml,zip');\n break;\n case 'patientsImportDataIatros':\n validations.push('ext:xml,mdb,sql,backup,zip');\n break;\n case 'patientsImportDataMillewin':\n validations.push('ext:sql,backup,.db3,zip');\n break;\n case 'patientsImportDataPhronesis':\n validations.push('ext:sqlite,sqlite3,db,db3,s3db,sl3,gz');\n break;\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n validations.push('ext:zip');\n break;\n default:\n break;\n }\n return validations;\n});\n\nconst { value, errorMessage, uuid } = useInput(modelValue, computedValidation, props.name, (newValue: File[]) => {\n emit('update:modelValue', newValue);\n});\n\nconst onChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (!target) return;\n loadFilesAndClearInput(target.files);\n};\n\nconst onDrop = (event: DragEvent) => {\n if (!event.dataTransfer) return;\n loadFilesAndClearInput(event.dataTransfer.files);\n dragging.value = false;\n};\n\nconst loadFilesAndClearInput = (newFiles: FileList | null) => {\n loadFiles(newFiles);\n if (inputField.value?.value) inputField.value.value = null;\n};\n\nconst loadFiles = (newFiles: FileList | null) => {\n if (!newFiles) return;\n const newFilesArray = [...newFiles];\n\n if (\n !newFilesArray.every(file =>\n computedAcceptedFileExtensionsOrMimeType.value.some(\n extensionOrMimeType =>\n file.name.toLowerCase().endsWith(extensionOrMimeType) ||\n file.type.toLowerCase() === extensionOrMimeType ||\n extensionOrMimeType === '*',\n ),\n )\n ) {\n return toast('Formato non supportato, verifica di aver inserito un file/s con il formato corretto', { state: 'error' });\n }\n\n value.value = [...value.value, ...newFilesArray];\n if (!props.multiple && value.value.length > 1) {\n value.value = [value.value[0]];\n }\n};\n\nconst removeFile = (idx: number) => {\n value.value = value.value.filter((_, i) => i !== idx);\n};\n</script>\n\n<template>\n <ElInputContainer\n v-bind=\"$attrs\"\n :name=\"uuid\"\n :label=\"label\"\n :error-message=\"props.errorMessage === false ? false : props.errorMessage || errorMessage\"\n :hidden-error-message=\"hiddenErrorMessage\"\n class=\"relative inline-block w-full\"\n >\n <div class=\"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20\">\n <label\n v-if=\"value.length == 0 || multiple\"\n tabIndex=\"0\"\n :for=\"uuid\"\n class=\"min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full\"\n :class=\"{\n 'bg-white': !dragging,\n 'bg-primary-light-hover': dragging,\n 'hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused':\n !disabled,\n 'border-gray-300 text-gray-300 cursor-not-allowed': disabled,\n 'border-primary': !disabled && !dragging,\n 'border-primary-hover': !disabled && dragging,\n }\"\n @dragover.prevent=\"dragging = true\"\n @drop.prevent=\"onDrop\"\n @dragenter.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n >\n <ElIcon\n name=\"ArrowUpCircleIcon\"\n :class=\"{\n 'w-5 h-5': content,\n 'w-7 h-7': !content,\n 'cursor-pointer': !disabled,\n }\"\n ></ElIcon>\n <span v-if=\"content\" class=\"text-xs\">{{ content }}</span>\n </label>\n <input\n :id=\"uuid\"\n ref=\"inputField\"\n type=\"file\"\n class=\"hidden\"\n :accept=\"computedAcceptedFileExtensionsOrMimeType.join(',')\"\n :disabled=\"disabled\"\n :name=\"props.name || uuid\"\n :multiple=\"multiple\"\n @change.prevent=\"onChange\"\n />\n <ElFile\n v-for=\"(file, index) in value\"\n :key=\"`file-${index}`\"\n variant=\"primary\"\n :name=\"file.name\"\n :format=\"file.type\"\n class=\"w-full\"\n :disabled=\"disabled\"\n @close=\"removeFile(index)\"\n />\n </div>\n </ElInputContainer>\n</template>\n"],"names":["elInputFileTypes","props","__props","dragging","ref","inputField","emit","__emit","modelValue","toRef","computedAcceptedFileExtensionsOrMimeType","computed","computedValidation","validations","value","errorMessage","uuid","useInput","newValue","onChange","event","target","loadFilesAndClearInput","onDrop","newFiles","loadFiles","_a","newFilesArray","file","extensionOrMimeType","toast","removeFile","idx","_","i"],"mappings":"ssBACaA,GAAmB,CAC9B,QACA,WACA,MACA,QACA,MACA,MACA,0BACA,gCACA,2BACA,4BACA,6BACA,8BACA,4BACA,+BACA,2BACA,2BACA,wCACA,6BACF,4PAYA,MAAMC,EAAQC,EAqBRC,EAAWC,EAAI,EAAK,EACpBC,EAAaD,IAEbE,EAAOC,EAIPC,EAAaC,EAAMR,EAAM,UAAU,EAEnCS,EAA2CC,EAAmB,IAAM,CACxE,OAAQV,EAAM,SAAU,CACtB,IAAK,0BACL,IAAK,4BACL,IAAK,4BACL,IAAK,2BACI,MAAA,CAAC,OAAQ,MAAM,EACxB,IAAK,gCACI,MAAA,CAAC,OAAQ,MAAM,EACxB,IAAK,2BACH,MAAO,CAAC,OAAQ,OAAQ,OAAQ,UAAW,MAAM,EACnD,IAAK,6BACH,MAAO,CAAC,OAAQ,UAAW,OAAQ,MAAM,EAC3C,IAAK,8BACH,MAAO,CAAC,UAAW,WAAY,MAAO,OAAQ,QAAS,OAAQ,KAAK,EACtE,IAAK,2BACL,IAAK,+BACL,IAAK,wCACL,IAAK,8BACL,IAAK,MACH,MAAO,CAAC,MAAM,EAChB,IAAK,QACI,MAAA,CAAC,aAAc,WAAW,EACnC,IAAK,WAEI,MAAA,CACL,OACA,QACA,OACA,qBACA,0EACA,MAAA,EAEJ,IAAK,MACH,MAAO,CAAC,MAAM,EAChB,IAAK,QACH,MAAO,CAAC,OAAO,EACjB,QACE,MAAO,CAAC,GAAG,CACf,CAAA,CACD,EACKW,EAAqBD,EAAS,IAAM,CAClC,MAAAE,EAAc,CAACZ,EAAM,UAAU,EACrC,OAAQA,EAAM,SAAU,CACtB,IAAK,QACHY,EAAY,KAAK,kBAAkB,EACnC,MACF,IAAK,WACHA,EAAY,KAAK,sBAAsB,EACvC,MACF,IAAK,MACHA,E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A,EAAM,MAAO,GAAGa,CAAa,EAC3C,CAAC1B,EAAM,UAAYa,EAAM,MAAM,OAAS,IAC1CA,EAAM,MAAQ,CAACA,EAAM,MAAM,CAAC,CAAC,EAC/B,EAGIiB,EAAcC,GAAgB,CAC5BlB,EAAA,MAAQA,EAAM,MAAM,OAAO,CAACmB,EAAGC,IAAMA,IAAMF,CAAG,CAAA"}
|
|
1
|
+
{"version":3,"file":"ElInputFile.vue.esm2.js","sources":["../../src/forms/ElInputFile.vue"],"sourcesContent":["<script lang=\"ts\">\nexport const elInputFileTypes = [\n 'image',\n 'document',\n 'csv',\n 'excel',\n 'any',\n 'zip',\n 'patientsImportDataFpfV5',\n 'patientsImportDataHippocrates',\n 'patientsImportDataIatros',\n 'patientsImportDataMdb2000',\n 'patientsImportDataMillewin',\n 'patientsImportDataPhronesis',\n 'patientsImportDataFastamb',\n 'patientsImportDataMedico2000',\n 'patientsImportDataTServe',\n 'patientsImportDataProfim',\n 'patientsImportDataMillewinAttachments',\n 'patientsImportDataAdvmednet',\n] as const;\nexport type ElInputFileType = (typeof elInputFileTypes)[number];\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, toRef, PropType } from 'vue';\nimport { useInput, withCommonElInputProps } from '@/forms/input';\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport ElFile from '@/ElFile.vue';\nimport ElIcon from '@/ElIcon.vue';\nimport { toast } from '@/ElToast.vue';\n\nconst props = defineProps({\n ...withCommonElInputProps(),\n modelValue: {\n type: Array as () => File[],\n required: true,\n },\n content: {\n type: String,\n default: undefined,\n },\n multiple: {\n type: Boolean,\n default: false,\n },\n fileType: {\n type: String as PropType<ElInputFileType>,\n default: 'document',\n required: false,\n },\n});\n\nconst dragging = ref(false);\nconst inputField = ref<HTMLFormElement>();\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', files: File[]): void;\n}>();\n\nconst modelValue = toRef(props.modelValue);\n\nconst computedAcceptedFileExtensionsOrMimeType = computed<string[]>(() => {\n switch (props.fileType) {\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n return ['.mdb'];\n case 'patientsImportDataHippocrates':\n return ['.xml'];\n case 'patientsImportDataIatros':\n return ['.xml', '.mdb', '.sql', '.backup'];\n case 'patientsImportDataMillewin':\n return ['.sql', '.backup', '.db3'];\n case 'patientsImportDataPhronesis':\n return ['.sqlite', '.sqlite3', '.db', '.db3', '.s3db', '.sl3', '.gz'];\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n return ['.zip'];\n case 'image':\n return ['image/jpeg', 'image/png'];\n case 'document':\n // any pdf or word-like document\n return [\n '.doc',\n '.docx',\n '.xml',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n '.pdf',\n ];\n case 'csv':\n return ['.csv'];\n case 'excel':\n return ['.xlsx'];\n default:\n return ['*'];\n }\n});\nconst computedValidation = computed(() => {\n const validations = [props.validation];\n switch (props.fileType) {\n case 'image':\n validations.push('ext:jpg,png,jpeg');\n break;\n case 'document':\n validations.push('ext:doc,docs,xml,pdf');\n break;\n case 'csv':\n validations.push('ext:csv');\n break;\n case 'excel':\n validations.push('ext:xlsx');\n break;\n case 'patientsImportDataFpfV5':\n case 'patientsImportDataMdb2000':\n case 'patientsImportDataFastamb':\n case 'patientsImportDataProfim':\n validations.push('ext:mdb');\n break;\n case 'patientsImportDataHippocrates':\n validations.push('ext:xml');\n break;\n case 'patientsImportDataIatros':\n validations.push('ext:xml,mdb,sql,backup');\n break;\n case 'patientsImportDataMillewin':\n validations.push('ext:sql,backup,.db3');\n break;\n case 'patientsImportDataPhronesis':\n validations.push('ext:sqlite,sqlite3,db,db3,s3db,sl3,gz');\n break;\n case 'patientsImportDataTServe':\n case 'patientsImportDataMedico2000':\n case 'patientsImportDataMillewinAttachments':\n case 'patientsImportDataAdvmednet':\n case 'zip':\n validations.push('ext:zip');\n break;\n default:\n break;\n }\n return validations;\n});\n\nconst { value, errorMessage, uuid } = useInput(modelValue, computedValidation, props.name, (newValue: File[]) => {\n emit('update:modelValue', newValue);\n});\n\nconst onChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (!target) return;\n loadFilesAndClearInput(target.files);\n};\n\nconst onDrop = (event: DragEvent) => {\n if (!event.dataTransfer) return;\n loadFilesAndClearInput(event.dataTransfer.files);\n dragging.value = false;\n};\n\nconst loadFilesAndClearInput = (newFiles: FileList | null) => {\n loadFiles(newFiles);\n if (inputField.value?.value) inputField.value.value = null;\n};\n\nconst loadFiles = (newFiles: FileList | null) => {\n if (!newFiles) return;\n const newFilesArray = [...newFiles];\n\n if (\n !newFilesArray.every(file =>\n computedAcceptedFileExtensionsOrMimeType.value.some(\n extensionOrMimeType =>\n file.name.toLowerCase().endsWith(extensionOrMimeType) ||\n file.type.toLowerCase() === extensionOrMimeType ||\n extensionOrMimeType === '*',\n ),\n )\n ) {\n return toast('Formato non supportato, verifica di aver inserito un file/s con il formato corretto', { state: 'error' });\n }\n\n value.value = [...value.value, ...newFilesArray];\n if (!props.multiple && value.value.length > 1) {\n value.value = [value.value[0]];\n }\n};\n\nconst removeFile = (idx: number) => {\n value.value = value.value.filter((_, i) => i !== idx);\n};\n</script>\n\n<template>\n <ElInputContainer\n v-bind=\"$attrs\"\n :name=\"uuid\"\n :label=\"label\"\n :error-message=\"props.errorMessage === false ? false : props.errorMessage || errorMessage\"\n :hidden-error-message=\"hiddenErrorMessage\"\n class=\"relative inline-block w-full\"\n >\n <div class=\"flex flex-col gap-2 min-w-0 sm:min-w-80 min-h-20\">\n <label\n v-if=\"value.length == 0 || multiple\"\n tabIndex=\"0\"\n :for=\"uuid\"\n class=\"min-h-20 p-4 flex flex-col gap-2 items-center justify-center rounded border outline-none border-dashed w-full\"\n :class=\"{\n 'bg-white': !dragging,\n 'bg-primary-light-hover': dragging,\n 'hover:bg-primary-light-hover hover:text-primary-hover hover:border-primary-hover group-focus-within:bg-primary-light-focused group-focus-within:text-primary-focused group-focus-within:border-primary-light-focused':\n !disabled,\n 'border-gray-300 text-gray-300 cursor-not-allowed': disabled,\n 'border-primary': !disabled && !dragging,\n 'border-primary-hover': !disabled && dragging,\n }\"\n @dragover.prevent=\"dragging = true\"\n @drop.prevent=\"onDrop\"\n @dragenter.prevent=\"dragging = true\"\n @dragleave.prevent=\"dragging = false\"\n >\n <ElIcon\n name=\"ArrowUpCircleIcon\"\n :class=\"{\n 'w-5 h-5': content,\n 'w-7 h-7': !content,\n 'cursor-pointer': !disabled,\n }\"\n ></ElIcon>\n <span v-if=\"content\" class=\"text-xs\">{{ content }}</span>\n </label>\n <input\n :id=\"uuid\"\n ref=\"inputField\"\n type=\"file\"\n class=\"hidden\"\n :accept=\"computedAcceptedFileExtensionsOrMimeType.join(',')\"\n :disabled=\"disabled\"\n :name=\"props.name || uuid\"\n :multiple=\"multiple\"\n @change.prevent=\"onChange\"\n />\n <ElFile\n v-for=\"(file, index) in value\"\n :key=\"`file-${index}`\"\n variant=\"primary\"\n :name=\"file.name\"\n :format=\"file.type\"\n class=\"w-full\"\n :disabled=\"disabled\"\n @close=\"removeFile(index)\"\n />\n </div>\n </ElInputContainer>\n</template>\n"],"names":["elInputFileTypes","props","__props","dragging","ref","inputField","emit","__emit","modelValue","toRef","computedAcceptedFileExtensionsOrMimeType","computed","computedValidation","validations","value","errorMessage","uuid","useInput","newValue","onChange","event","target","loadFilesAndClearInput","onDrop","newFiles","loadFiles","_a","newFilesArray","file","extensionOrMimeType","toast","removeFile","idx","_","i"],"mappings":"ssBACaA,GAAmB,CAC9B,QACA,WACA,MACA,QACA,MACA,MACA,0BACA,gCACA,2BACA,4BACA,6BACA,8BACA,4BACA,+BACA,2BACA,2BACA,wCACA,6BACF,4PAYA,MAAMC,EAAQC,EAqBRC,EAAWC,EAAI,EAAK,EACpBC,EAAaD,IAEbE,EAAOC,EAIPC,EAAaC,EAA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