Files
PORTAL_COD2/src/front/dist/assets/VFileInput-ac5ef80a.js
T
2024-11-08 14:18:06 +03:00

2 lines
3.6 KiB
JavaScript

import{m as W,f as X,V as Y,a as ee}from"./VField-e3c852c7.js";import{m as le,u as te,V as B}from"./VInput-e5a7e0e7.js";import{a7 as ne,dk as x,ab as ae,dg as ue,ak as ie,f as s,dZ as $,r as h,w as oe,af as se,d1 as re,x as u,z as V,S as k,cS as ce,d7 as de,n as fe,d_ as ve}from"./index-84cc8e63.js";const me=ne({chips:Boolean,counter:Boolean,counterSizeString:{type:String,default:"$vuetify.fileInput.counterSize"},counterString:{type:String,default:"$vuetify.fileInput.counter"},hideInput:Boolean,multiple:Boolean,showSize:{type:[Boolean,Number,String],default:!1,validator:e=>typeof e=="boolean"||[1e3,1024].includes(Number(e))},...le({prependIcon:"$file"}),modelValue:{type:[Array,Object],default:e=>e.multiple?[]:null,validator:e=>x(e).every(f=>f!=null&&typeof f=="object")},...W({clearable:!0})},"VFileInput"),ke=ae()({name:"VFileInput",inheritAttrs:!1,props:me(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,f){let{attrs:M,emit:g,slots:n}=f;const{t:C}=ue(),a=ie(e,"modelValue",e.modelValue,l=>x(l),l=>e.multiple||Array.isArray(e.modelValue)?l:l[0]??null),{isFocused:v,focus:N,blur:D}=te(e),I=s(()=>typeof e.showSize!="boolean"?e.showSize:void 0),b=s(()=>(a.value??[]).reduce((l,t)=>{let{size:r=0}=t;return l+r},0)),S=s(()=>$(b.value,I.value)),p=s(()=>(a.value??[]).map(l=>{const{name:t="",size:r=0}=l;return e.showSize?`${t} (${$(r,I.value)})`:t})),j=s(()=>{var t;const l=((t=a.value)==null?void 0:t.length)??0;return e.showSize?C(e.counterSizeString,l,S.value):C(e.counterString,l)}),F=h(),P=h(),i=h(),E=s(()=>v.value||e.active),z=s(()=>["plain","underlined"].includes(e.variant));function y(){var l;i.value!==document.activeElement&&((l=i.value)==null||l.focus()),v.value||N()}function O(l){var t;(t=i.value)==null||t.click()}function U(l){g("mousedown:control",l)}function _(l){var t;(t=i.value)==null||t.click(),g("click:control",l)}function L(l){l.stopPropagation(),y(),fe(()=>{a.value=[],ve(e["onClick:clear"],l)})}return oe(a,l=>{(!Array.isArray(l)||!l.length)&&i.value&&(i.value.value="")}),se(()=>{const l=!!(n.counter||e.counter),t=!!(l||n.details),[r,T]=re(M),{modelValue:pe,...Z}=B.filterProps(e),q=X(e);return u(B,V({ref:F,modelValue:a.value,"onUpdate:modelValue":c=>a.value=c,class:["v-file-input",{"v-file-input--chips":!!e.chips,"v-file-input--hide":e.hideInput,"v-input--plain-underlined":z.value},e.class],style:e.style,"onClick:prepend":O},r,Z,{centerAffix:!z.value,focused:v.value}),{...n,default:c=>{let{id:m,isDisabled:d,isDirty:w,isReadonly:A,isValid:G}=c;return u(Y,V({ref:P,"prepend-icon":e.prependIcon,onMousedown:U,onClick:_,"onClick:clear":L,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},q,{id:m.value,active:E.value||w.value,dirty:w.value||e.dirty,disabled:d.value,focused:v.value,error:G.value===!1}),{...n,default:H=>{var R;let{props:{class:J,...K}}=H;return u(k,null,[u("input",V({ref:i,type:"file",readonly:A.value,disabled:d.value,multiple:e.multiple,name:e.name,onClick:o=>{o.stopPropagation(),A.value&&o.preventDefault(),y()},onChange:o=>{if(!o.target)return;const Q=o.target;a.value=[...Q.files??[]]},onFocus:y,onBlur:D},K,T),null),u("div",{class:J},[!!((R=a.value)!=null&&R.length)&&!e.hideInput&&(n.selection?n.selection({fileNames:p.value,totalBytes:b.value,totalBytesReadable:S.value}):e.chips?p.value.map(o=>u(ce,{key:o,size:"small",text:o},null)):p.value.join(", "))])])}})},details:t?c=>{var m,d;return u(k,null,[(m=n.details)==null?void 0:m.call(n,c),l&&u(k,null,[u("span",null,null),u(ee,{active:!!((d=a.value)!=null&&d.length),value:j.value,disabled:e.disabled},n.counter)])])}:void 0})}),de({},F,P,i)}});export{ke as V};