UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue)

2 lines (1 loc) 13.3 kB
class e{static innerWidth(e){let t=e.offsetWidth,i=getComputedStyle(e);return t+=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),t}static width(e){let t=e.offsetWidth,i=getComputedStyle(e);return t-=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),t}static getWindowScrollTop(){let e=document.documentElement;return(window.pageYOffset||e.scrollTop)-(e.clientTop||0)}static getWindowScrollLeft(){let e=document.documentElement;return(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}static getOuterWidth(e,t){if(e){let i=e.offsetWidth;if(t){let t=getComputedStyle(e);i+=parseFloat(t.marginLeft)+parseFloat(t.marginRight)}return i}return 0}static getOuterHeight(e,t){if(e){let i=e.offsetHeight;if(t){let t=getComputedStyle(e);i+=parseFloat(t.marginTop)+parseFloat(t.marginBottom)}return i}return 0}static getClientHeight(e,t){if(e){let i=e.clientHeight;if(t){let t=getComputedStyle(e);i+=parseFloat(t.marginTop)+parseFloat(t.marginBottom)}return i}return 0}static getViewport(){let e=window,t=document,i=t.documentElement,l=t.getElementsByTagName("body")[0];return{width:e.innerWidth||i.clientWidth||l.clientWidth,height:e.innerHeight||i.clientHeight||l.clientHeight}}static getOffset(e){var t=e.getBoundingClientRect();return{top:t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:t.left+(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0)}}static generateZIndex(){return this.zindex=this.zindex||999,++this.zindex}static getCurrentZIndex(){return this.zindex}static index(e){let t=e.parentNode.childNodes,i=0;for(var l=0;l<t.length;l++){if(t[l]===e)return i;1===t[l].nodeType&&i++}return-1}static addMultipleClasses(e,t){if(e.classList){let i=t.split(" ");for(let t=0;t<i.length;t++)e.classList.add(i[t])}else{let i=t.split(" ");for(let t=0;t<i.length;t++)e.className+=" "+i[t]}}static addClass(e,t){e.classList?e.classList.add(t):e.className+=" "+t}static removeClass(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}static hasClass(e,t){return!!e&&(e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className))}static find(e,t){return e.querySelectorAll(t)}static findSingle(e,t){return e.querySelector(t)}static getHeight(e){let t=e.offsetHeight,i=getComputedStyle(e);return t-=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom)+parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),t}static getWidth(e){let t=e.offsetWidth,i=getComputedStyle(e);return t-=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight)+parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth),t}static absolutePosition(e,t){let i,l,n=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e),r=n.height,s=n.width,o=t.offsetHeight,a=t.offsetWidth,c=t.getBoundingClientRect(),d=this.getWindowScrollTop(),g=this.getWindowScrollLeft(),u=this.getViewport();c.top+o+r>u.height?(i=c.top+d-r,e.style.transformOrigin="bottom",i<0&&(i=d)):(i=o+c.top+d,e.style.transformOrigin="top"),l=c.left+s>u.width?Math.max(0,c.left+g+a-s):c.left+g,e.style.top=i+"px",e.style.left=l+"px"}static relativePosition(e,t){let i=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e);const l=t.offsetHeight,n=t.getBoundingClientRect(),r=this.getViewport();let s,o;n.top+l+i.height>r.height?(s=-1*i.height,e.style.transformOrigin="bottom",n.top+s<0&&(s=-1*n.top)):(s=l,e.style.transformOrigin="top"),o=i.width>r.width?-1*n.left:n.left+i.width>r.width?-1*(n.left+i.width-r.width):0,e.style.top=s+"px",e.style.left=o+"px"}static getParents(e,t=[]){return null===e.parentNode?t:this.getParents(e.parentNode,t.concat([e.parentNode]))}static getScrollableParents(e){let t=[];if(e){let i=this.getParents(e);const l=/(auto|scroll)/,n=e=>{let t=window.getComputedStyle(e,null);return l.test(t.getPropertyValue("overflow"))||l.test(t.getPropertyValue("overflowX"))||l.test(t.getPropertyValue("overflowY"))};for(let e of i){let i=1===e.nodeType&&e.dataset.scrollselectors;if(i){let l=i.split(",");for(let i of l){let l=this.findSingle(e,i);l&&n(l)&&t.push(l)}}}}return t}static getHiddenElementOuterHeight(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetHeight;return e.style.display="none",e.style.visibility="visible",t}static getHiddenElementOuterWidth(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetWidth;return e.style.display="none",e.style.visibility="visible",t}static getHiddenElementDimensions(e){var t={};return e.style.visibility="hidden",e.style.display="block",t.width=e.offsetWidth,t.height=e.offsetHeight,e.style.display="none",e.style.visibility="visible",t}static fadeIn(e,t){e.style.opacity=0;var i=+new Date,l=0,n=function(){l=+e.style.opacity+((new Date).getTime()-i)/t,e.style.opacity=l,i=+new Date,+l<1&&(window.requestAnimationFrame&&requestAnimationFrame(n)||setTimeout(n,16))};n()}static fadeOut(e,t){var i=1,l=50/t;let n=setInterval((()=>{(i-=l)<=0&&(i=0,clearInterval(n)),e.style.opacity=i}),50)}static getUserAgent(){return navigator.userAgent}static appendChild(e,t){if(this.isElement(t))t.appendChild(e);else{if(!t.el||!t.elElement)throw new Error("Cannot append "+t+" to "+e);t.elElement.appendChild(e)}}static scrollInView(e,t){let i=getComputedStyle(e).getPropertyValue("borderTopWidth"),l=i?parseFloat(i):0,n=getComputedStyle(e).getPropertyValue("paddingTop"),r=n?parseFloat(n):0,s=e.getBoundingClientRect(),o=t.getBoundingClientRect().top+document.body.scrollTop-(s.top+document.body.scrollTop)-l-r,a=e.scrollTop,c=e.clientHeight,d=this.getOuterHeight(t);o<0?e.scrollTop=a+o:o+d>c&&(e.scrollTop=a+o-c+d)}static clearSelection(){if(window.getSelection)window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().rangeCount>0&&window.getSelection().getRangeAt(0).getClientRects().length>0&&window.getSelection().removeAllRanges();else if(document.selection&&document.selection.empty)try{document.selection.empty()}catch(e){}}static calculateScrollbarWidth(){if(null!=this.calculatedScrollbarWidth)return this.calculatedScrollbarWidth;let e=document.createElement("div");e.className="p-scrollbar-measure",document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),this.calculatedScrollbarWidth=t,t}static getBrowser(){if(!this.browser){let e=this.resolveUserAgent();this.browser={},e.browser&&(this.browser[e.browser]=!0,this.browser.version=e.version),this.browser.chrome?this.browser.webkit=!0:this.browser.webkit&&(this.browser.safari=!0)}return this.browser}static resolveUserAgent(){let e=navigator.userAgent.toLowerCase(),t=/(chrome)[ ]([\w.]+)/.exec(e)||/(webkit)[ ]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ ]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}}static isVisible(e){return null!=e.offsetParent}static invokeElementMethod(e,t,i){e[t].apply(e,i)}static getFocusableElements(t){let i=e.find(t,'button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),\n [href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),\n input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),\n textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),\n [contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])'),l=[];for(let e of i)"none"!=getComputedStyle(e).display&&"hidden"!=getComputedStyle(e).visibility&&l.push(e);return l}static isClickable(e){const t=e.nodeName,i=e.parentElement&&e.parentElement.nodeName;return"INPUT"==t||"BUTTON"==t||"A"==t||"INPUT"==i||"BUTTON"==i||"A"==i||this.hasClass(e,"p-button")||this.hasClass(e.parentElement,"p-button")||this.hasClass(e.parentElement,"p-checkbox")||this.hasClass(e.parentElement,"p-radiobutton")}}class t{constructor(e,t=(()=>{})){this.element=e,this.listener=t}bindScrollListener(){this.scrollableParents=e.getScrollableParents(this.element);for(let e=0;e<this.scrollableParents.length;e++)this.scrollableParents[e].addEventListener("scroll",this.listener)}unbindScrollListener(){if(this.scrollableParents)for(let e=0;e<this.scrollableParents.length;e++)this.scrollableParents[e].removeEventListener("scroll",this.listener)}destroy(){this.unbindScrollListener(),this.element=null,this.listener=null,this.scrollableParents=null}}class i{static equals(e,t,i){return i?this.resolveFieldData(e,i)===this.resolveFieldData(t,i):this.deepEquals(e,t)}static deepEquals(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){var i,l,n,r=Array.isArray(e),s=Array.isArray(t);if(r&&s){if((l=e.length)!=t.length)return!1;for(i=l;0!=i--;)if(!this.deepEquals(e[i],t[i]))return!1;return!0}if(r!=s)return!1;var o=e instanceof Date,a=t instanceof Date;if(o!=a)return!1;if(o&&a)return e.getTime()==t.getTime();var c=e instanceof RegExp,d=t instanceof RegExp;if(c!=d)return!1;if(c&&d)return e.toString()==t.toString();var g=Object.keys(e);if((l=g.length)!==Object.keys(t).length)return!1;for(i=l;0!=i--;)if(!Object.prototype.hasOwnProperty.call(t,g[i]))return!1;for(i=l;0!=i--;)if(n=g[i],!this.deepEquals(e[n],t[n]))return!1;return!0}return e!=e&&t!=t}static resolveFieldData(e,t){if(e&&Object.keys(e).length&&t){if(this.isFunction(t))return t(e);if(-1===t.indexOf("."))return e[t];{let n=t.split("."),r=e;for(var i=0,l=n.length;i<l;++i){if(null==r)return null;r=r[n[i]]}return r}}return null}static isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)}static filter(e,t,i){var l=[];if(e)for(let n of e)for(let e of t)if(String(this.resolveFieldData(n,e)).toLowerCase().indexOf(i.toLowerCase())>-1){l.push(n);break}return l}static reorderArray(e,t,i){let l;if(e&&t!==i){if(i>=e.length)for(l=i-e.length;1+l--;)e.push(void 0);e.splice(i,0,e.splice(t,1)[0])}}static findIndexInList(e,t){let i=-1;if(t)for(let l=0;l<t.length;l++)if(t[l]===e){i=l;break}return i}static contains(e,t){if(null!=e&&t&&t.length)for(let i of t)if(this.equals(e,i))return!0;return!1}static insertIntoOrderedArray(e,t,i,l){if(i.length>0){let n=!1;for(let r=0;r<i.length;r++){if(this.findIndexInList(i[r],l)>t){i.splice(r,0,e),n=!0;break}}n||i.push(e)}else i.push(e)}static removeAccents(e){return e&&e.search(/[\xC0-\xFF]/g)>-1&&(e=e.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),e}}class l{static startsWith(e,t,l){if(null==t||""===t.trim())return!0;if(null==e)return!1;let n=i.removeAccents(t.toString()).toLocaleLowerCase(l);return i.removeAccents(e.toString()).toLocaleLowerCase(l).slice(0,n.length)===n}static contains(e,t,l){if(null==t||"string"==typeof t&&""===t.trim())return!0;if(null==e)return!1;let n=i.removeAccents(t.toString()).toLocaleLowerCase(l);return-1!==i.removeAccents(e.toString()).toLocaleLowerCase(l).indexOf(n)}static endsWith(e,t,l){if(null==t||""===t.trim())return!0;if(null==e)return!1;let n=i.removeAccents(t.toString()).toLocaleLowerCase(l),r=i.removeAccents(e.toString()).toLocaleLowerCase(l);return-1!==r.indexOf(n,r.length-n.length)}static equals(e,t,l){return null==t||"string"==typeof t&&""===t.trim()||null!=e&&(e.getTime&&t.getTime?e.getTime()===t.getTime():i.removeAccents(e.toString()).toLocaleLowerCase(l)===i.removeAccents(t.toString()).toLocaleLowerCase(l))}static notEquals(e,t,l){return null!=t&&("string"!=typeof t||""!==t.trim())&&(null==e||(e.getTime&&t.getTime?e.getTime()!==t.getTime():i.removeAccents(e.toString()).toLocaleLowerCase(l)!==i.removeAccents(t.toString()).toLocaleLowerCase(l)))}static in(e,t){if(null==t||0===t.length)return!0;if(null==e)return!1;for(let l=0;l<t.length;l++)if(i.equals(e,t[l]))return!0;return!1}static lt(e,t){return!!(null==t||t.trim&&0===t.trim().length)||null!=e&&(e.getTime&&t.getTime?e.getTime()<t.getTime():e<parseFloat(t))}static lte(e,t){return!!(null==t||t.trim&&0===t.trim().length)||null!=e&&(e.getTime&&t.getTime?e.getTime()<=t.getTime():e<=parseFloat(t))}static gt(e,t){return!!(null==t||t.trim&&0===t.trim().length)||null!=e&&(e.getTime&&t.getTime?e.getTime()>t.getTime():e>parseFloat(t))}static gte(e,t){return!!(null==t||t.trim&&0===t.trim().length)||null!=e&&(e.getTime&&t.getTime?e.getTime()>=t.getTime():e>=parseFloat(t))}}var n=0;function r(e="pv_id_"){return`${e}${++n}`}export{t as ConnectedOverlayScrollHandler,e as DomHandler,l as FilterUtils,i as ObjectUtils,r as UniqueComponentId};