claude-web/node_modules/@primeuix/utils/dist/dom/index.mjs

14 lines
18 KiB
JavaScript
Raw Normal View History

2026-02-23 02:23:38 +00:00
function R(t,e){return t?t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className):!1}function W(t,e){if(t&&e){let o=n=>{R(t,n)||(t.classList?t.classList.add(n):t.className+=" "+n)};[e].flat().filter(Boolean).forEach(n=>n.split(" ").forEach(o))}}function F(){return window.innerWidth-document.documentElement.offsetWidth}function st(t){typeof t=="string"?W(document.body,t||"p-overflow-hidden"):(t!=null&&t.variableName&&document.body.style.setProperty(t.variableName,F()+"px"),W(document.body,(t==null?void 0:t.className)||"p-overflow-hidden"))}function B(t){if(t){let e=document.createElement("a");if(e.download!==void 0){let{name:o,src:n}=t;return e.setAttribute("href",n),e.setAttribute("download",o),e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e),!0}}return!1}function at(t,e){let o=new Blob([t],{type:"application/csv;charset=utf-8;"});window.navigator.msSaveOrOpenBlob?navigator.msSaveOrOpenBlob(o,e+".csv"):B({name:e+".csv",src:URL.createObjectURL(o)})||(t="data:text/csv;charset=utf-8,"+t,window.open(encodeURI(t)))}function P(t,e){if(t&&e){let o=n=>{t.classList?t.classList.remove(n):t.className=t.className.replace(new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi")," ")};[e].flat().filter(Boolean).forEach(n=>n.split(" ").forEach(o))}}function dt(t){typeof t=="string"?P(document.body,t||"p-overflow-hidden"):(t!=null&&t.variableName&&document.body.style.removeProperty(t.variableName),P(document.body,(t==null?void 0:t.className)||"p-overflow-hidden"))}function x(t){for(let e of document==null?void 0:document.styleSheets)try{for(let o of e==null?void 0:e.cssRules)for(let n of o==null?void 0:o.style)if(t.test(n))return{name:n,value:o.style.getPropertyValue(n).trim()}}catch(o){}return null}function w(t){let e={width:0,height:0};if(t){let[o,n]=[t.style.visibility,t.style.display],r=t.getBoundingClientRect();t.style.visibility="hidden",t.style.display="block",e.width=r.width||t.offsetWidth,e.height=r.height||t.offsetHeight,t.style.display=n,t.style.visibility=o}return e}function h(){let t=window,e=document,o=e.documentElement,n=e.getElementsByTagName("body")[0],r=t.innerWidth||o.clientWidth||n.clientWidth,i=t.innerHeight||o.clientHeight||n.clientHeight;return{width:r,height:i}}function E(t){return t?Math.abs(t.scrollLeft):0}function k(){let t=document.documentElement;return(window.pageXOffset||E(t))-(t.clientLeft||0)}function $(){let t=document.documentElement;return(window.pageYOffset||t.scrollTop)-(t.clientTop||0)}function V(t){return t?getComputedStyle(t).direction==="rtl":!1}function D(t,e,o=!0){var n,r,i,l;if(t){let d=t.offsetParent?{width:t.offsetWidth,height:t.offsetHeight}:w(t),s=d.height,a=d.width,u=e.offsetHeight,p=e.offsetWidth,f=e.getBoundingClientRect(),g=$(),it=k(),lt=h(),L,N,ot="top";f.top+u+s>lt.height?(L=f.top+g-s,ot="bottom",L<0&&(L=g)):L=u+f.top+g,f.left+a>lt.width?N=Math.max(0,f.left+it+p-a):N=f.left+it,V(t)?t.style.insetInlineEnd=N+"px":t.style.insetInlineStart=N+"px",t.style.top=L+"px",t.style.transformOrigin=ot,o&&(t.style.marginTop=ot==="bottom"?`calc(${(r=(n=x(/-anchor-gutter$/))==null?void 0:n.value)!=null?r:"2px"} * -1)`:(l=(i=x(/-anchor-gutter$/))==null?void 0:i.value)!=null?l:"")}}function S(t,e){t&&(typeof e=="string"?t.style.cssText=e:Object.entries(e||{}).forEach(([o,n])=>t.style[o]=n))}function v(t,e){if(t instanceof HTMLElement){let o=t.offsetWidth;if(e){let n=getComputedStyle(t);o+=parseFloat(n.marginLeft)+parseFloat(n.marginRight)}return o}return 0}function I(t,e,o=!0,n=void 0){var r;if(t){let i=t.offsetParent?{width:t.offsetWidth,height:t.offsetHeight}:w(t),l=e.offsetHeight,d=e.getBoundingClientRect(),s=h(),a,u,p=n!=null?n:"top";if(!n&&d.top+l+i.height>s.height?(a=-1*i.height,p="bottom",d.top+a<0&&(a=-1*d.top)):a=l,i.width>s.width?u=d.left*-1:d.left+i.width>s.width?u=(d.left+i.width-s.width)*-1:u=0,t.style.top=a+"px",t.style.insetInlineStart=u+"px",t.style.transformOrigin=p,o){let f=(r=x(/-anchor-gutter$/))==null?void 0:r.value;t.style.marginTop=p==="bottom"?`calc(${f!=null?f:"2px"} * -1)`:f!=null?f:""}}}function ft
[href]:not([tabindex = "-1"]):not([style*="display:none"]):not([hidden])${e},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e}`),n=[];for(let r of o)getComputedStyle(r).display!="none"&&getComputedStyle(r).visibility!="hidden"&&n.push(r);return n}function vt(t,e){let o=b(t,e);return o.length>0?o[0]:null}function Tt(t){if(t){let e=t.offsetHeight,o=getComputedStyle(t);return e-=parseFloat(o.paddingTop)+parseFloat(o.paddingBottom)+parseFloat(o.borderTopWidth)+parseFloat(o.borderBottomWidth),e}return 0}function G(t){if(t){let[e,o]=[t.style.visibility,t.style.display];t.style.visibility="hidden",t.style.display="block";let n=t.offsetHeight;return t.style.display=o,t.style.visibility=e,n}return 0}function J(t){if(t){let[e,o]=[t.style.visibility,t.style.display];t.style.visibility="hidden",t.style.display="block";let n=t.offsetWidth;return t.style.display=o,t.style.visibility=e,n}return 0}function Ht(t){var e;if(t){let o=(e=y(t))==null?void 0:e.childNodes,n=0;if(o)for(let r=0;r<o.length;r++){if(o[r]===t)return n;o[r].nodeType===1&&n++}}return-1}function Ct(t){if(t){let e=t.offsetWidth,o=getComputedStyle(t);return e-=parseFloat(o.borderLeft)+parseFloat(o.borderRight),e}return 0}function Lt(t,e){let o=b(t,e);return o.length>0?o[o.length-1]:null}function Wt(t,e){let o=t.nextElementSibling;for(;o;){if(o.matches(e))return o;o=o.nextElementSibling}return null}function Pt(t,e,o){let n=b(t,o),r=n.length>0?n.findIndex(l=>l===e):-1,i=r>-1&&n.length>=r+1?r+1:-1;return i>-1?n[i]:null}function K(t){if(t){let e=t.getBoundingClientRect();return{top:e.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:e.left+(window.pageXOffset||E(document.documentElement)||E(document.body)||0)}}return{top:"auto",left:"auto"}}function C(t,e){if(t){let o=t.offsetHeight;if(e){let n=getComputedStyle(t);o+=parseFloat(n.marginTop)+parseFloat(n.marginBottom)}return o}return 0}function M(t,e=[]){let o=y(t);return o===null?e:M(o,e.concat([o]))}function Ot(t,e){let o=t.previousElementSibling;for(;o;){if(o.matches(e))return o;o=o.previousElementSibling}return null}function At(t){let e=[];if(t){let o=M(t),n=/(auto|scroll)/,r=i=>{try{let l=window.getComputedStyle(i,null);return n.test(l.getPropertyValue("overflow"))||n.test(l.getPropertyValue("overflowX"))||n.test(l.getPropertyValue("overflowY"))}catch(l){return!1}};for(let i of o){let l=i.nodeType===1&&i.dataset.scrollselectors;if(l){let d=l.split(",");for(let s of d){let a=z(i,s);a&&r(a)&&e.push(a)}}i.nodeType!==9&&r(i)&&e.push(i)}}return e}function Mt(){if(window.getSelection)return window.getSelection().toString();if(document.getSelection)return document.getSelection().toString()}function Nt(){return navigator.userAgent}function Rt(t){if(t){let e=t.offsetWidth,o=getComputedStyle(t);return e-=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight)+parseFloat(o.borderLeftWidth)+parseFloat(o.borderRightWidth),e}return 0}function Ft(t){if(t){let e=getComputedStyle(t);return parseFloat(e.getPropertyValue("animation-duration")||"0")>0}return!1}function Bt(t){if(t){let e=getComputedStyle(t);return parseFloat(e.getPropertyValue("transition-duration")||"0")>0}return!1}function kt(t,e,o){let n=t[e];typeof n=="function"&&n.apply(t,o!=null?o:[])}function $t(){return/(android)/i.test(navigator.userAgent)}function _(t,e,o){return c(t)?Q(t,e)===o:!1}function Vt(t,e,o){return!_(t,e,o)}function Dt(t){if(t){let e=t.nodeName,o=t.parentElement&&t.parentElement.nodeName;return e==="INPUT"||e==="TEXTAREA"||e==="BUTTON"||e==="A"||o==="INPUT"||o==="TEXTAREA"||o==="BUTTON"||o==="A"||!!t.closest(".p-button, .p-checkbox, .p-radiobutton")}return!1}function tt(){return!!(typeof window!="undefined"&&window.document&&window.document.createElement)}function It(t,e=""){return c(t)?t.matches(`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${e}`):!1}function et(t){return!!(t&&t.offsetParent!=null)}function jt(t){return!et(t)}function Ut(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window)}function qt(){return typeof window=="undefined"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Xt(){return!tt()}function Yt(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function zt(t,e){var o,n;if(t){let r=t.parentElement,i=K(r),l=h(),d=t.offsetParent?t.offsetWidth:J(t),s=t.offsetParent?t.offsetHeight:G(t),a=v((o=r==null?void 0:r.children)==null?void 0:o[0]),u=C((n=r==null?void 0:r.children)==null?void 0:n[0]),p="",f="";i.left+a+d>l.width-O()?i.left<d?e%2===1?p=i.left?"-"+i.left+"px":"100%":e%2===0&&(p=l.width-d-O()+"px"):p="-100%":p="100%",t.getBoundingClientRect().top+u+s>l.height?f=`-${s-u}px`:f="0px",t.style.top=f,t.style.insetInlineStart=p}}function Qt(){return new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(t)})})}function Zt(t){var e;t&&("remove"in Element.prototype?t.remove():(e=t.parentNode)==null||e.removeChild(t))}function Gt(t,e){let o=H(t);if(o)o.removeChild(e);else throw new Error("Cannot remove "+e+" from "+t)}function Jt(t){var e;if(T(t)){try{(e=t.parentNode)==null||e.removeChild(t)}catch(o){}return null}return t}function Kt(t,e){let o=getComputedStyle(t).getPropertyValue("borderTopWidth"),n=o?parseFloat(o):0,r=getComputedStyle(t).getPropertyValue("paddingTop"),i=r?parseFloat(r):0,l=t.getBoundingClientRect(),s=e.getBoundingClientRect().top+document.body.scrollTop-(l.top+document.body.scrollTop)-n-i,a=t.scrollTop,u=t.clientHeight,p=C(e);s<0?t.scrollTop=a+s:s+p>u&&(t.scrollTop=a+s-u+p)}function _t(t,e="",o){c(t)&&o!==null&&o!==void 0&&t.setAttribute(e,o)}function te(t,e,o=null,n){var r;e&&((r=t==null?void 0:t.style)==null||r.setProperty(e,o,n))}export{D as absolutePosition,W as addClass,S as addStyle,ft as alignOverlay,ut as appendChild,st as blockBodyScroll,F as calculateBodyScrollbarWidth,ct as calculateScrollbarHeight,O as calculateScrollbarWidth,pt as clearSelection,U as createElement,mt as createStyleAsString,X as createStyleElement,q as createStyleMarkup,gt as createStyleTag,at as exportCSV,ht as fadeIn,yt as fadeOut,Y as find,z as findSingle,bt as focus,Q as getAttribute,xt as getBrowser,Et as getBrowserLanguage,wt as getCSSProperty,x as getCSSVariableByRegex,St as getCursorOffset,vt as getFirstFocusableElement,b as getFocusableElements,Tt as getHeight,w as getHiddenElementDimensions,G as getHiddenElementOuterHeight,J as getHiddenElementOuterWidth,Ht as getIndex,Ct as getInnerWidth,Lt as getLastFocusableElement,Wt as getNextElementSibling,Pt as getNextFocusableElement,K as getOffset,C as getOuterHeight,v as getOuterWidth,y as getParentNode,M as getParents,Ot as getPreviousElementSibling,E as getScrollLeft,At as getScrollableParents,Mt as getSelection,j as getTargetElement,Nt as getUserAgent,h as getViewport,Rt as getWidth,k as getWindowScrollLeft,$ as getWindowScrollTop,Ft as hasCSSAnimation,Bt as hasCSSTransition,R as hasClass,kt as invokeElementMethod,$t as isAndroid,_ as isAttributeEquals,Vt as isAttributeNotEquals,Dt as isClickable,tt as isClient,c as isElement,T as isExist,It as isFocusableElement,jt as isHidden,Ut as isIOS,qt as isPrefersReducedMotion,V as isRTL,Xt as isServer,Yt as isTouchDevice,et as isVisible,zt as nestedPosition,Qt as nextFrame,I as relativePosition,Zt as remove,Gt as removeChild,P as removeClass,Jt as removeStyleTag,Z as resolveUserAgent,B as saveAs,Kt as scrollInView,_t as setAttribute,A as setAttributes,te as setCSSProperty,H as toElement,dt as unblockBodyScroll};
//# sourceMappingURL=index.mjs.map