2 lines
7.4 KiB
JavaScript
2 lines
7.4 KiB
JavaScript
import{a as $,n as f,x as O,t as u,p as L,ak as M,al as q,am as F,q as S,w as x,o as W,ar as N,as as k,at as U,s as j,m as A,au as I,E as K,ae as D,av as Z,aw as G,Z as J,ax as V,ay as X,az as Y,a5 as C}from"./index-BMUcF_AE.js";import{a as B}from"./QResizeObserver-UV_Ef03s.js";const le=$({name:"QToolbarTitle",props:{shrink:Boolean},setup(e,{slots:v}){const l=u(()=>"q-toolbar__title ellipsis"+(e.shrink===!0?" col-shrink":""));return()=>f("div",{class:l.value},O(v.default))}}),ae=$({name:"QToolbar",props:{inset:Boolean},setup(e,{slots:v}){const l=u(()=>"q-toolbar row no-wrap items-center"+(e.inset===!0?" q-toolbar--inset":""));return()=>f("div",{class:l.value,role:"toolbar"},O(v.default))}}),ie=$({name:"QHeader",props:{modelValue:{type:Boolean,default:!0},reveal:Boolean,revealOffset:{type:Number,default:250},bordered:Boolean,elevated:Boolean,heightHint:{type:[String,Number],default:50}},emits:["reveal","focusin"],setup(e,{slots:v,emit:l}){const{proxy:{$q:n}}=L(),o=M(F,q);if(o===q)return console.error("QHeader needs to be child of QLayout"),q;const r=S(parseInt(e.heightHint,10)),c=S(!0),y=u(()=>e.reveal===!0||o.view.value.indexOf("H")!==-1||n.platform.is.ios&&o.isContainer.value===!0),g=u(()=>{if(e.modelValue!==!0)return 0;if(y.value===!0)return c.value===!0?r.value:0;const t=r.value-o.scroll.value.position;return t>0?t:0}),s=u(()=>e.modelValue!==!0||y.value===!0&&c.value!==!0),T=u(()=>e.modelValue===!0&&s.value===!0&&e.reveal===!0),p=u(()=>"q-header q-layout__section--marginal "+(y.value===!0?"fixed":"absolute")+"-top"+(e.bordered===!0?" q-header--bordered":"")+(s.value===!0?" q-header--hidden":"")+(e.modelValue!==!0?" q-layout--prevent-focus":"")),w=u(()=>{const t=o.rows.value.top,h={};return t[0]==="l"&&o.left.space===!0&&(h[n.lang.rtl===!0?"right":"left"]=`${o.left.size}px`),t[2]==="r"&&o.right.space===!0&&(h[n.lang.rtl===!0?"left":"right"]=`${o.right.size}px`),h});function i(t,h){o.update("header",t,h)}function m(t,h){t.value!==h&&(t.value=h)}function P({height:t}){m(r,t),i("size",t)}function H(t){T.value===!0&&m(c,!0),l("focusin",t)}x(()=>e.modelValue,t=>{i("space",t),m(c,!0),o.animate()}),x(g,t=>{i("offset",t)}),x(()=>e.reveal,t=>{t===!1&&m(c,e.modelValue)}),x(c,t=>{o.animate(),l("reveal",t)}),x(o.scroll,t=>{e.reveal===!0&&m(c,t.direction==="up"||t.position<=e.revealOffset||t.position-t.inflectionPoint<100)});const Q={};return o.instances.header=Q,e.modelValue===!0&&i("size",r.value),i("space",e.modelValue),i("offset",g.value),W(()=>{o.instances.header===Q&&(o.instances.header=void 0,i("size",0),i("offset",0),i("space",!1))}),()=>{const t=N(v.default,[]);return e.elevated===!0&&t.push(f("div",{class:"q-layout__shadow absolute-full overflow-hidden no-pointer-events"})),t.push(f(B,{debounce:0,onResize:P})),f("header",{class:p.value,style:w.value,onFocusin:H},t)}}}),re=$({name:"QPageContainer",setup(e,{slots:v}){const{proxy:{$q:l}}=L(),n=M(F,q);if(n===q)return console.error("QPageContainer needs to be child of QLayout"),q;k(U,!0);const o=u(()=>{const r={};return n.header.space===!0&&(r.paddingTop=`${n.header.size}px`),n.right.space===!0&&(r[`padding${l.lang.rtl===!0?"Left":"Right"}`]=`${n.right.size}px`),n.footer.space===!0&&(r.paddingBottom=`${n.footer.size}px`),n.left.space===!0&&(r[`padding${l.lang.rtl===!0?"Right":"Left"}`]=`${n.left.size}px`),r});return()=>f("div",{class:"q-page-container",style:o.value},O(v.default))}}),{passive:_}=I,ee=["both","horizontal","vertical"],te=$({name:"QScrollObserver",props:{axis:{type:String,validator:e=>ee.includes(e),default:"vertical"},debounce:[String,Number],scrollTarget:j},emits:["scroll"],setup(e,{emit:v}){const l={position:{top:0,left:0},direction:"down",directionChanged:!1,delta:{top:0,left:0},inflectionPoint:{top:0,left:0}};let n=null,o,r;x(()=>e.scrollTarget,()=>{g(),y()});function c(){n?.();const p=Math.max(0,Z(o)),w=G(o),i={top:p-l.position.top,left:w-l.position.left};if(e.axis==="vertical"&&i.top===0||e.axis==="horizontal"&&i.left===0)return;const m=Math.abs(i.top)>=Math.abs(i.left)?i.top<0?"up":"down":i.left<0?"left":"right";l.position={top:p,left:w},l.directionChanged=l.direction!==m,l.delta=i,l.directionChanged===!0&&(l.direction=m,l.inflectionPoint=l.position),v("scroll",{...l})}function y(){o=A(r,e.scrollTarget),o.addEventListener("scroll",s,_),s(!0)}function g(){o!==void 0&&(o.removeEventListener("scroll",s,_),o=void 0)}function s(p){if(p===!0||e.debounce===0||e.debounce==="0")c();else if(n===null){const[w,i]=e.debounce?[setTimeout(c,e.debounce),clearTimeout]:[requestAnimationFrame(c),cancelAnimationFrame];n=()=>{i(w),n=null}}}const{proxy:T}=L();return x(()=>T.$q.lang.rtl,c),K(()=>{r=T.$el.parentNode,y()}),W(()=>{n?.(),g()}),Object.assign(T,{trigger:s,getPosition:()=>l}),D}}),se=$({name:"QLayout",props:{container:Boolean,view:{type:String,default:"hhh lpr fff",validator:e=>/^(h|l)h(h|r) lpr (f|l)f(f|r)$/.test(e.toLowerCase())},onScroll:Function,onScrollHeight:Function,onResize:Function},setup(e,{slots:v,emit:l}){const{proxy:{$q:n}}=L(),o=S(null),r=S(n.screen.height),c=S(e.container===!0?0:n.screen.width),y=S({position:0,direction:"down",inflectionPoint:0}),g=S(0),s=S(J.value===!0?0:V()),T=u(()=>"q-layout q-layout--"+(e.container===!0?"containerized":"standard")),p=u(()=>e.container===!1?{minHeight:n.screen.height+"px"}:null),w=u(()=>s.value!==0?{[n.lang.rtl===!0?"left":"right"]:`${s.value}px`}:null),i=u(()=>s.value!==0?{[n.lang.rtl===!0?"right":"left"]:0,[n.lang.rtl===!0?"left":"right"]:`-${s.value}px`,width:`calc(100% + ${s.value}px)`}:null);function m(a){if(e.container===!0||document.qScrollPrevented!==!0){const d={position:a.position.top,direction:a.direction,directionChanged:a.directionChanged,inflectionPoint:a.inflectionPoint.top,delta:a.delta.top};y.value=d,e.onScroll!==void 0&&l("scroll",d)}}function P(a){const{height:d,width:z}=a;let b=!1;r.value!==d&&(b=!0,r.value=d,e.onScrollHeight!==void 0&&l("scrollHeight",d),Q()),c.value!==z&&(b=!0,c.value=z),b===!0&&e.onResize!==void 0&&l("resize",a)}function H({height:a}){g.value!==a&&(g.value=a,Q())}function Q(){if(e.container===!0){const a=r.value>g.value?V():0;s.value!==a&&(s.value=a)}}let t=null;const h={instances:{},view:u(()=>e.view),isContainer:u(()=>e.container),rootRef:o,height:r,containerHeight:g,scrollbarWidth:s,totalWidth:u(()=>c.value+s.value),rows:u(()=>{const a=e.view.toLowerCase().split(" ");return{top:a[0].split(""),middle:a[1].split(""),bottom:a[2].split("")}}),header:C({size:0,offset:0,space:!1}),right:C({size:300,offset:0,space:!1}),footer:C({size:0,offset:0,space:!1}),left:C({size:300,offset:0,space:!1}),scroll:y,animate(){t!==null?clearTimeout(t):document.body.classList.add("q-body--layout-animate"),t=setTimeout(()=>{t=null,document.body.classList.remove("q-body--layout-animate")},155)},update(a,d,z){h[a][d]=z}};if(k(F,h),V()>0){let a=function(){b=null,R.classList.remove("hide-scrollbar")},d=function(){if(b===null){if(R.scrollHeight>n.screen.height)return;R.classList.add("hide-scrollbar")}else clearTimeout(b);b=setTimeout(a,300)},z=function(E){b!==null&&E==="remove"&&(clearTimeout(b),a()),window[`${E}EventListener`]("resize",d)},b=null;const R=document.body;x(()=>e.container!==!0?"add":"remove",z),e.container!==!0&&z("add"),X(()=>{z("remove")})}return()=>{const a=Y(v.default,[f(te,{onScroll:m}),f(B,{onResize:P})]),d=f("div",{class:T.value,style:p.value,ref:e.container===!0?void 0:o,tabindex:-1},a);return e.container===!0?f("div",{class:"q-layout-container overflow-hidden",ref:o},[f(B,{onResize:H}),f("div",{class:"absolute-full",style:w.value},[f("div",{class:"scroll",style:i.value},[d])])]):d}}});export{ie as Q,ae as a,le as b,re as c,se as d};
|