2 lines
2.7 KiB
JavaScript
Vendored
2 lines
2.7 KiB
JavaScript
Vendored
import{h as m}from"./app.ccfeba26.js";import{_ as g}from"./plugin-vue_export-helper.21dcd24c.js";import{o as l,f as o,t as u,j as c,i as a,F as h,B as x,m as p,J as b}from"./vendor.7e4e5e39.js";const y={props:{modelValue:FileList,label:String,accept:String,error:String},emits:["fileTime","loadFileStart","update:modelValue"],watch:{modelValue(r){r||(this.$refs.file.value="")}},methods:{filesize(r){var e=Math.floor(Math.log(r)/Math.log(1024));return(r/Math.pow(1024,e)).toFixed(2)*1+" "+["B","kB","MB","GB","TB"][e]},browse(){this.$refs.file.click()},change(r){const e=Array.from(r.target.files),t=this;e.map(function(n){t.$emit("loadFileStart");var d=new(AudioContext||webkitAudioContext),i=new FileReader;i.readAsArrayBuffer(n),i.onload=function(s){d.decodeAudioData(s.target.result).then(function(f){t.$emit("fileTime",n.name+","+t.formatTimeSong(f.duration))})}}),this.$emit("update:modelValue",r.target.files)},formatTimeSong(r){return m.formatTime(r)},remove(r){const e=new DataTransfer;Array.from(this.$refs.file.files).map(function(n,d){d!==r&&e.items.add(n)}),e.files.length?(this.$refs.file.files=e.files,this.$emit("update:modelValue",e.files)):(this.$refs.file.files=null,this.$emit("update:modelValue",null))}}},v=["accept"],_={key:0,class:"py-2"},w={key:1,class:"flex flex-col justify-center max-w-lg mt-3 p-2 border rounded-md"},k={class:"flex-1 pr-1 text-gray"},V={class:"text-xs text-gray-light"},B=["onClick"],C={key:1,class:"text-red text-sm"};function F(r,e,t,n,d,i){return l(),o("div",null,[t.label?(l(),o("label",{key:0,onClick:e[0]||(e[0]=(...s)=>i.browse&&i.browse(...s)),class:"cursor-pointer text-gray-light text-lg mb-2"},u(t.label)+":",1)):c("",!0),a("div",{class:b({error:t.error})},[a("input",{ref:"file",type:"file",accept:t.accept,multiple:"",class:"hidden",onChange:e[1]||(e[1]=(...s)=>i.change&&i.change(...s))},null,40,v),t.modelValue?(l(),o("div",w,[(l(!0),o(h,null,x(t.modelValue,(s,f)=>(l(),o("div",{key:f,class:"flex items-center justify-between p-1"},[a("div",k,[p(u(s.name)+" ",1),a("span",V,"("+u(i.filesize(s.size))+")",1)]),a("button",{type:"button",class:"px-4 py-1 bg-indigo-300 hover:bg-indigo-100 rounded-sm text-xs font-medium text-white",onClick:A=>i.remove(f)}," \u0423\u0434\u0430\u043B\u0438\u0442\u044C ",8,B)]))),128))])):(l(),o("div",_,[a("button",{type:"button",class:"px-6 py-2 bg-indigo-300 focus:ring-4 focus:ring-offset-1 focus:ring-orange focus:ring-opacity-20 focus:ring-offset-orange focus:outline-none focus:border-transparent rounded-sm text-sm text-white",onClick:e[2]||(e[2]=(...s)=>i.browse&&i.browse(...s))}," \u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0444\u0430\u0439\u043B\u044B ")]))],2),t.error?(l(),o("div",C,u(t.error),1)):c("",!0)])}var M=g(y,[["render",F]]);export{M as F};
|