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) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 12.3 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={innerWidth(e){let t=e.offsetWidth,l=getComputedStyle(e);return t+=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),t},width(e){let t=e.offsetWidth,l=getComputedStyle(e);return t-=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight),t},getWindowScrollTop(){let e=document.documentElement;return(window.pageYOffset||e.scrollTop)-(e.clientTop||0)},getWindowScrollLeft(){let e=document.documentElement;return(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)},getOuterWidth(e,t){if(e){let l=e.offsetWidth;if(t){let t=getComputedStyle(e);l+=parseFloat(t.marginLeft)+parseFloat(t.marginRight)}return l}return 0},getOuterHeight(e,t){if(e){let l=e.offsetHeight;if(t){let t=getComputedStyle(e);l+=parseFloat(t.marginTop)+parseFloat(t.marginBottom)}return l}return 0},getClientHeight(e,t){if(e){let l=e.clientHeight;if(t){let t=getComputedStyle(e);l+=parseFloat(t.marginTop)+parseFloat(t.marginBottom)}return l}return 0},getViewport(){let e=window,t=document,l=t.documentElement,n=t.getElementsByTagName("body")[0];return{width:e.innerWidth||l.clientWidth||n.clientWidth,height:e.innerHeight||l.clientHeight||n.clientHeight}},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)}},index(e){let t=e.parentNode.childNodes,l=0;for(var n=0;n<t.length;n++){if(t[n]===e)return l;1===t[n].nodeType&&l++}return-1},addMultipleClasses(e,t){if(e.classList){let l=t.split(" ");for(let t=0;t<l.length;t++)e.classList.add(l[t])}else{let l=t.split(" ");for(let t=0;t<l.length;t++)e.className+=" "+l[t]}},addClass(e,t){e.classList?e.classList.add(t):e.className+=" "+t},removeClass(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")},hasClass:(e,t)=>!!e&&(e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)),find:(e,t)=>e.querySelectorAll(t),findSingle:(e,t)=>e.querySelector(t),getHeight(e){let t=e.offsetHeight,l=getComputedStyle(e);return t-=parseFloat(l.paddingTop)+parseFloat(l.paddingBottom)+parseFloat(l.borderTopWidth)+parseFloat(l.borderBottomWidth),t},getWidth(e){let t=e.offsetWidth,l=getComputedStyle(e);return t-=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight)+parseFloat(l.borderLeftWidth)+parseFloat(l.borderRightWidth),t},absolutePosition(e,t){let l,n,i=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e),r=i.height,o=i.width,s=t.offsetHeight,a=t.offsetWidth,d=t.getBoundingClientRect(),p=this.getWindowScrollTop(),c=this.getWindowScrollLeft(),h=this.getViewport();d.top+s+r>h.height?(l=d.top+p-r,e.style.transformOrigin="bottom",l<0&&(l=p)):(l=s+d.top+p,e.style.transformOrigin="top"),n=d.left+o>h.width?Math.max(0,d.left+c+a-o):d.left+c,e.style.top=l+"px",e.style.left=n+"px"},relativePosition(e,t){let l=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e);const n=t.offsetHeight,i=t.getBoundingClientRect(),r=this.getViewport();let o,s;i.top+n+l.height>r.height?(o=-1*l.height,e.style.transformOrigin="bottom",i.top+o<0&&(o=-1*i.top)):(o=n,e.style.transformOrigin="top"),s=l.width>r.width?-1*i.left:i.left+l.width>r.width?-1*(i.left+l.width-r.width):0,e.style.top=o+"px",e.style.left=s+"px"},getParents(e,t=[]){return null===e.parentNode?t:this.getParents(e.parentNode,t.concat([e.parentNode]))},getScrollableParents(e){let t=[];if(e){let l=this.getParents(e);const n=/(auto|scroll)/,i=e=>{let t=window.getComputedStyle(e,null);return n.test(t.getPropertyValue("overflow"))||n.test(t.getPropertyValue("overflowX"))||n.test(t.getPropertyValue("overflowY"))};for(let e of l){let l=1===e.nodeType&&e.dataset.scrollselectors;if(l){let n=l.split(",");for(let l of n){let n=this.findSingle(e,l);n&&i(n)&&t.push(n)}}9!==e.nodeType&&i(e)&&t.push(e)}}return t},getHiddenElementOuterHeight(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetHeight;return e.style.display="none",e.style.visibility="visible",t},getHiddenElementOuterWidth(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetWidth;return e.style.display="none",e.style.visibility="visible",t},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},fadeIn(e,t){e.style.opacity=0;var l=+new Date,n=0,i=function(){n=+e.style.opacity+((new Date).getTime()-l)/t,e.style.opacity=n,l=+new Date,+n<1&&(window.requestAnimationFrame&&requestAnimationFrame(i)||setTimeout(i,16))};i()},fadeOut(e,t){var l=1,n=50/t;let i=setInterval((()=>{(l-=n)<=0&&(l=0,clearInterval(i)),e.style.opacity=l}),50)},getUserAgent:()=>navigator.userAgent,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)}},scrollInView(e,t){let l=getComputedStyle(e).getPropertyValue("borderTopWidth"),n=l?parseFloat(l):0,i=getComputedStyle(e).getPropertyValue("paddingTop"),r=i?parseFloat(i):0,o=e.getBoundingClientRect(),s=t.getBoundingClientRect().top+document.body.scrollTop-(o.top+document.body.scrollTop)-n-r,a=e.scrollTop,d=e.clientHeight,p=this.getOuterHeight(t);s<0?e.scrollTop=a+s:s+p>d&&(e.scrollTop=a+s-d+p)},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){}},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},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},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"}},isVisible:e=>null!=e.offsetParent,invokeElementMethod(e,t,l){e[t].apply(e,l)},getFocusableElements(e){let t=this.find(e,'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 t)"none"!=getComputedStyle(e).display&&"hidden"!=getComputedStyle(e).visibility&&l.push(e);return l},getFirstFocusableElement(e){const t=this.getFocusableElements(e);return t.length>0?t[0]:null},isClickable(e){const t=e.nodeName,l=e.parentElement&&e.parentElement.nodeName;return"INPUT"==t||"BUTTON"==t||"A"==t||"INPUT"==l||"BUTTON"==l||"A"==l||this.hasClass(e,"p-button")||this.hasClass(e.parentElement,"p-button")||this.hasClass(e.parentElement,"p-checkbox")||this.hasClass(e.parentElement,"p-radiobutton")},applyStyle(e,t){if("string"==typeof t)e.style.cssText=this.style;else for(let l in this.style)e.style[l]=t[l]},isIOS:()=>/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,isAndroid:()=>/(android)/i.test(navigator.userAgent),isTouchDevice:()=>"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0};var t={equals(e,t,l){return l?this.resolveFieldData(e,l)===this.resolveFieldData(t,l):this.deepEquals(e,t)},deepEquals(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){var l,n,i,r=Array.isArray(e),o=Array.isArray(t);if(r&&o){if((n=e.length)!=t.length)return!1;for(l=n;0!=l--;)if(!this.deepEquals(e[l],t[l]))return!1;return!0}if(r!=o)return!1;var s=e instanceof Date,a=t instanceof Date;if(s!=a)return!1;if(s&&a)return e.getTime()==t.getTime();var d=e instanceof RegExp,p=t instanceof RegExp;if(d!=p)return!1;if(d&&p)return e.toString()==t.toString();var c=Object.keys(e);if((n=c.length)!==Object.keys(t).length)return!1;for(l=n;0!=l--;)if(!Object.prototype.hasOwnProperty.call(t,c[l]))return!1;for(l=n;0!=l--;)if(i=c[l],!this.deepEquals(e[i],t[i]))return!1;return!0}return e!=e&&t!=t},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 i=t.split("."),r=e;for(var l=0,n=i.length;l<n;++l){if(null==r)return null;r=r[i[l]]}return r}}return null},isFunction:e=>!!(e&&e.constructor&&e.call&&e.apply),filter(e,t,l){var n=[];if(e)for(let i of e)for(let e of t)if(String(this.resolveFieldData(i,e)).toLowerCase().indexOf(l.toLowerCase())>-1){n.push(i);break}return n},reorderArray(e,t,l){let n;if(e&&t!==l){if(l>=e.length)for(n=l-e.length;1+n--;)e.push(void 0);e.splice(l,0,e.splice(t,1)[0])}},findIndexInList(e,t){let l=-1;if(t)for(let n=0;n<t.length;n++)if(t[n]===e){l=n;break}return l},contains(e,t){if(null!=e&&t&&t.length)for(let l of t)if(this.equals(e,l))return!0;return!1},insertIntoOrderedArray(e,t,l,n){if(l.length>0){let i=!1;for(let r=0;r<l.length;r++){if(this.findIndexInList(l[r],n)>t){l.splice(r,0,e),i=!0;break}}i||l.push(e)}else l.push(e)},removeAccents:e=>(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),getVNodeProp(e,t){let l=e.props;if(l){let n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=Object.prototype.hasOwnProperty.call(l,n)?n:t;return e.type.props[t].type===Boolean&&""===l[i]||l[i]}return null}};var l=function(){let e=[];const t=e=>e&&parseInt(e.style.zIndex,10)||0;return{get:t,set:(t,l,n)=>{l&&(l.style.zIndex=String(((t,l)=>{let n=e.length>0?e[e.length-1]:{key:t,value:l},i=n.value+(n.key===t?0:l)+1;return e.push({key:t,value:i}),i})(t,n)))},clear:l=>{var n;l&&(n=t(l),e=e.filter((e=>e.value!==n)),l.style.zIndex="")},getCurrent:()=>e.length>0?e[e.length-1].value:0}}(),n=0;exports.ConnectedOverlayScrollHandler=class{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}},exports.DomHandler=e,exports.EventBus=function(){const e=new Map;return{on(t,l){let n=e.get(t);n?n.push(l):n=[l],e.set(t,n)},off(t,l){let n=e.get(t);n&&n.splice(n.indexOf(l)>>>0,1)},emit(t,l){let n=e.get(t);n&&n.slice().map((e=>{e(l)}))}}},exports.ObjectUtils=t,exports.UniqueComponentId=function(e="pv_id_"){return`${e}${++n}`},exports.ZIndexUtils=l;