@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
2 lines (1 loc) • 12.5 kB
JavaScript
import{Sb as de,Ya as me,wb as fe}from"./chunk-4U5A2DEP.js";import{Cb as H,Eb as I,Ed as ae,Fb as G,Gb as X,Ib as v,J as b,Jb as C,Ka as Q,Kb as y,Ma as T,N as F,Qa as Z,T as L,X as V,Xa as w,Z as z,Zc as ie,_a as $,ad as se,bb as _,cb as j,dc as ee,ed as oe,f as W,fc as te,ha as c,jb as q,kb as K,kf as ce,ma as M,md as ne,na as x,p as k,pb as R,qb as O,rb as P,ta as A,tb as J,ub as Y,ud as re,va as N,vb as U,xd as le,ya as E,yd as he,zb as D}from"./chunk-HW2H3ISM.js";var ve=["iFilter"];function Ce(r,i){if(r&1){let m=D();O(0,"span",3)(1,"fa-icon",4),H("click",function(){M(m);let e=I();return x(e.clear())}),P()()}if(r&2){let m=I();T(),R("icon",m.faTimes)}}var De=(()=>{let i=class i{constructor(){this.search=A(""),this.locale=c(he),this.faTimes=ce,this.fb=c(re),this.searchControl=this.fb.control(""),this.subscription=this.searchControl.valueChanges.pipe(b(300),F()).subscribe(t=>this.onType(t))}ngOnDestroy(){this.subscription.unsubscribe()}onKeyPress(t){(t.ctrlKey||t.metaKey)&&t.keyCode===70?(t.preventDefault(),t.stopPropagation(),this.iFilter.nativeElement.focus()):t.keyCode===27&&(t.preventDefault(),t.stopPropagation())}clear(){this.searchControl&&(this.searchControl.reset(),this.iFilter.nativeElement.value="")}onType(t){this.search.set(t)}};i.\u0275fac=function(e){return new(e||i)},i.\u0275cmp=w({type:i,selectors:[["app-input-filter"]],viewQuery:function(e,s){if(e&1&&v(ve,7),e&2){let o;C(o=y())&&(s.iFilter=o.first)}},hostBindings:function(e,s){e&1&&H("keydown",function(h){return s.onKeyPress(h)},Q)},decls:5,vars:6,consts:[["iFilter",""],[1,"btn-group",2,"height","30px","max-width","150px"],["type","text",1,"form-control","form-control-sm",2,"padding-right","24px",3,"keyup.escape","placeholder","formControl"],[1,"cursor-pointer",2,"position","absolute","right","5px","top","3px","z-index","1001","font-size","1rem"],["role","button",3,"click","icon"]],template:function(e,s){if(e&1){let o=D();O(0,"div",1)(1,"input",2,0),ee(3,"translate"),H("keyup.escape",function(){return M(o),x(s.clear())}),P(),q(4,Ce,2,1,"span",3),P()}e&2&&(T(),R("placeholder",te(3,3,"Filter",s.locale.language))("formControl",s.searchControl),T(3),K(s.search()?4:-1))},dependencies:[le,se,oe,ne,ie,ae],encapsulation:2});let r=i;return r})();var ye=["content"],Se=["shim"],be=["*"],Qe=(()=>{let i=class i{constructor(){this.isScrollBottom=new _,this.isScrollTop=new _,this.resizeOffset=130,this.galleryMode=!1,this.selectedChat=null,this.items=[],this.childHeight=35,this.bufferAmount=0,this.viewPortItems=[],this.element=c(E),this.renderer=c(Z),this.ngZone=c(j),this.layout=c(fe),this.subscriptions=[],this.scrollbarWidth=0,this._scrollChat=new W,this.scrollChat=this._scrollChat.asObservable().pipe(b(50)),this.startupLoop=!0,this.scrollTimer=null,this.lastScrollHeight=-1,this.lastTopPadding=-1,this.toggleLeftSidebar=this.layout.toggleLeftSideBar.pipe(V(1),z(t=>k(t).pipe(L({count:30,delay:10})))),this.tableScrollHovering=()=>{clearTimeout(this.scrollTimer),this.contentElementRef.nativeElement.classList.contains("table-disable-hover")||this.renderer.addClass(this.contentElementRef.nativeElement,"table-disable-hover"),this.scrollTimer=setTimeout(()=>{this.renderer.removeClass(this.contentElementRef.nativeElement,"table-disable-hover")},200),this.refresh()},this.refreshWithDimensions=()=>{this.resizeOffsetHeight(),this.refresh(!0)},this.refreshWithoutDimensions=()=>{this.refresh()},this.refreshChatWithoutDimensions=()=>{this.chatIsScrolledToTop()&&!this.selectedChat.allHistoryLoaded?this.element.nativeElement.scrollTo({left:0,top:this.element.nativeElement.scrollTop,behavior:"auto"}):(this.refreshWithoutDimensions(),this._scrollChat.next())},this.refreshChatWithDimensions=()=>{this.resizeOffsetHeight(),this.refresh(!0),this.selectedChat.isScrolledToBottom?this.scrollInto(-2):this._scrollChat.next()}}ngOnInit(){this.resizeOffsetHeight(!0),this.addParentEventHandlers(),this.selectedChat?(this.childHeight=1,this.subscriptions.push(this.scrollChat.subscribe(()=>this.checkScrollChat()))):this.galleryMode||this.subscriptions.push(this.toggleLeftSidebar.subscribe(()=>this.resizeTableHeader()))}ngOnDestroy(){this.eventScrollHandler&&(this.eventScrollHandler(),this.eventScrollHandler=void 0),this.subscriptions.forEach(t=>t.unsubscribe())}ngOnChanges(t){if(this.previousStart=void 0,this.previousEnd=void 0,this.galleryMode)this.startupLoop=!0;else{let e=t.items||void 0;(t.items!==void 0&&e.previousValue===void 0||e.previousValue!==void 0&&e.previousValue.length===0)&&(this.startupLoop=!0)}this.refresh(!0),this.checkChangesOnChat(t)}refresh(t=!1){this.ngZone.runOutsideAngular(()=>{(t||!this.dimensionsView)&&this.calculateDimensions(),requestAnimationFrame(()=>this.calculateItems())}),this.resizeTableHeader()}scrollInto(t){if(t===-1){this.element.nativeElement.scrollTo({left:0,top:0,behavior:"auto"});return}else if(t===-2){this.element.nativeElement.scrollTo({left:0,top:this.element.nativeElement.scrollHeight,behavior:"smooth"});return}else if(t===0){this.refresh();return}let e=(this.items||[]).indexOf(t);if(e<0||e>=(this.items||[]).length)return;let s=this.dimensionsView,o=Math.floor(e/s.itemsPerRow)*s.childHeight-s.childHeight*Math.min(e,this.bufferAmount);this.element.nativeElement.scrollTo({left:0,top:o,behavior:"smooth"}),this.refresh()}checkChangesOnChat(t){this.selectedChat&&(t.selectedChat?(this.renderer.setStyle(this.element.nativeElement,"visibility","hidden"),setTimeout(()=>{this.selectedChat.lastScrollPosition===null&&this.saveChatScrollPosition(this.element.nativeElement.scrollHeight),this.element.nativeElement.scrollTo({left:0,top:this.selectedChat.lastScrollPosition,behavior:"auto"}),this.checkScrollChat(),this.renderer.setStyle(this.element.nativeElement,"visibility","visible")},50)):this.chatIsScrolledToBottom()?this.restoreBottomScrollChat():this.chatIsScrolledToTop()&&this.restoreTopScrollChat())}checkScrollChat(){let t=this.chatIsScrolledToBottom(),e=this.chatIsScrolledToTop();e?this.saveChatScrollPosition(this.element.nativeElement.scrollHeight-this.element.nativeElement.scrollTop):t?this.saveChatScrollPosition(this.element.nativeElement.scrollHeight):this.saveChatScrollPosition(),this.ngZone.run(()=>{this.isScrollBottom.next(t),this.isScrollTop.next(e)})}saveChatScrollPosition(t=null){this.selectedChat.lastScrollPosition=t||this.element.nativeElement.scrollTop}chatIsScrolledToBottom(){return Math.ceil(this.element.nativeElement.clientHeight/10)*10===Math.ceil((this.element.nativeElement.scrollHeight-this.element.nativeElement.scrollTop)/10)*10}chatIsScrolledToTop(){return this.element.nativeElement.scrollTop<=300}restoreBottomScrollChat(){setTimeout(()=>{this.element.nativeElement.scrollTo({left:0,top:this.element.nativeElement.scrollHeight,behavior:"smooth"})},50)}restoreTopScrollChat(){setTimeout(()=>{this.element.nativeElement.scrollTop=this.element.nativeElement.scrollHeight-this.selectedChat.lastScrollPosition},50)}resizeOffsetHeight(t=!1){let e=window.innerHeight-this.resizeOffset;(t||this.element.nativeElement.offsetHeight!==e)&&this.renderer.setStyle(this.element.nativeElement,"height",`${e-1}px`)}resizeTableHeader(){!this.selectedChat&&!this.galleryMode&&this.element.nativeElement.previousElementSibling&&this.element.nativeElement.previousElementSibling.classList.contains("app-table")&&setTimeout(()=>this.renderer.setStyle(this.element.nativeElement.previousElementSibling,"width",`${this.element.nativeElement.clientWidth}px`),50)}addParentEventHandlers(){this.ngZone.runOutsideAngular(()=>{this.galleryMode?this.eventScrollHandler=this.renderer.listen(this.element.nativeElement,"scroll",this.refreshWithoutDimensions):this.selectedChat?this.eventScrollHandler=this.renderer.listen(this.element.nativeElement,"scroll",this.refreshChatWithoutDimensions):this.eventScrollHandler=this.renderer.listen(this.element.nativeElement,"scroll",this.tableScrollHovering),this.selectedChat?this.subscriptions.push(this.layout.resizeEvent.subscribe(()=>this.refreshChatWithDimensions())):this.subscriptions.push(this.layout.resizeEvent.subscribe(()=>this.refreshWithDimensions()))})}countItemsPerRow(){if(this.galleryMode){let t,e,s=this.contentElementRef.nativeElement.children;for(s[0]&&(s=s[0].children),e=0;e<s.length&&!(t!==void 0&&t!==s[e].offsetTop);e++)t=s[e].offsetTop;return e}else return 1}calculateDimensions(){let t=this.element.nativeElement,e=t.offsetWidth-t.clientWidth;this.scrollbarWidth!=e&&(this.resizeTableHeader(),this.scrollbarWidth=e);let o=(this.items||[]).length,h=t.clientWidth-this.scrollbarWidth,S=t.clientHeight,f;if(this.childWidth===void 0||this.childHeight===void 0){let B=this.contentElementRef.nativeElement;f=B.children[0]?B.children[0].getBoundingClientRect():{width:h,height:S}}let n=this.childWidth||f.width,d=this.childHeight||f.height,a=this.countItemsPerRow(),u=Math.max(1,Math.floor(h/n));this.galleryMode&&a===0?a=u:a=Math.max(1,a);let l=Math.max(1,Math.floor(S/d)),p=t.scrollTop,ge=Math.max(0,p),g=d*Math.ceil(o/a);l===1&&Math.floor(ge/g*o)+u>=o&&(a=u),g!==this.lastScrollHeight&&(this.renderer.setStyle(this.shimElementRef.nativeElement,"height",`${g}px`),this.lastScrollHeight=g),this.dimensionsView={itemCount:o,viewWidth:h,viewHeight:S,childWidth:n,childHeight:d,itemsPerRow:a,itemsPerCol:l,itemsPerRowByCalc:u,scrollHeight:g}}calculateItems(){let t=this.element.nativeElement,e=this.dimensionsView,s=this.items||[],o=this.galleryMode?this.bufferAmount*e.itemsPerRowByCalc:this.bufferAmount,h=t.scrollTop;h>e.scrollHeight&&(h=e.scrollHeight);let f=Math.max(0,h)/e.scrollHeight*e.itemCount/e.itemsPerRow,n=Math.min(e.itemCount,Math.ceil(f)*e.itemsPerRow+e.itemsPerRow*(e.itemsPerCol+1)),d=n,a=n%e.itemsPerRow;a&&(d=n+e.itemsPerRow-a);let u=Math.max(0,d-e.itemsPerCol*e.itemsPerRow-e.itemsPerRow),l=Math.min(u,Math.floor(f)*e.itemsPerRow),p=s==null||s.length===0?0:e.childHeight*Math.ceil(l/e.itemsPerRow)-e.childHeight*Math.min(l,this.bufferAmount);p!==this.lastTopPadding&&(this.renderer.setStyle(this.contentElementRef.nativeElement,"transform",`translateY(${p}px)`),this.renderer.setStyle(this.contentElementRef.nativeElement,"webkitTransform",`translateY(${p}px)`),this.lastTopPadding=p),l=isNaN(l)?-1:l,n=isNaN(n)?-1:n,l-=o,l=Math.max(0,l),n+=o,n=Math.min(s.length,n),l!==this.previousStart||n!==this.previousEnd?(this.ngZone.run(()=>{this.viewPortItems=s.slice(l,n>=0?n:0)}),this.previousStart=l,this.previousEnd=n,this.startupLoop===!0&&this.refresh()):this.startupLoop===!0&&(this.startupLoop=!1,this.refresh(!0))}};i.\u0275fac=function(e){return new(e||i)},i.\u0275cmp=w({type:i,selectors:[["app-virtual-scroll"]],viewQuery:function(e,s){if(e&1&&(v(ye,7,E),v(Se,7,E)),e&2){let o;C(o=y())&&(s.contentElementRef=o.first),C(o=y())&&(s.shimElementRef=o.first)}},inputs:{resizeOffset:"resizeOffset",galleryMode:"galleryMode",selectedChat:"selectedChat",items:"items",childHeight:"childHeight",childWidth:"childWidth",bufferAmount:"bufferAmount"},outputs:{isScrollBottom:"isScrollBottom",isScrollTop:"isScrollTop"},features:[N],ngContentSelectors:be,decls:5,vars:0,consts:[["shim",""],["content",""],[1,"total-padding"],[1,"scrollable-content"]],template:function(e,s){e&1&&(G(),U(0,"div",2,0),J(2,"div",3,1),X(4),Y())},styles:["[_nghost-%COMP%]{display:block;overflow-x:hidden;overflow-y:auto;position:relative;scrollbar-width:thin}.scrollable-content[_ngcontent-%COMP%]{top:0;left:0;width:100%;position:absolute;will-change:transform}.total-padding[_ngcontent-%COMP%]{width:1px;opacity:0}"],changeDetection:0});let r=i;return r})();var je=(()=>{let i=class i{transform(t,e,s){return!t?.length||!e?t:me(e,t,s)}};i.\u0275fac=function(e){return new(e||i)},i.\u0275pipe=$({name:"searchFilter",type:i,pure:!0});let r=i;return r})();var pe=class{constructor(i,m){this.defaultId="default",this.keyStore=`sortBy${i}`,this.sortSettings=m,this._sortParam=this.sort}get sortParam(){return this._sortParam||this.sort}get sort(){let i=localStorage.getItem(this.keyStore);return i?JSON.parse(i):{column:this.defaultId,asc:!1}}set sort(i){this._sortParam=i,localStorage.setItem(this.keyStore,JSON.stringify(i))}sortBy(i,m=!0,t){if(!(i in this.sortSettings))return t;m&&(this.sortParam.asc?(this.sortParam.column=this.defaultId,this.sortParam.asc=!1,i=this.defaultId):this.sortParam.column===i?this.sortParam.asc=!this.sortParam.asc:(this.sortParam.column=i,this.sortParam.asc=!1),this.sort=this.sortParam);for(let e of this.sortSettings[i])de(e.type,t,e.prop,i===this.defaultId?!1:this.sortParam.asc);return[...t]}};export{De as a,Qe as b,je as c,pe as d};