mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 16:35:14 +00:00
3 lines
8.7 KiB
JavaScript
3 lines
8.7 KiB
JavaScript
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),o=t(e),n=t(require("react-dom"));function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}var i="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,a={popupContent:{tooltip:{position:"absolute",zIndex:999},modal:{position:"relative",margin:"auto"}},popupArrow:{height:"8px",width:"16px",position:"absolute",background:"transparent",color:"#FFF",zIndex:-1},overlay:{tooltip:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",zIndex:999},modal:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"flex",zIndex:999}}},u=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],l=function(t,e,o,n,r){var i=r.offsetX,a=r.offsetY,u=n?8:0,l=o.split(" "),c=e.height,f=e.width,s=t.top+t.height/2-c/2,d=t.left+t.width/2-f/2,p="",v="0%",m="0%";switch(l[0]){case"top":s-=c/2+t.height/2+u,p="rotate(180deg) translateX(50%)",v="100%",m="50%";break;case"bottom":s+=c/2+t.height/2+u,p="rotate(0deg) translateY(-100%) translateX(-50%)",m="50%";break;case"left":d-=f/2+t.width/2+u,p=" rotate(90deg) translateY(50%) translateX(-25%)",m="100%",v="50%";break;case"right":d+=f/2+t.width/2+u,p="rotate(-90deg) translateY(-150%) translateX(25%)",v="50%"}switch(l[1]){case"top":s=t.top,v=t.height/2+"px";break;case"bottom":s=t.top-c+t.height,v=c-t.height/2+"px";break;case"left":d=t.left,m=t.width/2+"px";break;case"right":d=t.left-f+t.width,m=f-t.width/2+"px"}return{top:s="top"===l[0]?s-a:s+a,left:d="left"===l[0]?d-i:d+i,transform:p,arrowLeft:m,arrowTop:v}},c=0,f=e.forwardRef((function(t,f){var s=t.trigger,d=void 0===s?null:s,p=t.onOpen,v=void 0===p?function(){}:p,m=t.onClose,h=void 0===m?function(){}:m,y=t.defaultOpen,g=t.open,w=void 0===g?void 0:g,b=t.disabled,E=void 0!==b&&b,k=t.nested,x=void 0!==k&&k,L=t.closeOnDocumentClick,A=void 0===L||L,C=t.repositionOnResize,T=void 0===C||C,O=t.closeOnEscape,R=void 0===O||O,S=t.on,X=void 0===S?["click"]:S,P=t.contentStyle,Y=void 0===P?{}:P,j=t.arrowStyle,z=void 0===j?{}:j,B=t.overlayStyle,I=void 0===B?{}:B,D=t.className,M=void 0===D?"":D,N=t.position,q=void 0===N?"bottom center":N,F=t.modal,H=void 0!==F&&F,_=t.lockScroll,K=void 0!==_&&_,W=t.arrow,G=void 0===W||W,J=t.offsetX,Q=void 0===J?0:J,U=t.offsetY,V=void 0===U?0:U,Z=t.mouseEnterDelay,$=void 0===Z?100:Z,tt=t.mouseLeaveDelay,et=void 0===tt?100:tt,ot=t.keepTooltipInside,nt=void 0!==ot&&ot,rt=t.children,it=e.useState(w||void 0!==y&&y),at=it[0],ut=it[1],lt=e.useRef(null),ct=e.useRef(null),ft=e.useRef(null),st=e.useRef(null),dt=e.useRef("popup-"+ ++c),pt=!!H||!d,vt=e.useRef(0);i((function(){return at?(st.current=document.activeElement,Ct(),xt(),Et()):kt(),function(){clearTimeout(vt.current)}}),[at]),e.useEffect((function(){"boolean"==typeof w&&(w?mt():ht())}),[w,E]);var mt=function(t){at||E||(ut(!0),setTimeout((function(){return v(t)}),0))},ht=function(t){var e;at&&!E&&(ut(!1),pt&&(null===(e=st.current)||void 0===e||e.focus()),setTimeout((function(){return h(t)}),0))},yt=function(t){null==t||t.stopPropagation(),at?ht(t):mt(t)},gt=function(t){clearTimeout(vt.current),vt.current=setTimeout((function(){return mt(t)}),$)},wt=function(t){null==t||t.preventDefault(),yt()},bt=function(t){clearTimeout(vt.current),vt.current=setTimeout((function(){return ht(t)}),et)},Et=function(){pt&&K&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},kt=function(){pt&&K&&(document.getElementsByTagName("body")[0].style.overflow="auto")},xt=function(){var t,e=null==ct||null===(t=ct.current)||void 0===t?void 0:t.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),o=Array.prototype.slice.call(e)[0];null==o||o.focus()};e.useImperativeHandle(f,(function(){return{open:function(){mt()},close:function(){ht()},toggle:function(){yt()}}}));var Lt,At,Ct=function(){if(!pt&&at&&(null==lt?void 0:lt.current)&&(null==lt?void 0:lt.current)&&(null==ct?void 0:ct.current)){var t,e,o=function(t,e,o,n,r,i){var a=r.offsetX,c=r.offsetY,f={arrowLeft:"0%",arrowTop:"0%",left:0,top:0,transform:"rotate(135deg)"},s=0,d=function(t){var e={top:0,left:0,width:window.innerWidth,height:window.innerHeight};if("string"==typeof t){var o=document.querySelector(t);null!==o&&(e=o.getBoundingClientRect())}return e}(i),p=Array.isArray(o)?o:[o];for((i||Array.isArray(o))&&(p=[].concat(p,u));s<p.length;){var v={top:(f=l(t,e,p[s],n,{offsetX:a,offsetY:c})).top,left:f.left,width:e.width,height:e.height};if(!(v.top<=d.top||v.left<=d.left||v.top+v.height>=d.top+d.height||v.left+v.width>=d.left+d.width))break;s++}return f}(lt.current.getBoundingClientRect(),ct.current.getBoundingClientRect(),q,G,{offsetX:Q,offsetY:V},nt);ct.current.style.top=o.top+window.scrollY+"px",ct.current.style.left=o.left+window.scrollX+"px",G&&ft.current&&(ft.current.style.transform=o.transform,ft.current.style.setProperty("-ms-transform",o.transform),ft.current.style.setProperty("-webkit-transform",o.transform),ft.current.style.top=(null===(t=z.top)||void 0===t?void 0:t.toString())||o.arrowTop,ft.current.style.left=(null===(e=z.left)||void 0===e?void 0:e.toString())||o.arrowLeft)}};void 0===(At=R)&&(At=!0),e.useEffect((function(){if(At){var t=function(t){"Escape"===t.key&&Lt(t)};return document.addEventListener("keyup",t),function(){At&&document.removeEventListener("keyup",t)}}}),[Lt=ht,At]),function(t,o){void 0===o&&(o=!0),e.useEffect((function(){if(o){var e=function(e){if(9===e.keyCode){var o,n=null==t||null===(o=t.current)||void 0===o?void 0:o.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),r=Array.prototype.slice.call(n);if(1===r.length)return void e.preventDefault();var i=r[0],a=r[r.length-1];e.shiftKey&&document.activeElement===i?(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())}};return document.addEventListener("keydown",e),function(){o&&document.removeEventListener("keydown",e)}}}),[t,o])}(ct,at&&pt),function(t,o){void 0===o&&(o=!0),e.useEffect((function(){if(o){var e=function(){t()};return window.addEventListener("resize",e),function(){o&&window.removeEventListener("resize",e)}}}),[t,o])}(Ct,T),function(t,o,n){void 0===n&&(n=!0),e.useEffect((function(){if(n){var e=function(e){var n=Array.isArray(t)?t:[t],r=!1;n.forEach((function(t){t.current&&!t.current.contains(e.target)||(r=!0)})),e.stopPropagation(),r||o(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){n&&(document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e))}}}),[t,o,n])}(d?[ct,lt]:[ct],ht,A&&!x);var Tt,Ot=function(){return o.createElement("div",Object.assign({},(t=pt?a.popupContent.modal:a.popupContent.tooltip,e={className:"popup-content "+(""!==M?M.split(" ").map((function(t){return t+"-content"})).join(" "):""),style:r({},t,Y,{pointerEvents:"auto"}),ref:ct,onClick:function(t){t.stopPropagation()}},!H&&X.indexOf("hover")>=0&&(e.onMouseEnter=gt,e.onMouseLeave=bt),e),{key:"C",role:pt?"dialog":"tooltip",id:dt.current}),G&&!pt&&o.createElement("div",{ref:ft,style:a.popupArrow},o.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==M?M.split(" ").map((function(t){return t+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:r({position:"absolute"},z)},o.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),rt&&"function"==typeof rt?rt(ht,at):rt);var t,e},Rt=!(X.indexOf("hover")>=0),St=pt?a.overlay.modal:a.overlay.tooltip,Xt=[Rt&&o.createElement("div",{key:"O","data-testid":"overlay","data-popup":pt?"modal":"tooltip",className:"popup-overlay "+(""!==M?M.split(" ").map((function(t){return t+"-overlay"})).join(" "):""),style:r({},St,I,{pointerEvents:A&&x||pt?"auto":"none"}),onClick:A&&x?ht:void 0,tabIndex:-1},pt&&Ot()),!pt&&Ot()];return o.createElement(o.Fragment,null,function(){for(var t={key:"T",ref:lt,"aria-describedby":dt.current},e=Array.isArray(X)?X:[X],n=0,r=e.length;n<r;n++)switch(e[n]){case"click":t.onClick=yt;break;case"right-click":t.onContextMenu=wt;break;case"hover":t.onMouseEnter=gt,t.onMouseLeave=bt;break;case"focus":t.onFocus=gt,t.onBlur=bt}if("function"==typeof d){var i=d(at);return!!d&&o.cloneElement(i,t)}return!!d&&o.cloneElement(d,t)}(),at&&n.createPortal(Xt,(null===(Tt=document.getElementById("popup-root"))&&((Tt=document.createElement("div")).setAttribute("id","popup-root"),document.body.appendChild(Tt)),Tt)))}));exports.Popup=f,exports.default=f;
|
|
//# sourceMappingURL=reactjs-popup.cjs.production.min.js.map
|