2 lines
9.3 KiB
JavaScript
2 lines
9.3 KiB
JavaScript
import{c as le,au as W,P as se,s as ue,Q as re,g as $,r as H,a as c,av as ce,R as de,aw as fe,S as me,ax as ve,w as X,e as Y,y as Z,B as J,t as ge,h as T,ay as he,b as pe,G as K,E as ye,z as be,az as Se,aA as Fe,aB as xe,aC as Te,aD as Ce,aE as Pe,aF as ee,aG as Oe,aH as ke,D as we,j as ze,aI as Ee,as as De}from"./index-Dga5rwnp.js";import{v as je,a as te,u as Ae,p as ae,d as Ve,e as _e,f as Ne,r as ne,s as qe,c as ie,h as Ie}from"./LocalStorage-BQmANGBd.js";import{c as He}from"./QSelect-DXNgklLP.js";const $e=le({name:"QTooltip",inheritAttrs:!1,props:{...Ae,...re,...W,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null},transitionShow:{...W.transitionShow,default:"jump-down"},transitionHide:{...W.transitionHide,default:"jump-up"},anchor:{type:String,default:"bottom middle",validator:te},self:{type:String,default:"top middle",validator:te},offset:{type:Array,default:()=>[14,14],validator:je},scrollTarget:ue,delay:{type:Number,default:0},hideDelay:{type:Number,default:0},persistent:Boolean},emits:[...se],setup(e,{slots:v,emit:C,attrs:b}){let o,s;const y=$(),{proxy:{$q:d}}=y,S=H(null),x=H(!1),w=c(()=>ae(e.anchor,d.lang.rtl)),z=c(()=>ae(e.self,d.lang.rtl)),E=c(()=>e.persistent!==!0),{registerTick:N,removeTick:q}=ce(),{registerTimeout:l}=de(),{transitionProps:D,transitionStyle:I}=fe(e),{localScrollTarget:t,changeScrollEvent:h,unconfigureScrollTarget:P}=Ve(e,V),{anchorEl:f,canShow:n,anchorEvents:r}=_e({showing:x,configureAnchorEl:p}),{show:F,hide:i}=me({showing:x,canShow:n,handleShow:Q,handleHide:A,hideOnRouteChange:E,processOnMount:!0});Object.assign(r,{delayShow:a,delayHide:m});const{showPortal:u,hidePortal:j,renderPortal:R}=ve(y,S,oe,"tooltip");if(d.platform.is.mobile===!0){const g={anchorEl:f,innerRef:S,onClickOutside(k){return i(k),k.target.classList.contains("q-dialog__backdrop")&&K(k),!0}},M=c(()=>e.modelValue===null&&e.persistent!==!0&&x.value===!0);X(M,k=>{(k===!0?Ne:ne)(g)}),Y(()=>{ne(g)})}function Q(g){u(),N(()=>{s=new MutationObserver(()=>O()),s.observe(S.value,{attributes:!1,childList:!0,characterData:!0,subtree:!0}),O(),V()}),o===void 0&&(o=X(()=>d.screen.width+"|"+d.screen.height+"|"+e.self+"|"+e.anchor+"|"+d.lang.rtl,O)),l(()=>{u(!0),C("show",g)},e.transitionDuration)}function A(g){q(),j(),U(),l(()=>{j(!0),C("hide",g)},e.transitionDuration)}function U(){s!==void 0&&(s.disconnect(),s=void 0),o!==void 0&&(o(),o=void 0),P(),Z(r,"tooltipTemp")}function O(){qe({targetEl:S.value,offset:e.offset,anchorEl:f.value,anchorOrigin:w.value,selfOrigin:z.value,maxHeight:e.maxHeight,maxWidth:e.maxWidth})}function a(g){if(d.platform.is.mobile===!0){ie(),document.body.classList.add("non-selectable");const M=f.value,k=["touchmove","touchcancel","touchend","click"].map(G=>[M,G,"delayHide","passiveCapture"]);J(r,"tooltipTemp",k)}l(()=>{F(g)},e.delay)}function m(g){d.platform.is.mobile===!0&&(Z(r,"tooltipTemp"),ie(),setTimeout(()=>{document.body.classList.remove("non-selectable")},10)),l(()=>{i(g)},e.hideDelay)}function p(){if(e.noParentEvent===!0||f.value===null)return;const g=d.platform.is.mobile===!0?[[f.value,"touchstart","delayShow","passive"]]:[[f.value,"mouseenter","delayShow","passive"],[f.value,"mouseleave","delayHide","passive"]];J(r,"anchor",g)}function V(){if(f.value!==null||e.scrollTarget!==void 0){t.value=ge(f.value,e.scrollTarget);const g=e.noParentEvent===!0?O:i;h(t.value,g)}}function L(){return x.value===!0?T("div",{...b,ref:S,class:["q-tooltip q-tooltip--style q-position-engine no-pointer-events",b.class],style:[b.style,I.value],role:"tooltip"},pe(v.default)):null}function oe(){return T(he,D.value,L)}return Y(U),Object.assign(y.proxy,{updatePosition:O}),R}});function _(e,v,C,b){const o=[];return e.forEach(s=>{b(s)===!0?o.push(s):v.push({failedPropValidation:C,file:s})}),o}function B(e){e?.dataTransfer&&(e.dataTransfer.dropEffect="copy"),K(e)}const Re={multiple:Boolean,accept:String,capture:String,maxFileSize:[Number,String],maxTotalSize:[Number,String],maxFiles:[Number,String],filter:Function},Qe=["rejected"];function Ue({editable:e,dnd:v,getFileInput:C,addFilesToQueue:b}){const{props:o,emit:s,proxy:y}=$(),d=H(null),S=c(()=>o.accept!==void 0?o.accept.split(",").map(t=>(t=t.trim(),t==="*"?"*/":(t.endsWith("/*")&&(t=t.slice(0,t.length-1)),t.toUpperCase()))):null),x=c(()=>parseInt(o.maxFiles,10)),w=c(()=>parseInt(o.maxTotalSize,10));function z(t){if(e.value)if(t!==Object(t)&&(t={target:null}),t.target?.matches('input[type="file"]')===!0)t.clientX===0&&t.clientY===0&&ye(t);else{const h=C();h!==t.target&&h?.click(t)}}function E(t){e.value&&t&&b(null,t)}function N(t,h,P,f){let n=Array.from(h||t.target.files);const r=[],F=()=>{r.length!==0&&s("rejected",r)};if(o.accept!==void 0&&S.value.indexOf("*/")===-1&&(n=_(n,r,"accept",i=>S.value.some(u=>i.type.toUpperCase().startsWith(u)||i.name.toUpperCase().endsWith(u))),n.length===0))return F();if(o.maxFileSize!==void 0){const i=parseInt(o.maxFileSize,10);if(n=_(n,r,"max-file-size",u=>u.size<=i),n.length===0)return F()}if(o.multiple!==!0&&n.length!==0&&(n=[n[0]]),n.forEach(i=>{i.__key=i.webkitRelativePath+i.lastModified+i.name+i.size}),f===!0){const i=P.map(u=>u.__key);n=_(n,r,"duplicate",u=>i.includes(u.__key)===!1)}if(n.length===0)return F();if(o.maxTotalSize!==void 0){let i=f===!0?P.reduce((u,j)=>u+j.size,0):0;if(n=_(n,r,"max-total-size",u=>(i+=u.size,i<=w.value)),n.length===0)return F()}if(typeof o.filter=="function"){const i=o.filter(n);n=_(n,r,"filter",u=>i.includes(u))}if(o.maxFiles!==void 0){let i=f===!0?P.length:0;if(n=_(n,r,"max-files",()=>(i++,i<=x.value)),n.length===0)return F()}if(F(),n.length!==0)return n}function q(t){B(t),v.value!==!0&&(v.value=!0)}function l(t){K(t),(t.relatedTarget!==null||be.is.safari!==!0?t.relatedTarget!==d.value:document.elementsFromPoint(t.clientX,t.clientY).includes(d.value)===!1)===!0&&(v.value=!1)}function D(t){B(t);const h=t.dataTransfer.files;h.length!==0&&b(null,h),v.value=!1}function I(t){if(v.value===!0)return T("div",{ref:d,class:`q-${t}__dnd absolute-full`,onDragenter:B,onDragover:B,onDragleave:l,onDrop:D})}return Object.assign(y,{pickFiles:z,addFiles:E}),{pickFiles:z,addFiles:E,onDragover:q,onDragleave:l,processFiles:N,getDndNode:I,maxFilesNumber:x,maxTotalSizeNumber:w}}const Ke=le({name:"QFile",inheritAttrs:!1,props:{...xe,...Fe,...Re,modelValue:[File,FileList,Array],append:Boolean,useChips:Boolean,displayValue:[String,Number],tabindex:{type:[String,Number],default:0},counterLabel:Function,inputClass:[Array,String,Object],inputStyle:[Array,String,Object]},emits:[...Se,...Qe],setup(e,{slots:v,emit:C,attrs:b}){const{proxy:o}=$(),s=Te(),y=H(null),d=H(!1),S=Ce(e),{pickFiles:x,onDragover:w,onDragleave:z,processFiles:E,getDndNode:N}=Ue({editable:s.editable,dnd:d,getFileInput:R,addFilesToQueue:Q}),q=Pe(e),l=c(()=>Object(e.modelValue)===e.modelValue?"length"in e.modelValue?Array.from(e.modelValue):[e.modelValue]:[]),D=c(()=>ee(l.value)),I=c(()=>l.value.map(a=>a.name).join(", ")),t=c(()=>Ie(l.value.reduce((a,m)=>a+m.size,0))),h=c(()=>({totalSize:t.value,filesNumber:l.value.length,maxFiles:e.maxFiles})),P=c(()=>({tabindex:-1,type:"file",title:"",accept:e.accept,capture:e.capture,name:S.value,...b,id:s.targetUid.value,disabled:s.editable.value!==!0})),f=c(()=>"q-file q-field--auto-height"+(d.value===!0?" q-file--dnd":"")),n=c(()=>e.multiple===!0&&e.append===!0);function r(a){const m=l.value.slice();m.splice(a,1),i(m)}function F(a){const m=l.value.indexOf(a);m!==-1&&r(m)}function i(a){C("update:modelValue",e.multiple===!0?a:a[0])}function u(a){a.keyCode===13&&we(a)}function j(a){(a.keyCode===13||a.keyCode===32)&&x(a)}function R(){return y.value}function Q(a,m){const p=E(a,m,l.value,n.value),V=R();V!=null&&(V.value=""),p!==void 0&&((e.multiple===!0?e.modelValue&&p.every(L=>l.value.includes(L)):e.modelValue===p[0])||i(n.value===!0?l.value.concat(p):p))}function A(){return[T("input",{class:[e.inputClass,"q-file__filler"],style:e.inputStyle})]}function U(){if(v.file!==void 0)return l.value.length===0?A():l.value.map((m,p)=>v.file({index:p,file:m,ref:this}));if(v.selected!==void 0)return l.value.length===0?A():v.selected({files:l.value,ref:this});if(e.useChips===!0)return l.value.length===0?A():l.value.map((m,p)=>T(He,{key:"file-"+p,removable:s.editable.value,dense:!0,textColor:e.color,tabindex:e.tabindex,onRemove:()=>{r(p)}},()=>T("span",{class:"ellipsis",textContent:m.name})));const a=e.displayValue!==void 0?e.displayValue:I.value;return a.length!==0?[T("div",{class:e.inputClass,style:e.inputStyle,textContent:a})]:A()}function O(){const a={ref:y,...P.value,...q.value,class:"q-field__input fit absolute-full cursor-pointer",onChange:Q};return e.multiple===!0&&(a.multiple=!0),T("input",a)}return Object.assign(s,{fieldClass:f,emitValue:i,hasValue:D,inputRef:y,innerValue:l,floatingLabel:c(()=>D.value===!0||ee(e.displayValue)),computedCounter:c(()=>{if(e.counterLabel!==void 0)return e.counterLabel(h.value);const a=e.maxFiles;return`${l.value.length}${a!==void 0?" / "+a:""} (${t.value})`}),getControlChild:()=>N("file"),getControl:()=>{const a={ref:s.targetRef,class:"q-field__native row items-center cursor-pointer",tabindex:e.tabindex};return s.editable.value===!0&&Object.assign(a,{onDragover:w,onDragleave:z,onKeydown:u,onKeyup:j}),T("div",a,[O()].concat(U()))}}),Object.assign(o,{removeAtIndex:r,removeFile:F,getNativeElement:()=>y.value}),Oe(o,"nativeEl",()=>y.value),ke(s)}});function Ge(){return ze(Ee)}const Be="00000000-0000-0000-0000-000000000000",Xe=De("userstore",{state:()=>({id:Be})});export{$e as Q,Xe as a,Ke as b,Ge as u};
|