QItemLabel-CbaSgT54.js 14 KB

1
  1. import{bC as Te,g as Q,k as H,bc as Z,A as ee,R as Ce,b9 as re,w as B,S as Se,o as j,z as pe,au as K,bD as te,b2 as Be,aI as He,c as A,n as Le,s as Me,u as We,F as ce,p as Pe,e as x,H as de,q as _e,t as Ae,v as Re,x as Fe,y as $e,bE as ze,bF as ne,bG as De,b4 as Ke,bH as Ie,B as Qe,bI as je,bJ as Oe,h as L,f as O,T as Ne,bK as Ve,D as fe,G as Ge,bL as Ue,m as Xe}from"./index-Cd2JsgaO.js";function Ye(){if(window.getSelection!==void 0){const e=window.getSelection();e.empty!==void 0?e.empty():e.removeAllRanges!==void 0&&(e.removeAllRanges(),Te.is.mobile!==!0&&e.addRange(document.createRange()))}else document.selection!==void 0&&document.selection.empty()}const Je={target:{type:[Boolean,String,Element],default:!0},noParentEvent:Boolean},Ze={...Je,contextMenu:Boolean};function et({showing:e,avoidEmit:n,configureAnchorEl:l}){const{props:t,proxy:i,emit:d}=Q(),a=H(null);let v=null;function m(o){return a.value===null?!1:o===void 0||o.touches===void 0||o.touches.length<=1}const c={};l===void 0&&(Object.assign(c,{hide(o){i.hide(o)},toggle(o){i.toggle(o),o.qAnchorHandled=!0},toggleKey(o){re(o,13)===!0&&c.toggle(o)},contextClick(o){i.hide(o),Z(o),Ce(()=>{i.show(o),o.qAnchorHandled=!0})},prevent:Z,mobileTouch(o){if(c.mobileCleanup(o),m(o)!==!0)return;i.hide(o),a.value.classList.add("non-selectable");const r=o.target;ee(c,"anchor",[[r,"touchmove","mobileCleanup","passive"],[r,"touchend","mobileCleanup","passive"],[r,"touchcancel","mobileCleanup","passive"],[a.value,"contextmenu","prevent","notPassive"]]),v=setTimeout(()=>{v=null,i.show(o),o.qAnchorHandled=!0},300)},mobileCleanup(o){a.value.classList.remove("non-selectable"),v!==null&&(clearTimeout(v),v=null),e.value===!0&&o!==void 0&&Ye()}}),l=function(o=t.contextMenu){if(t.noParentEvent===!0||a.value===null)return;let r;o===!0?i.$q.platform.is.mobile===!0?r=[[a.value,"touchstart","mobileTouch","passive"]]:r=[[a.value,"mousedown","hide","passive"],[a.value,"contextmenu","contextClick","notPassive"]]:r=[[a.value,"click","toggle","passive"],[a.value,"keyup","toggleKey","passive"]],ee(c,"anchor",r)});function f(){pe(c,"anchor")}function h(o){for(a.value=o;a.value.classList.contains("q-anchor--skip");)a.value=a.value.parentNode;l()}function b(){if(t.target===!1||t.target===""||i.$el.parentNode===null)a.value=null;else if(t.target===!0)h(i.$el.parentNode);else{let o=t.target;if(typeof t.target=="string")try{o=document.querySelector(t.target)}catch{o=void 0}o!=null?(a.value=o.$el||o,l()):(a.value=null,console.error(`Anchor: target "${t.target}" not found`))}}return B(()=>t.contextMenu,o=>{a.value!==null&&(f(),l(o))}),B(()=>t.target,()=>{a.value!==null&&f(),b()}),B(()=>t.noParentEvent,o=>{a.value!==null&&(o===!0?f():l())}),Se(()=>{b(),n!==!0&&t.modelValue===!0&&a.value===null&&d("update:modelValue",!1)}),j(()=>{v!==null&&clearTimeout(v),f()}),{anchorEl:a,canShow:m,anchorEvents:c}}function tt(e,n){const l=H(null);let t;function i(v,m){const c=`${m!==void 0?"add":"remove"}EventListener`,f=m!==void 0?m:t;v!==window&&v[c]("scroll",f,K.passive),window[c]("scroll",f,K.passive),t=m}function d(){l.value!==null&&(i(l.value),l.value=null)}const a=B(()=>e.noParentEvent,()=>{l.value!==null&&(d(),n())});return j(a),{localScrollTarget:l,unconfigureScrollTarget:d,changeScrollEvent:i}}const{notPassiveCapture:P}=K,T=[];function _(e){const n=e.target;if(n===void 0||n.nodeType===8||n.classList.contains("no-pointer-events")===!0)return;let l=te.length-1;for(;l>=0;){const t=te[l].$;if(t.type.name==="QTooltip"){l--;continue}if(t.type.name!=="QDialog")break;if(t.props.seamless!==!0)return;l--}for(let t=T.length-1;t>=0;t--){const i=T[t];if((i.anchorEl.value===null||i.anchorEl.value.contains(n)===!1)&&(n===document.body||i.innerRef.value!==null&&i.innerRef.value.contains(n)===!1))e.qClickOutside=!0,i.onClickOutside(e);else return}}function nt(e){T.push(e),T.length===1&&(document.addEventListener("mousedown",_,P),document.addEventListener("touchstart",_,P))}function le(e){const n=T.findIndex(l=>l===e);n!==-1&&(T.splice(n,1),T.length===0&&(document.removeEventListener("mousedown",_,P),document.removeEventListener("touchstart",_,P)))}let oe,ie;function ae(e){const n=e.split(" ");return n.length!==2?!1:["top","center","bottom"].includes(n[0])!==!0?(console.error("Anchor/Self position must start with one of top/center/bottom"),!1):["left","middle","right","start","end"].includes(n[1])!==!0?(console.error("Anchor/Self position must end with one of left/middle/right/start/end"),!1):!0}function lt(e){return e?!(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number"):!0}const I={"start#ltr":"left","start#rtl":"right","end#ltr":"right","end#rtl":"left"};["left","middle","right"].forEach(e=>{I[`${e}#ltr`]=e,I[`${e}#rtl`]=e});function ue(e,n){const l=e.split(" ");return{vertical:l[0],horizontal:I[`${l[1]}#${n===!0?"rtl":"ltr"}`]}}function ot(e,n){let{top:l,left:t,right:i,bottom:d,width:a,height:v}=e.getBoundingClientRect();return n!==void 0&&(l-=n[1],t-=n[0],d+=n[1],i+=n[0],a+=n[0],v+=n[1]),{top:l,bottom:d,height:v,left:t,right:i,width:a,middle:t+(i-t)/2,center:l+(d-l)/2}}function it(e,n,l){let{top:t,left:i}=e.getBoundingClientRect();return t+=n.top,i+=n.left,l!==void 0&&(t+=l[1],i+=l[0]),{top:t,bottom:t+1,height:1,left:i,right:i+1,width:1,middle:i,center:t}}function at(e,n){return{top:0,center:n/2,bottom:n,left:0,middle:e/2,right:e}}function se(e,n,l,t){return{top:e[l.vertical]-n[t.vertical],left:e[l.horizontal]-n[t.horizontal]}}function ve(e,n=0){if(e.targetEl===null||e.anchorEl===null||n>5)return;if(e.targetEl.offsetHeight===0||e.targetEl.offsetWidth===0){setTimeout(()=>{ve(e,n+1)},10);return}const{targetEl:l,offset:t,anchorEl:i,anchorOrigin:d,selfOrigin:a,absoluteOffset:v,fit:m,cover:c,maxHeight:f,maxWidth:h}=e;if(Be.is.ios===!0&&window.visualViewport!==void 0){const p=document.body.style,{offsetLeft:k,offsetTop:q}=window.visualViewport;k!==oe&&(p.setProperty("--q-pe-left",k+"px"),oe=k),q!==ie&&(p.setProperty("--q-pe-top",q+"px"),ie=q)}const{scrollLeft:b,scrollTop:o}=l,r=v===void 0?ot(i,c===!0?[0,0]:t):it(i,v,t);Object.assign(l.style,{top:0,left:0,minWidth:null,minHeight:null,maxWidth:h,maxHeight:f,visibility:"visible"});const{offsetWidth:C,offsetHeight:E}=l,{elWidth:S,elHeight:M}=m===!0||c===!0?{elWidth:Math.max(r.width,C),elHeight:c===!0?Math.max(r.height,E):E}:{elWidth:C,elHeight:E};let s={maxWidth:h,maxHeight:f};(m===!0||c===!0)&&(s.minWidth=r.width+"px",c===!0&&(s.minHeight=r.height+"px")),Object.assign(l.style,s);const y=at(S,M);let g=se(r,y,d,a);if(v===void 0||t===void 0)D(g,r,y,d,a);else{const{top:p,left:k}=g;D(g,r,y,d,a);let q=!1;if(g.top!==p){q=!0;const w=2*t[1];r.center=r.top-=w,r.bottom-=w+2}if(g.left!==k){q=!0;const w=2*t[0];r.middle=r.left-=w,r.right-=w+2}q===!0&&(g=se(r,y,d,a),D(g,r,y,d,a))}s={top:g.top+"px",left:g.left+"px"},g.maxHeight!==void 0&&(s.maxHeight=g.maxHeight+"px",r.height>g.maxHeight&&(s.minHeight=s.maxHeight)),g.maxWidth!==void 0&&(s.maxWidth=g.maxWidth+"px",r.width>g.maxWidth&&(s.minWidth=s.maxWidth)),Object.assign(l.style,s),l.scrollTop!==o&&(l.scrollTop=o),l.scrollLeft!==b&&(l.scrollLeft=b)}function D(e,n,l,t,i){const d=l.bottom,a=l.right,v=He(),m=window.innerHeight-v,c=document.body.clientWidth;if(e.top<0||e.top+d>m)if(i.vertical==="center")e.top=n[t.vertical]>m/2?Math.max(0,m-d):0,e.maxHeight=Math.min(d,m);else if(n[t.vertical]>m/2){const f=Math.min(m,t.vertical==="center"?n.center:t.vertical===i.vertical?n.bottom:n.top);e.maxHeight=Math.min(d,f),e.top=Math.max(0,f-d)}else e.top=Math.max(0,t.vertical==="center"?n.center:t.vertical===i.vertical?n.top:n.bottom),e.maxHeight=Math.min(d,m-e.top);if(e.left<0||e.left+a>c)if(e.maxWidth=Math.min(a,c),i.horizontal==="middle")e.left=n[t.horizontal]>c/2?Math.max(0,c-a):0;else if(n[t.horizontal]>c/2){const f=Math.min(c,t.horizontal==="middle"?n.middle:t.horizontal===i.horizontal?n.right:n.left);e.maxWidth=Math.min(a,f),e.left=Math.max(0,f-e.maxWidth)}else e.left=Math.max(0,t.horizontal==="middle"?n.middle:t.horizontal===i.horizontal?n.left:n.right),e.maxWidth=Math.min(a,c-e.left)}const st=A({name:"QMenu",inheritAttrs:!1,props:{...Ze,...Pe,...ce,...We,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noEscDismiss:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:ae},self:{type:String,validator:ae},offset:{type:Array,validator:lt},scrollTarget:Me,touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...Le,"click","escapeKey"],setup(e,{slots:n,emit:l,attrs:t}){let i=null,d,a,v;const m=Q(),{proxy:c}=m,{$q:f}=c,h=H(null),b=H(!1),o=x(()=>e.persistent!==!0&&e.noRouteDismiss!==!0),r=de(e,f),{registerTick:C,removeTick:E}=_e(),{registerTimeout:S}=Ae(),{transitionProps:M,transitionStyle:s}=Re(e),{localScrollTarget:y,changeScrollEvent:g,unconfigureScrollTarget:p}=tt(e,Y),{anchorEl:k,canShow:q}=et({showing:b}),{hide:w}=Fe({showing:b,canShow:q,handleShow:xe,handleHide:ye,hideOnRouteChange:o,processOnMount:!0}),{showPortal:N,hidePortal:V,renderPortal:me}=$e(m,h,qe,"menu"),R={anchorEl:k,innerRef:h,onClickOutside(u){if(e.persistent!==!0&&b.value===!0)return w(u),(u.type==="touchstart"||u.target.classList.contains("q-dialog__backdrop"))&&fe(u),!0}},G=x(()=>ue(e.anchor||(e.cover===!0?"center middle":"bottom start"),f.lang.rtl)),he=x(()=>e.cover===!0?G.value:ue(e.self||"top start",f.lang.rtl)),ge=x(()=>(e.square===!0?" q-menu--square":"")+(r.value===!0?" q-menu--dark q-dark":"")),be=x(()=>e.autoClose===!0?{onClick:ke}:{}),U=x(()=>b.value===!0&&e.persistent!==!0);B(U,u=>{u===!0?(ze($),nt(R)):(ne($),le(R))});function F(){Ve(()=>{let u=h.value;u&&u.contains(document.activeElement)!==!0&&(u=u.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||u.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||u.querySelector("[autofocus], [data-autofocus]")||u,u.focus({preventScroll:!0}))})}function xe(u){if(i=e.noRefocus===!1?document.activeElement:null,De(J),N(),Y(),d=void 0,u!==void 0&&(e.touchPosition||e.contextMenu)){const z=Ke(u);if(z.left!==void 0){const{top:we,left:Ee}=k.value.getBoundingClientRect();d={left:z.left-Ee,top:z.top-we}}}a===void 0&&(a=B(()=>f.screen.width+"|"+f.screen.height+"|"+e.self+"|"+e.anchor+"|"+f.lang.rtl,W)),e.noFocus!==!0&&document.activeElement.blur(),C(()=>{W(),e.noFocus!==!0&&F()}),S(()=>{f.platform.is.ios===!0&&(v=e.autoClose,h.value.click()),W(),N(!0),l("show",u)},e.transitionDuration)}function ye(u){E(),V(),X(!0),i!==null&&(u===void 0||u.qClickOutside!==!0)&&(((u?.type.indexOf("key")===0?i.closest('[tabindex]:not([tabindex^="-"])'):void 0)||i).focus(),i=null),S(()=>{V(!0),l("hide",u)},e.transitionDuration)}function X(u){d=void 0,a!==void 0&&(a(),a=void 0),(u===!0||b.value===!0)&&(Ie(J),p(),le(R),ne($)),u!==!0&&(i=null)}function Y(){(k.value!==null||e.scrollTarget!==void 0)&&(y.value=Qe(k.value,e.scrollTarget),g(y.value,W))}function ke(u){v!==!0?(je(c,u),l("click",u)):v=!1}function J(u){U.value===!0&&e.noFocus!==!0&&Oe(h.value,u.target)!==!0&&F()}function $(u){e.noEscDismiss!==!0&&(l("escapeKey"),w(u))}function W(){ve({targetEl:h.value,offset:e.offset,anchorEl:k.value,anchorOrigin:G.value,selfOrigin:he.value,absoluteOffset:d,fit:e.fit,cover:e.cover,maxHeight:e.maxHeight,maxWidth:e.maxWidth})}function qe(){return L(Ne,M.value,()=>b.value===!0?L("div",{role:"menu",...t,ref:h,tabindex:-1,class:["q-menu q-position-engine scroll"+ge.value,t.class],style:[t.style,s.value],...be.value},O(n.default)):null)}return j(X),Object.assign(c,{focus:F,updatePosition:W}),me}}),rt=A({name:"QItemSection",props:{avatar:Boolean,thumbnail:Boolean,side:Boolean,top:Boolean,noWrap:Boolean},setup(e,{slots:n}){const l=x(()=>`q-item__section column q-item__section--${e.avatar===!0||e.side===!0||e.thumbnail===!0?"side":"main"}`+(e.top===!0?" q-item__section--top justify-start":" justify-center")+(e.avatar===!0?" q-item__section--avatar":"")+(e.thumbnail===!0?" q-item__section--thumbnail":"")+(e.noWrap===!0?" q-item__section--nowrap":""));return()=>L("div",{class:l.value},O(n.default))}}),ct=A({name:"QItem",props:{...ce,...Ge,tag:{type:String,default:"div"},active:{type:Boolean,default:null},clickable:Boolean,dense:Boolean,insetLevel:Number,tabindex:[String,Number],focused:Boolean,manualFocus:Boolean},emits:["click","keyup"],setup(e,{slots:n,emit:l}){const{proxy:{$q:t}}=Q(),i=de(e,t),{hasLink:d,linkAttrs:a,linkClass:v,linkTag:m,navigateOnClick:c}=Ue(),f=H(null),h=H(null),b=x(()=>e.clickable===!0||d.value===!0||e.tag==="label"),o=x(()=>e.disable!==!0&&b.value===!0),r=x(()=>"q-item q-item-type row no-wrap"+(e.dense===!0?" q-item--dense":"")+(i.value===!0?" q-item--dark":"")+(d.value===!0&&e.active===null?v.value:e.active===!0?` q-item--active${e.activeClass!==void 0?` ${e.activeClass}`:""}`:"")+(e.disable===!0?" disabled":"")+(o.value===!0?" q-item--clickable q-link cursor-pointer "+(e.manualFocus===!0?"q-manual-focusable":"q-focusable q-hoverable")+(e.focused===!0?" q-manual-focusable--focused":""):"")),C=x(()=>e.insetLevel===void 0?null:{["padding"+(t.lang.rtl===!0?"Right":"Left")]:16+e.insetLevel*56+"px"});function E(s){o.value===!0&&(h.value!==null&&s.qAvoidFocus!==!0&&(s.qKeyEvent!==!0&&document.activeElement===f.value?h.value.focus():document.activeElement===h.value&&f.value.focus()),c(s))}function S(s){if(o.value===!0&&re(s,[13,32])===!0){fe(s),s.qKeyEvent=!0;const y=new MouseEvent("click",s);y.qKeyEvent=!0,f.value.dispatchEvent(y)}l("keyup",s)}function M(){const s=Xe(n.default,[]);return o.value===!0&&s.unshift(L("div",{class:"q-focus-helper",tabindex:-1,ref:h})),s}return()=>{const s={ref:f,class:r.value,style:C.value,role:"listitem",onClick:E,onKeyup:S};return o.value===!0?(s.tabindex=e.tabindex||"0",Object.assign(s,a.value)):b.value===!0&&(s["aria-disabled"]="true"),L(m.value,s,M())}}}),dt=A({name:"QItemLabel",props:{overline:Boolean,caption:Boolean,header:Boolean,lines:[Number,String]},setup(e,{slots:n}){const l=x(()=>parseInt(e.lines,10)),t=x(()=>"q-item__label"+(e.overline===!0?" q-item__label--overline text-overline":"")+(e.caption===!0?" q-item__label--caption text-caption":"")+(e.header===!0?" q-item__label--header":"")+(l.value===1?" ellipsis":"")),i=x(()=>e.lines!==void 0&&l.value>1?{overflow:"hidden",display:"-webkit-box","-webkit-box-orient":"vertical","-webkit-line-clamp":l.value}:null);return()=>L("div",{style:i.value,class:t.value},O(n.default))}});export{ct as Q,ae as a,tt as b,et as c,nt as d,Ye as e,dt as f,rt as g,st as h,Ze as i,ue as p,le as r,ve as s,Je as u,lt as v};