@rero/rero-ils-ui
Version:
User interface for RERO integrated library system (RERO ILS).
75 lines (64 loc) • 13.7 kB
JavaScript
import{A as p,Ba as K,Ea as O,Fa as Z,Ga as b,Ha as G,X as Q,na as q,xa as W,y as l,ya as j}from"./chunk-FRI676LD.js";import{Fa as $,ga as N,wa as U}from"./chunk-WKOKZ3JO.js";import{Cb as k,Db as V,Eb as A,Ed as H,Fa as M,Gc as u,Sb as _,Vb as F,Vc as I,Xb as P,ac as c,bc as v,cc as y,da as D,ga as T,gb as a,ia as f,jc as X,rc as g,tc as Y,uc as x,vc as z,wa as E,wc as R,xc as d,yb as S,yc as h}from"./chunk-3WD6XLXL.js";var J=`
.p-scrollpanel-content-container {
overflow: hidden;
width: 100%;
height: 100%;
position: relative;
z-index: 1;
float: left;
}
.p-scrollpanel-content {
height: calc(100% + calc(2 * dt('scrollpanel.bar.size')));
width: calc(100% + calc(2 * dt('scrollpanel.bar.size')));
padding-inline: 0 calc(2 * dt('scrollpanel.bar.size'));
padding-block: 0 calc(2 * dt('scrollpanel.bar.size'));
position: relative;
overflow: auto;
box-sizing: border-box;
scrollbar-width: none;
}
.p-scrollpanel-content::-webkit-scrollbar {
display: none;
}
.p-scrollpanel-bar {
position: relative;
border-radius: dt('scrollpanel.bar.border.radius');
z-index: 2;
cursor: pointer;
opacity: 0;
outline-color: transparent;
background: dt('scrollpanel.bar.background');
border: 0 none;
transition:
outline-color dt('scrollpanel.transition.duration'),
opacity dt('scrollpanel.transition.duration');
}
.p-scrollpanel-bar:focus-visible {
box-shadow: dt('scrollpanel.bar.focus.ring.shadow');
outline: dt('scrollpanel.barfocus.ring.width') dt('scrollpanel.bar.focus.ring.style') dt('scrollpanel.bar.focus.ring.color');
outline-offset: dt('scrollpanel.barfocus.ring.offset');
}
.p-scrollpanel-bar-y {
width: dt('scrollpanel.bar.size');
inset-block-start: 0;
}
.p-scrollpanel-bar-x {
height: dt('scrollpanel.bar.size');
inset-block-end: 0;
}
.p-scrollpanel-hidden {
visibility: hidden;
}
.p-scrollpanel:hover .p-scrollpanel-bar,
.p-scrollpanel:active .p-scrollpanel-bar {
opacity: 1;
}
.p-scrollpanel-grabbed {
user-select: none;
}
`;var ee=["content"],se=["xBar"],re=["yBar"],le=["*"];function ae(s,ie){s&1&&x(0)}function ce(s,ie){s&1&&X(0)}var de=`
${J}
.p-scrollpanel {
display: block;
}
`,he={root:"p-scrollpanel p-component",contentContainer:"p-scrollpanel-content-container",content:"p-scrollpanel-content",barX:"p-scrollpanel-bar p-scrollpanel-bar-x",barY:"p-scrollpanel-bar p-scrollpanel-bar-y"},te=(()=>{class s extends K{name="scrollpanel";style=de;classes=he;static \u0275fac=(()=>{let e;return function(t){return(e||(e=M(s)))(t||s)}})();static \u0275prov=D({token:s,factory:s.\u0275fac})}return s})();var ne=new T("SCROLLPANEL_INSTANCE"),Xe=(()=>{class s extends Z{componentName="ScrollPanel";$pcScrollPanel=f(ne,{optional:!0,skipSelf:!0})??void 0;bindDirectiveInstance=f(b,{self:!0});onAfterViewChecked(){this.bindDirectiveInstance.setAttrs(this.ptms(["host","root"]))}styleClass;step=5;contentViewChild;xBarViewChild;yBarViewChild;contentTemplate;templates;_contentTemplate;scrollYRatio;scrollXRatio;timeoutFrame=e=>setTimeout(e,0);initialized=!1;lastPageY;lastPageX;isXBarClicked=!1;isYBarClicked=!1;lastScrollLeft=0;lastScrollTop=0;orientation="vertical";timer;contentId;windowResizeListener;contentScrollListener;mouseEnterListener;xBarMouseDownListener;yBarMouseDownListener;documentMouseMoveListener;documentMouseUpListener;_componentStyle=f(te);zone=f(E);onInit(){this.contentId=q("pn_id_")+"_content"}onAfterViewInit(){$(this.platformId)&&this.zone.runOutsideAngular(()=>{this.moveBar(),this.moveBar=this.moveBar.bind(this),this.onXBarMouseDown=this.onXBarMouseDown.bind(this),this.onYBarMouseDown=this.onYBarMouseDown.bind(this),this.onDocumentMouseMove=this.onDocumentMouseMove.bind(this),this.onDocumentMouseUp=this.onDocumentMouseUp.bind(this),this.windowResizeListener=this.renderer.listen(window,"resize",this.moveBar),this.contentScrollListener=this.renderer.listen(this.contentViewChild.nativeElement,"scroll",this.moveBar),this.mouseEnterListener=this.renderer.listen(this.contentViewChild.nativeElement,"mouseenter",this.moveBar),this.xBarMouseDownListener=this.renderer.listen(this.xBarViewChild.nativeElement,"mousedown",this.onXBarMouseDown),this.yBarMouseDownListener=this.renderer.listen(this.yBarViewChild.nativeElement,"mousedown",this.onYBarMouseDown),this.calculateContainerHeight(),this.initialized=!0})}onAfterContentInit(){this.templates.forEach(e=>{e.getType()==="content"?this._contentTemplate=e.template:this._contentTemplate=e.template})}calculateContainerHeight(){let e=this.el.nativeElement,n=this.contentViewChild.nativeElement,t=this.xBarViewChild.nativeElement,o=this.document.defaultView,i=o.getComputedStyle(e),w=o.getComputedStyle(t),r=Q(e)-parseInt(w.height,10);i["max-height"]!="none"&&r==0&&(n.offsetHeight+parseInt(w.height,10)>parseInt(i["max-height"],10)?e.style.height=i["max-height"]:e.style.height=n.offsetHeight+parseFloat(i.paddingTop)+parseFloat(i.paddingBottom)+parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth)+"px")}moveBar(){let e=this.el.nativeElement,n=this.contentViewChild.nativeElement,t=this.xBarViewChild.nativeElement,o=n.scrollWidth,i=n.clientWidth,w=(e.clientHeight-t.clientHeight)*-1;this.scrollXRatio=i/o;let r=this.yBarViewChild.nativeElement,C=n.scrollHeight,L=n.clientHeight,oe=(e.clientWidth-r.clientWidth)*-1;this.scrollYRatio=L/C,this.requestAnimationFrame(()=>{if(this.scrollXRatio>=1)t.setAttribute("data-p-scrollpanel-hidden","true"),!this.$unstyled()&&l(t,"p-scrollpanel-hidden");else{t.setAttribute("data-p-scrollpanel-hidden","false"),!this.$unstyled()&&p(t,"p-scrollpanel-hidden");let m=Math.max(this.scrollXRatio*100,10),B=Math.abs(n.scrollLeft*(100-m)/(o-i));t.style.cssText="width:"+m+"%; inset-inline-start:"+B+"%;bottom:"+w+"px;"}if(this.scrollYRatio>=1)r.setAttribute("data-p-scrollpanel-hidden","true"),!this.$unstyled()&&l(r,"p-scrollpanel-hidden");else{r.setAttribute("data-p-scrollpanel-hidden","false"),!this.$unstyled()&&p(r,"p-scrollpanel-hidden");let m=Math.max(this.scrollYRatio*100,10),B=n.scrollTop*(100-m)/(C-L);r.style.cssText="height:"+m+"%; top: calc("+B+"% - "+t.clientHeight+"px); inset-inline-end:"+oe+"px;"}}),this.cd.markForCheck()}onScroll(e){this.lastScrollLeft!==e.target.scrollLeft?(this.lastScrollLeft=e.target.scrollLeft,this.orientation="horizontal"):this.lastScrollTop!==e.target.scrollTop&&(this.lastScrollTop=e.target.scrollTop,this.orientation="vertical"),this.moveBar()}onKeyDown(e){if(this.orientation==="vertical")switch(e.code){case"ArrowDown":{this.setTimer("scrollTop",this.step),e.preventDefault();break}case"ArrowUp":{this.setTimer("scrollTop",this.step*-1),e.preventDefault();break}case"ArrowLeft":case"ArrowRight":{e.preventDefault();break}default:break}else if(this.orientation==="horizontal")switch(e.code){case"ArrowRight":{this.setTimer("scrollLeft",this.step),e.preventDefault();break}case"ArrowLeft":{this.setTimer("scrollLeft",this.step*-1),e.preventDefault();break}case"ArrowDown":case"ArrowUp":{e.preventDefault();break}default:break}}onKeyUp(){this.clearTimer()}repeat(e,n){this.contentViewChild?.nativeElement&&(this.contentViewChild.nativeElement[e]+=n),this.moveBar()}setTimer(e,n){this.clearTimer(),this.timer=setTimeout(()=>{this.repeat(e,n)},40)}clearTimer(){this.timer&&clearTimeout(this.timer)}bindDocumentMouseListeners(){this.documentMouseMoveListener||(this.documentMouseMoveListener=e=>{this.onDocumentMouseMove(e)},this.document.addEventListener("mousemove",this.documentMouseMoveListener)),this.documentMouseUpListener||(this.documentMouseUpListener=e=>{this.onDocumentMouseUp(e)},this.document.addEventListener("mouseup",this.documentMouseUpListener))}unbindDocumentMouseListeners(){this.documentMouseMoveListener&&(this.document.removeEventListener("mousemove",this.documentMouseMoveListener),this.documentMouseMoveListener=null),this.documentMouseUpListener&&(document.removeEventListener("mouseup",this.documentMouseUpListener),this.documentMouseUpListener=null)}onYBarMouseDown(e){this.isYBarClicked=!0,this.yBarViewChild?.nativeElement?.focus(),this.lastPageY=e.pageY,this.yBarViewChild?.nativeElement?.setAttribute("data-p-scrollpanel-grabbed","true"),!this.$unstyled()&&l(this.yBarViewChild.nativeElement,"p-scrollpanel-grabbed"),this.document.body.setAttribute("data-p-scrollpanel-grabbed","true"),!this.$unstyled()&&l(this.document.body,"p-scrollpanel-grabbed"),this.bindDocumentMouseListeners(),e.preventDefault()}onXBarMouseDown(e){this.isXBarClicked=!0,this.xBarViewChild?.nativeElement?.focus(),this.lastPageX=e.pageX,this.xBarViewChild?.nativeElement?.setAttribute("data-p-scrollpanel-grabbed","false"),!this.$unstyled()&&l(this.xBarViewChild.nativeElement,"p-scrollpanel-grabbed"),this.document.body.setAttribute("data-p-scrollpanel-grabbed","false"),!this.$unstyled()&&l(this.document.body,"p-scrollpanel-grabbed"),this.bindDocumentMouseListeners(),e.preventDefault()}onDocumentMouseMove(e){this.isXBarClicked?this.onMouseMoveForXBar(e):this.isYBarClicked?this.onMouseMoveForYBar(e):(this.onMouseMoveForXBar(e),this.onMouseMoveForYBar(e))}onMouseMoveForXBar(e){let n=e.pageX-this.lastPageX;this.lastPageX=e.pageX,this.requestAnimationFrame(()=>{this.contentViewChild.nativeElement.scrollLeft+=n/this.scrollXRatio})}onMouseMoveForYBar(e){let n=e.pageY-this.lastPageY;this.lastPageY=e.pageY,this.requestAnimationFrame(()=>{this.contentViewChild.nativeElement.scrollTop+=n/this.scrollYRatio})}scrollTop(e){let n=this.contentViewChild.nativeElement.scrollHeight-this.contentViewChild.nativeElement.clientHeight;e=e>n?n:e>0?e:0,this.contentViewChild.nativeElement.scrollTop=e}onFocus(e){this.xBarViewChild?.nativeElement?.isSameNode(e.target)?this.orientation="horizontal":this.yBarViewChild?.nativeElement?.isSameNode(e.target)&&(this.orientation="vertical")}onBlur(){this.orientation==="horizontal"&&(this.orientation="vertical")}onDocumentMouseUp(e){this.yBarViewChild?.nativeElement?.setAttribute("data-p-scrollpanel-grabbed","false"),!this.$unstyled()&&p(this.yBarViewChild.nativeElement,"p-scrollpanel-grabbed"),this.xBarViewChild?.nativeElement?.setAttribute("data-p-scrollpanel-grabbed","false"),!this.$unstyled()&&p(this.xBarViewChild.nativeElement,"p-scrollpanel-grabbed"),this.document.body.setAttribute("data-p-scrollpanel-grabbed","false"),!this.$unstyled()&&p(this.document.body,"p-scrollpanel-grabbed"),this.unbindDocumentMouseListeners(),this.isXBarClicked=!1,this.isYBarClicked=!1}requestAnimationFrame(e){(window.requestAnimationFrame||this.timeoutFrame)(e)}unbindListeners(){this.windowResizeListener&&(this.windowResizeListener(),this.windowResizeListener=null),this.contentScrollListener&&(this.contentScrollListener(),this.contentScrollListener=null),this.mouseEnterListener&&(this.mouseEnterListener(),this.mouseEnterListener=null),this.xBarMouseDownListener&&(this.xBarMouseDownListener(),this.xBarMouseDownListener=null),this.yBarMouseDownListener&&(this.yBarMouseDownListener(),this.yBarMouseDownListener=null)}onDestroy(){this.initialized&&this.unbindListeners()}refresh(){this.moveBar()}static \u0275fac=(()=>{let e;return function(t){return(e||(e=M(s)))(t||s)}})();static \u0275cmp=S({type:s,selectors:[["p-scroll-panel"],["p-scrollPanel"],["p-scrollpanel"]],contentQueries:function(n,t,o){if(n&1&&z(o,ee,4)(o,W,4),n&2){let i;d(i=h())&&(t.contentTemplate=i.first),d(i=h())&&(t.templates=i)}},viewQuery:function(n,t){if(n&1&&R(ee,5)(se,5)(re,5),n&2){let o;d(o=h())&&(t.contentViewChild=o.first),d(o=h())&&(t.xBarViewChild=o.first),d(o=h())&&(t.yBarViewChild=o.first)}},hostVars:2,hostBindings:function(n,t){n&2&&u(t.cn(t.cx("root"),t.styleClass))},inputs:{styleClass:"styleClass",step:[2,"step","step",H]},features:[I([te,{provide:ne,useExisting:s},{provide:O,useExisting:s}]),k([b]),V],ngContentSelectors:le,decls:9,vars:22,consts:[["content",""],["xBar",""],["yBar",""],[3,"pBind"],[3,"mouseenter","scroll","pBind"],[4,"ngTemplateOutlet"],["tabindex","0","role","scrollbar",3,"mousedown","keydown","keyup","focus","blur","pBind"],["tabindex","0","role","scrollbar",3,"mousedown","keydown","keyup","focus","pBind"]],template:function(n,t){n&1&&(Y(),v(0,"div",3)(1,"div",4,0),g("mouseenter",function(){return t.moveBar()})("scroll",function(i){return t.onScroll(i)}),F(3,ae,1,0),A(4,ce,1,0,"ng-container",5),y()(),v(5,"div",6,1),g("mousedown",function(i){return t.onXBarMouseDown(i)})("keydown",function(i){return t.onKeyDown(i)})("keyup",function(){return t.onKeyUp()})("focus",function(i){return t.onFocus(i)})("blur",function(){return t.onBlur()}),y(),v(7,"div",7,2),g("mousedown",function(i){return t.onYBarMouseDown(i)})("keydown",function(i){return t.onKeyDown(i)})("keyup",function(){return t.onKeyUp()})("focus",function(i){return t.onFocus(i)}),y()),n&2&&(u(t.cx("contentContainer")),c("pBind",t.ptm("contentContainer")),a(),u(t.cx("content")),c("pBind",t.ptm("content")),a(2),P(!t.contentTemplate&&!t._contentTemplate?3:-1),a(),c("ngTemplateOutlet",t.contentTemplate||t._contentTemplate),a(),u(t.cx("barX")),c("pBind",t.ptm("barX")),_("aria-orientation","horizontal")("aria-valuenow",t.lastScrollLeft)("aria-controls",t.contentId)("data-pc-group-section","bar"),a(2),u(t.cx("barY")),c("pBind",t.ptm("barY")),_("aria-orientation","vertical")("aria-valuenow",t.lastScrollTop)("aria-controls",t.contentId)("data-pc-group-section","bar"))},dependencies:[U,N,j,G,b],encapsulation:2,changeDetection:0})}return s})();export{Xe as a};