@davincihealthcare/elty-design-system-vue 1.73.0 → 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.
- package/dist/forms/ElInputFile.vue.cjs2.js +1 -1
- package/dist/forms/ElInputFile.vue.cjs2.js.map +1 -1
- package/dist/forms/ElInputFile.vue.esm2.js +1 -1
- package/dist/forms/ElInputFile.vue.esm2.js.map +1 -1
- package/dist/forms/ElInputNumber.vue.cjs2.js +1 -1
- package/dist/forms/ElInputNumber.vue.cjs2.js.map +1 -1
- package/dist/forms/ElInputNumber.vue.esm2.js +1 -1
- package/dist/forms/ElInputNumber.vue.esm2.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,EAIPC,EAAaC,EAAAA,MAAMR,EAAM,UAAU,EAEnCS,EAA2CC,EAAAA,SAAmB,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,EAAAA,SAAS,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,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GxHhB,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
|
+
{"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'];\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,E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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,0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A8B,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,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
|
+
{"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,EAAMR,EAAM,UAAU,EAEnCS,EAA2CC,EAAmB,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,OAAQ,UAAW,MAAM,EACnC,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,EAAY,KAAK,SAAS,EAC1B,MACF,IAAK,QACHA,EAAY,KAA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Ya,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
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),h=require("./ElInputContainer.vue.cjs2.js"),n=require("./input.cjs.js"),M=["id","name","type","step","min","max","placeholder","disabled","data-cy"],V=l.defineComponent({__name:"ElInputNumber",props:{...n.withNumberElInputProps(),isTwoDecimals:{type:Boolean,default:!1},defaultNullValueToZeroOnBlur:{type:Boolean,default:!0}},emits:["update:modelValue","overlayedBtnClicked","update:formattedAmount"],setup(d,{emit:m}){const a=d,o=m,p=l.ref(!1),f=l.computed(()=>a.modelValue),v=l.computed(()=>[a.validation]),{value:u,errorMessage:c,uuid:s,fieldContext:b}=n.useInput(f,v,a.name,e=>{o("update:modelValue",e),o("update:formattedAmount",r.value)}),r=l.computed({get:()=>u.value===null||u.value===void 0||typeof u.value=="string"&&u.value===""?null:typeof u.value=="string"?Number(u.value):a.isTwoDecimals?parseFloat((u.value/100).toFixed(2)):u.value,set:e=>{if(e===""||e===null){u.value=null;return}const t=Number(e);isNaN(t)?u.value=t:a.isTwoDecimals?u.value=Math.round(t*100):u.value=t}}),g=e=>{const t=Number(e.target.value);b.validate(),a.min&&t&&t<a.min&&(u.value=a.min),a.max&&t&&t>a.max&&(u.value=a.max),a.defaultNullValueToZeroOnBlur&&y()},y=()=>{u.value||(u.value=0)};return(e,t)=>(l.openBlock(),l.createBlock(h.default,l.mergeProps(e.$attrs,{name:l.unref(s),label:e.label,"error-message":a.errorMessage===!1?!1:a.errorMessage||l.unref(c),"hidden-error-message":e.hiddenErrorMessage,"set-required-mark":l.unref(n.showRequiredMark)([e.validation])}),{default:l.withCtx(({error:N})=>[l.withDirectives(l.createElementVNode("input",{id:l.unref(s),"onUpdate:modelValue":[t[0]||(t[0]=i=>r.value=i),t[1]||(t[1]=i=>p.value=!0)],name:a.name,type:a.isTwoDecimals?"text":"number",step:e.step,min:e.min,max:e.max,placeholder:e.placeholder,disabled:e.disabled,class:l.normalizeClass(["el-input",{error:N}]),"data-cy":e.label?`${e.label.trim().replaceAll(" ","")}-number-input`:"number-input",onBlur:g},null,42,M),[[l.vModelDynamic,r.value]])]),_:1},16,["name","label","error-message","hidden-error-message","set-required-mark"]))}});exports.default=V;
|
|
2
2
|
//# sourceMappingURL=ElInputNumber.vue.cjs2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElInputNumber.vue.cjs2.js","sources":["../../src/forms/ElInputNumber.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport { useInput, NumberValueType, showRequiredMark, withNumberElInputProps } from '@/forms/input';\nimport { computed, ref } from 'vue';\n\nconst props = defineProps({\n ...withNumberElInputProps(),\n isTwoDecimals: {\n type: Boolean,\n default: false,\n },\n defaultNullValueToZeroOnBlur: {\n type: Boolean,\n default: true,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: NumberValueType): void;\n (event: 'overlayedBtnClicked'): void;\n (event: 'update:formattedAmount', value: NumberValueType): void;\n}>();\n\nconst showOverlayedIcon = ref(false);\nconst computedModelValue = computed(() => {\n return props.modelValue;\n});\n\nconst computedValidation = computed(() => [props.validation]);\n\nconst { value, errorMessage, uuid, fieldContext } = useInput(computedModelValue, computedValidation, props.name, newValue => {\n emit('update:modelValue', newValue);\n emit('update:formattedAmount', formattedAmount.value);\n});\n\nconst formattedAmount = computed<number | null>({\n get: () => {\n if (value.value === null || value.value === undefined) return null;\n if (typeof value.value === 'string' && value.value === '') return null;\n if (typeof value.value === 'string') return Number(value.value);\n\n if (props.isTwoDecimals) {\n return parseFloat((value.value / 100).toFixed(2));\n }\n\n return value.value;\n },\n set: (inputValue: number | null | string) => {\n if (inputValue === '' || inputValue === null) {\n value.value = null;\n return;\n }\n\n const numValue = Number(inputValue);\n if (!isNaN(numValue)) {\n if (props.isTwoDecimals) {\n value.value = Math.round(numValue * 100);\n } else {\n value.value = numValue;\n }\n }\n },\n});\n\nconst onBlur = () => {\n fieldContext.validate();\n\n if (props.defaultNullValueToZeroOnBlur) {\n resetNullValueToZero();\n }\n};\n\nconst resetNullValueToZero = () => {\n if (!value.value) {\n value.value = 0;\n }\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 :set-required-mark=\"showRequiredMark([validation])\"\n >\n <template #default=\"{ error }\">\n <input\n :id=\"uuid\"\n
|
|
1
|
+
{"version":3,"file":"ElInputNumber.vue.cjs2.js","sources":["../../src/forms/ElInputNumber.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport { useInput, NumberValueType, showRequiredMark, withNumberElInputProps } from '@/forms/input';\nimport { computed, ref } from 'vue';\n\nconst props = defineProps({\n ...withNumberElInputProps(),\n isTwoDecimals: {\n type: Boolean,\n default: false,\n },\n defaultNullValueToZeroOnBlur: {\n type: Boolean,\n default: true,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: NumberValueType): void;\n (event: 'overlayedBtnClicked'): void;\n (event: 'update:formattedAmount', value: NumberValueType): void;\n}>();\n\nconst showOverlayedIcon = ref(false);\nconst computedModelValue = computed(() => {\n return props.modelValue;\n});\n\nconst computedValidation = computed(() => [props.validation]);\n\nconst { value, errorMessage, uuid, fieldContext } = useInput(computedModelValue, computedValidation, props.name, newValue => {\n emit('update:modelValue', newValue);\n emit('update:formattedAmount', formattedAmount.value);\n});\n\nconst formattedAmount = computed<number | null>({\n get: () => {\n if (value.value === null || value.value === undefined) return null;\n if (typeof value.value === 'string' && value.value === '') return null;\n if (typeof value.value === 'string') return Number(value.value);\n\n if (props.isTwoDecimals) {\n return parseFloat((value.value / 100).toFixed(2));\n }\n\n return value.value;\n },\n set: (inputValue: number | null | string) => {\n if (inputValue === '' || inputValue === null) {\n value.value = null;\n return;\n }\n\n const numValue = Number(inputValue);\n if (!isNaN(numValue)) {\n if (props.isTwoDecimals) {\n value.value = Math.round(numValue * 100);\n } else {\n value.value = numValue;\n }\n } else {\n value.value = numValue;\n }\n },\n});\n\nconst onBlur = (event: Event) => {\n const inputValue = Number((event.target as HTMLInputElement).value);\n fieldContext.validate();\n\n // if props.min and / or props.max are set, check if the value is within the range\n if (props.min && inputValue && inputValue < props.min) {\n value.value = props.min;\n }\n\n if (props.max && inputValue && inputValue > props.max) {\n value.value = props.max;\n }\n\n if (props.defaultNullValueToZeroOnBlur) {\n resetNullValueToZero();\n }\n};\n\nconst resetNullValueToZero = () => {\n if (!value.value) {\n value.value = 0;\n }\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 :set-required-mark=\"showRequiredMark([validation])\"\n >\n <template #default=\"{ error }\">\n <input\n :id=\"uuid\"\n v-model=\"formattedAmount\"\n :name=\"props.name\"\n :type=\"props.isTwoDecimals ? 'text' : 'number'\"\n :step=\"step\"\n :min=\"min\"\n :max=\"max\"\n :placeholder=\"placeholder\"\n :disabled=\"disabled\"\n class=\"el-input\"\n :class=\"{ error }\"\n :data-cy=\"label ? `${label.trim().replaceAll(' ', '')}-number-input` : `number-input`\"\n @blur=\"onBlur\"\n @update:model-value=\"showOverlayedIcon = true\"\n />\n </template>\n </ElInputContainer>\n</template>\n"],"names":["props","__props","emit","__emit","showOverlayedIcon","ref","computedModelValue","computed","computedValidation","value","errorMessage","uuid","fieldContext","useInput","newValue","formattedAmount","inputValue","numValue","onBlur","event","resetNullValueToZero"],"mappings":"siBAKA,MAAMA,EAAQC,EAYRC,EAAOC,EAMPC,EAAoBC,MAAI,EAAK,EAC7BC,EAAqBC,EAAAA,SAAS,IAC3BP,EAAM,UACd,EAEKQ,EAAqBD,EAAAA,SAAS,IAAM,CAACP,EAAM,UAAU,CAAC,EAEtD,CAAE,MAAAS,EAAO,aAAAC,EAAc,KAAAC,EAAM,aAAAC,CAAiB,EAAAC,WAASP,EAAoBE,EAAoBR,EAAM,KAAkBc,GAAA,CAC3HZ,EAAK,oBAAqBY,CAAQ,EAC7BZ,EAAA,yBAA0Ba,EAAgB,KAAK,CAAA,CACrD,EAEKA,EAAkBR,EAAAA,SAAwB,CAC9C,IAAK,IACCE,EAAM,QAAU,MAAQA,EAAM,QAAU,QACxC,OAAOA,EAAM,OAAU,UAAYA,EAAM,QAAU,GAAW,KAC9D,OAAOA,EAAM,OAAU,SAAiB,OAAOA,EAAM,KAAK,EAE1DT,EAAM,cACD,YAAYS,EAAM,MAAQ,KAAK,QAAQ,CAAC,CAAC,EAG3CA,EAAM,MAEf,IAAMO,GAAuC,CACvC,GAAAA,IAAe,IAAMA,IAAe,KAAM,CAC5CP,EAAM,MAAQ,KACd,MACF,CAEM,MAAAQ,EAAW,OAAOD,CAAU,EAC7B,MAAMC,CAAQ,EAOjBR,EAAM,MAAQQ,EANVjB,EAAM,cACRS,EAAM,MAAQ,KAAK,MAAMQ,EAAW,GAAG,EAEvCR,EAAM,MAAQQ,CAKpB,CAAA,CACD,EAEKC,EAAUC,GAAiB,CAC/B,MAAMH,EAAa,OAAQG,EAAM,OAA4B,KAAK,EAClEP,EAAa,SAAS,EAGlBZ,EAAM,KAAOgB,GAAcA,EAAahB,EAAM,MAChDS,EAAM,MAAQT,EAAM,KAGlBA,EAAM,KAAOgB,GAAcA,EAAahB,EAAM,MAChDS,EAAM,MAAQT,EAAM,KAGlBA,EAAM,8BACaoB,GACvB,EAGIA,EAAuB,IAAM,CAC5BX,EAAM,QACTA,EAAM,MAAQ,EAChB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as
|
|
1
|
+
import{defineComponent as h,ref as V,computed as o,openBlock as w,createBlock as B,mergeProps as M,unref as t,withCtx as T,withDirectives as k,createElementVNode as D,normalizeClass as C,vModelDynamic as A}from"vue";import E from"./ElInputContainer.vue.esm2.js";import{withNumberElInputProps as I,useInput as $,showRequiredMark as q}from"./input.esm.js";const O=["id","name","type","step","min","max","placeholder","disabled","data-cy"],x=h({__name:"ElInputNumber",props:{...I(),isTwoDecimals:{type:Boolean,default:!1},defaultNullValueToZeroOnBlur:{type:Boolean,default:!0}},emits:["update:modelValue","overlayedBtnClicked","update:formattedAmount"],setup(m,{emit:d}){const a=m,n=d,p=V(!1),f=o(()=>a.modelValue),v=o(()=>[a.validation]),{value:l,errorMessage:c,uuid:s,fieldContext:b}=$(f,v,a.name,e=>{n("update:modelValue",e),n("update:formattedAmount",u.value)}),u=o({get:()=>l.value===null||l.value===void 0||typeof l.value=="string"&&l.value===""?null:typeof l.value=="string"?Number(l.value):a.isTwoDecimals?parseFloat((l.value/100).toFixed(2)):l.value,set:e=>{if(e===""||e===null){l.value=null;return}const r=Number(e);isNaN(r)?l.value=r:a.isTwoDecimals?l.value=Math.round(r*100):l.value=r}}),g=e=>{const r=Number(e.target.value);b.validate(),a.min&&r&&r<a.min&&(l.value=a.min),a.max&&r&&r>a.max&&(l.value=a.max),a.defaultNullValueToZeroOnBlur&&y()},y=()=>{l.value||(l.value=0)};return(e,r)=>(w(),B(E,M(e.$attrs,{name:t(s),label:e.label,"error-message":a.errorMessage===!1?!1:a.errorMessage||t(c),"hidden-error-message":e.hiddenErrorMessage,"set-required-mark":t(q)([e.validation])}),{default:T(({error:N})=>[k(D("input",{id:t(s),"onUpdate:modelValue":[r[0]||(r[0]=i=>u.value=i),r[1]||(r[1]=i=>p.value=!0)],name:a.name,type:a.isTwoDecimals?"text":"number",step:e.step,min:e.min,max:e.max,placeholder:e.placeholder,disabled:e.disabled,class:C(["el-input",{error:N}]),"data-cy":e.label?`${e.label.trim().replaceAll(" ","")}-number-input`:"number-input",onBlur:g},null,42,O),[[A,u.value]])]),_:1},16,["name","label","error-message","hidden-error-message","set-required-mark"]))}});export{x as default};
|
|
2
2
|
//# sourceMappingURL=ElInputNumber.vue.esm2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElInputNumber.vue.esm2.js","sources":["../../src/forms/ElInputNumber.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport { useInput, NumberValueType, showRequiredMark, withNumberElInputProps } from '@/forms/input';\nimport { computed, ref } from 'vue';\n\nconst props = defineProps({\n ...withNumberElInputProps(),\n isTwoDecimals: {\n type: Boolean,\n default: false,\n },\n defaultNullValueToZeroOnBlur: {\n type: Boolean,\n default: true,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: NumberValueType): void;\n (event: 'overlayedBtnClicked'): void;\n (event: 'update:formattedAmount', value: NumberValueType): void;\n}>();\n\nconst showOverlayedIcon = ref(false);\nconst computedModelValue = computed(() => {\n return props.modelValue;\n});\n\nconst computedValidation = computed(() => [props.validation]);\n\nconst { value, errorMessage, uuid, fieldContext } = useInput(computedModelValue, computedValidation, props.name, newValue => {\n emit('update:modelValue', newValue);\n emit('update:formattedAmount', formattedAmount.value);\n});\n\nconst formattedAmount = computed<number | null>({\n get: () => {\n if (value.value === null || value.value === undefined) return null;\n if (typeof value.value === 'string' && value.value === '') return null;\n if (typeof value.value === 'string') return Number(value.value);\n\n if (props.isTwoDecimals) {\n return parseFloat((value.value / 100).toFixed(2));\n }\n\n return value.value;\n },\n set: (inputValue: number | null | string) => {\n if (inputValue === '' || inputValue === null) {\n value.value = null;\n return;\n }\n\n const numValue = Number(inputValue);\n if (!isNaN(numValue)) {\n if (props.isTwoDecimals) {\n value.value = Math.round(numValue * 100);\n } else {\n value.value = numValue;\n }\n }\n },\n});\n\nconst onBlur = () => {\n fieldContext.validate();\n\n if (props.defaultNullValueToZeroOnBlur) {\n resetNullValueToZero();\n }\n};\n\nconst resetNullValueToZero = () => {\n if (!value.value) {\n value.value = 0;\n }\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 :set-required-mark=\"showRequiredMark([validation])\"\n >\n <template #default=\"{ error }\">\n <input\n :id=\"uuid\"\n
|
|
1
|
+
{"version":3,"file":"ElInputNumber.vue.esm2.js","sources":["../../src/forms/ElInputNumber.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport ElInputContainer from '@/forms/ElInputContainer.vue';\nimport { useInput, NumberValueType, showRequiredMark, withNumberElInputProps } from '@/forms/input';\nimport { computed, ref } from 'vue';\n\nconst props = defineProps({\n ...withNumberElInputProps(),\n isTwoDecimals: {\n type: Boolean,\n default: false,\n },\n defaultNullValueToZeroOnBlur: {\n type: Boolean,\n default: true,\n },\n});\n\nconst emit = defineEmits<{\n (event: 'update:modelValue', value: NumberValueType): void;\n (event: 'overlayedBtnClicked'): void;\n (event: 'update:formattedAmount', value: NumberValueType): void;\n}>();\n\nconst showOverlayedIcon = ref(false);\nconst computedModelValue = computed(() => {\n return props.modelValue;\n});\n\nconst computedValidation = computed(() => [props.validation]);\n\nconst { value, errorMessage, uuid, fieldContext } = useInput(computedModelValue, computedValidation, props.name, newValue => {\n emit('update:modelValue', newValue);\n emit('update:formattedAmount', formattedAmount.value);\n});\n\nconst formattedAmount = computed<number | null>({\n get: () => {\n if (value.value === null || value.value === undefined) return null;\n if (typeof value.value === 'string' && value.value === '') return null;\n if (typeof value.value === 'string') return Number(value.value);\n\n if (props.isTwoDecimals) {\n return parseFloat((value.value / 100).toFixed(2));\n }\n\n return value.value;\n },\n set: (inputValue: number | null | string) => {\n if (inputValue === '' || inputValue === null) {\n value.value = null;\n return;\n }\n\n const numValue = Number(inputValue);\n if (!isNaN(numValue)) {\n if (props.isTwoDecimals) {\n value.value = Math.round(numValue * 100);\n } else {\n value.value = numValue;\n }\n } else {\n value.value = numValue;\n }\n },\n});\n\nconst onBlur = (event: Event) => {\n const inputValue = Number((event.target as HTMLInputElement).value);\n fieldContext.validate();\n\n // if props.min and / or props.max are set, check if the value is within the range\n if (props.min && inputValue && inputValue < props.min) {\n value.value = props.min;\n }\n\n if (props.max && inputValue && inputValue > props.max) {\n value.value = props.max;\n }\n\n if (props.defaultNullValueToZeroOnBlur) {\n resetNullValueToZero();\n }\n};\n\nconst resetNullValueToZero = () => {\n if (!value.value) {\n value.value = 0;\n }\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 :set-required-mark=\"showRequiredMark([validation])\"\n >\n <template #default=\"{ error }\">\n <input\n :id=\"uuid\"\n v-model=\"formattedAmount\"\n :name=\"props.name\"\n :type=\"props.isTwoDecimals ? 'text' : 'number'\"\n :step=\"step\"\n :min=\"min\"\n :max=\"max\"\n :placeholder=\"placeholder\"\n :disabled=\"disabled\"\n class=\"el-input\"\n :class=\"{ error }\"\n :data-cy=\"label ? `${label.trim().replaceAll(' ', '')}-number-input` : `number-input`\"\n @blur=\"onBlur\"\n @update:model-value=\"showOverlayedIcon = true\"\n />\n </template>\n </ElInputContainer>\n</template>\n"],"names":["props","__props","emit","__emit","showOverlayedIcon","ref","computedModelValue","computed","computedValidation","value","errorMessage","uuid","fieldContext","useInput","newValue","formattedAmount","inputValue","numValue","onBlur","event","resetNullValueToZero"],"mappings":"4pBAKA,MAAMA,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