{"version":3,"file":"index.vue.mjs","sources":["../../../../../../packages/preview/supports/vue-files-preview/index.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { watch } from 'vue'\nimport { PreviewRules, getPreviewTypeByFileType } from '../../preview.const'\nimport type { IPreviewRule, PreviewProps } from '../../preview.interface'\nimport { PreviewType } from '../../preview.interface'\nimport { getFileName, getFileType } from '../../utils/utils'\n\nconst props = withDefaults(\n  defineProps<PreviewProps & {\n    width?: string\n    height?: string\n    overflow?: string\n  }>(),\n  {\n    file: () => null,\n    url: () => null,\n    width: () => '100%',\n    height: () => '100%',\n    overflow: () => 'auto',\n  },\n)\n\nconst currentPreview = shallowRef<IPreviewRule>(PreviewRules[PreviewType.NONE])\n\nfunction syncPreview(file: File): void {\n  const preview = PreviewRules[getPreviewTypeByFileType(getFileType(file))]\n  if (preview) {\n    preview.name = getFileName(file)\n    currentPreview.value = preview\n  }\n}\n\nwatch(\n  () => props.file,\n  (file) => {\n    if (file) {\n      syncPreview(file)\n    }\n  },\n  { immediate: true },\n)\n</script>\n\n<template>\n  <div class=\"vue-files-preview\" :style=\"{ width, height, overflow }\">\n    <component :is=\"currentPreview.component\" :name=\"currentPreview.name\" :file=\"file\" :url=\"url\" />\n  </div>\n</template>\n\n<style scoped lang=\"scss\"></style>\n"],"names":["props","__props","currentPreview","shallowRef","PreviewRules","PreviewType","syncPreview","file","preview","getPreviewTypeByFileType","getFileType","getFileName","watch"],"mappings":";;;;;;;;;;;;;;;AAOA,UAAMA,IAAQC,GAeRC,IAAiBC,EAAyBC,EAAaC,EAAY,IAAI,CAAC;AAE9E,aAASC,EAAYC,GAAkB;AACrC,YAAMC,IAAUJ,EAAaK,EAAyBC,EAAYH,CAAI,CAAC,CAAC;AACxE,MAAIC,MACMA,EAAA,OAAOG,EAAYJ,CAAI,GAC/BL,EAAe,QAAQM;AAAA,IAE3B;AAEA,WAAAI;AAAA,MACE,MAAMZ,EAAM;AAAA,MACZ,CAACO,MAAS;AACR,QAAIA,KACFD,EAAYC,CAAI;AAAA,MAEpB;AAAA,MACA,EAAE,WAAW,GAAK;AAAA,IAAA;;;;;;;;;;;;"}