UNPKG

@r365/react-calendar-timeline

Version:
8 lines (6 loc) 18.9 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Pt(t){t._resizeEventListener=()=>t.resize(),window.addEventListener("resize",t._resizeEventListener)}function Wt(t){window.removeEventListener("resize",t._resizeEventListener)}const _t={addListener:Pt,removeListener:Wt};function Bt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Et={exports:{}},Rt=Et.exports={};Rt.forEach=function(t,i){for(var s=0;s<t.length;s++){var r=i(t[s]);if(r)return r}};var xt=Et.exports,Ft=function(t){var i=t.stateHandler.getState;function s(l){var d=i(l);return d&&!!d.isDetectable}function r(l){i(l).isDetectable=!0}function u(l){return!!i(l).busy}function g(l,d){i(l).busy=!!d}return{isDetectable:s,markAsDetectable:r,isBusy:u,markBusy:g}},$t=function(t){var i={};function s(l){var d=t.get(l);return d===void 0?[]:i[d]||[]}function r(l,d){var h=t.get(l);i[h]||(i[h]=[]),i[h].push(d)}function u(l,d){for(var h=s(l),c=0,b=h.length;c<b;++c)if(h[c]===d){h.splice(c,1);break}}function g(l){var d=s(l);d&&(d.length=0)}return{get:s,add:r,removeListener:u,removeAllListeners:g}},qt=function(){var t=1;function i(){return t++}return{generate:i}},Ut=function(t){var i=t.idGenerator,s=t.stateHandler.getState;function r(g){var l=s(g);return l&&l.id!==void 0?l.id:null}function u(g){var l=s(g);if(!l)throw new Error("setId required the element to have a resize detection state.");var d=i.generate();return l.id=d,d}return{get:r,set:u}},Gt=function(t){function i(){}var s={log:i,warn:i,error:i};if(!t&&window.console){var r=function(u,g){u[g]=function(){var d=console[g];if(d.apply)d.apply(console,arguments);else for(var h=0;h<arguments.length;h++)d(arguments[h])}};r(s,"log"),r(s,"warn"),r(s,"error")}return s},kt={exports:{}},mt=kt.exports={};mt.isIE=function(t){function i(){var r=navigator.userAgent.toLowerCase();return r.indexOf("msie")!==-1||r.indexOf("trident")!==-1||r.indexOf(" edge/")!==-1}if(!i())return!1;if(!t)return!0;var s=function(){var r,u=3,g=document.createElement("div"),l=g.getElementsByTagName("i");do g.innerHTML="<!--[if gt IE "+ ++u+"]><i></i><![endif]-->";while(l[0]);return u>4?u:r}();return t===s};mt.isLegacyOpera=function(){return!!window.opera};var Lt=kt.exports,zt={exports:{}},Vt=zt.exports={};Vt.getOption=Jt;function Jt(t,i,s){var r=t[i];return r==null&&s!==void 0?s:r}var Yt=zt.exports,gt=Yt,Kt=function(i){i=i||{};var s=i.reporter,r=gt.getOption(i,"async",!0),u=gt.getOption(i,"auto",!0);u&&!r&&(s&&s.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),r=!0);var g=bt(),l,d=!1;function h(S,T){!d&&u&&r&&g.size()===0&&z(),g.add(S,T)}function c(){for(d=!0;g.size();){var S=g;g=bt(),S.process()}d=!1}function b(S){d||(S===void 0&&(S=r),l&&(N(l),l=null),S?z():c())}function z(){l=k(c)}function N(S){var T=clearTimeout;return T(S)}function k(S){var T=function(P){return setTimeout(P,0)};return T(S)}return{add:h,force:b}};function bt(){var t={},i=0,s=0,r=0;function u(d,h){h||(h=d,d=0),d>s?s=d:d<r&&(r=d),t[d]||(t[d]=[]),t[d].push(h),i++}function g(){for(var d=r;d<=s;d++)for(var h=t[d],c=0;c<h.length;c++){var b=h[c];b()}}function l(){return i}return{add:u,process:g,size:l}}var st="_erd";function Qt(t){return t[st]={},Dt(t)}function Dt(t){return t[st]}function Xt(t){delete t[st]}var Zt={initState:Qt,getState:Dt,cleanState:Xt},Z=Lt,te=function(t){t=t||{};var i=t.reporter,s=t.batchProcessor,r=t.stateHandler.getState;if(!i)throw new Error("Missing required dependency: reporter.");function u(c,b){function z(){b(c)}if(Z.isIE(8))r(c).object={proxy:z},c.attachEvent("onresize",z);else{var N=d(c);if(!N)throw new Error("Element is not detectable by this strategy.");N.contentDocument.defaultView.addEventListener("resize",z)}}function g(c){var b=t.important?" !important; ":"; ";return(c.join(b)+b).trim()}function l(c,b,z){z||(z=b,b=c,c=null),c=c||{},c.debug;function N(k,S){var T=g(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),P=!1,W=window.getComputedStyle(k),m=k.offsetWidth,L=k.offsetHeight;r(k).startSize={width:m,height:L};function o(){function e(){if(W.position==="static"){k.style.setProperty("position","relative",c.important?"important":"");var D=function(A,w,H,f){function y(O){return O.replace(/[^-\d\.]/g,"")}var I=H[f];I!=="auto"&&y(I)!=="0"&&(A.warn("An element that is positioned static has style."+f+"="+I+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+f+" will be set to 0. Element: ",w),w.style.setProperty(f,"0",c.important?"important":""))};D(i,k,W,"top"),D(i,k,W,"right"),D(i,k,W,"bottom"),D(i,k,W,"left")}}function E(){P||e();function D(w,H){if(!w.contentDocument){var f=r(w);f.checkForObjectDocumentTimeoutId&&window.clearTimeout(f.checkForObjectDocumentTimeoutId),f.checkForObjectDocumentTimeoutId=setTimeout(function(){f.checkForObjectDocumentTimeoutId=0,D(w,H)},100);return}H(w.contentDocument)}var A=this;D(A,function(H){S(k)})}W.position!==""&&(e(),P=!0);var n=document.createElement("object");n.style.cssText=T,n.tabIndex=-1,n.type="text/html",n.setAttribute("aria-hidden","true"),n.onload=E,Z.isIE()||(n.data="about:blank"),r(k)&&(k.appendChild(n),r(k).object=n,Z.isIE()&&(n.data="about:blank"))}s?s.add(o):o()}Z.isIE(8)?z(b):N(b,z)}function d(c){return r(c).object}function h(c){if(r(c)){var b=d(c);b&&(Z.isIE(8)?c.detachEvent("onresize",b.proxy):c.removeChild(b),r(c).checkForObjectDocumentTimeoutId&&window.clearTimeout(r(c).checkForObjectDocumentTimeoutId),delete r(c).object)}}return{makeDetectable:l,addListener:u,uninstall:h}},ee=xt.forEach,re=function(t){t=t||{};var i=t.reporter,s=t.batchProcessor,r=t.stateHandler.getState;t.stateHandler.hasState;var u=t.idHandler;if(!s)throw new Error("Missing required dependency: batchProcessor");if(!i)throw new Error("Missing required dependency: reporter.");var g=b(),l="erd_scroll_detection_scrollbar_style",d="erd_scroll_detection_container";function h(o){z(o,l,d)}h(window.document);function c(o){var e=t.important?" !important; ":"; ";return(o.join(e)+e).trim()}function b(){var o=500,e=500,E=document.createElement("div");E.style.cssText=c(["position: absolute","width: "+o*2+"px","height: "+e*2+"px","visibility: hidden","margin: 0","padding: 0"]);var n=document.createElement("div");n.style.cssText=c(["position: absolute","width: "+o+"px","height: "+e+"px","overflow: scroll","visibility: none","top: "+-o*3+"px","left: "+-e*3+"px","visibility: hidden","margin: 0","padding: 0"]),n.appendChild(E),document.body.insertBefore(n,document.body.firstChild);var D=o-n.clientWidth,A=e-n.clientHeight;return document.body.removeChild(n),{width:D,height:A}}function z(o,e,E){function n(H,f){f=f||function(I){o.head.appendChild(I)};var y=o.createElement("style");return y.innerHTML=H,y.id=e,f(y),y}if(!o.getElementById(e)){var D=E+"_animation",A=E+"_animation_active",w=`/* Created by the element-resize-detector library. */ `;w+="."+E+" > div::-webkit-scrollbar { "+c(["display: none"])+` } `,w+="."+A+" { "+c(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+D,"animation-name: "+D])+` } `,w+="@-webkit-keyframes "+D+` { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } } `,w+="@keyframes "+D+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",n(w)}}function N(o){o.className+=" "+d+"_animation_active"}function k(o,e,E){if(o.addEventListener)o.addEventListener(e,E);else if(o.attachEvent)o.attachEvent("on"+e,E);else return i.error("[scroll] Don't know how to add event listeners.")}function S(o,e,E){if(o.removeEventListener)o.removeEventListener(e,E);else if(o.detachEvent)o.detachEvent("on"+e,E);else return i.error("[scroll] Don't know how to remove event listeners.")}function T(o){return r(o).container.childNodes[0].childNodes[0].childNodes[0]}function P(o){return r(o).container.childNodes[0].childNodes[0].childNodes[1]}function W(o,e){var E=r(o).listeners;if(!E.push)throw new Error("Cannot add listener to an element that is not detectable.");r(o).listeners.push(e)}function m(o,e,E){E||(E=e,e=o,o=null),o=o||{};function n(){if(o.debug){var a=Array.prototype.slice.call(arguments);if(a.unshift(u.get(e),"Scroll: "),i.log.apply)i.log.apply(null,a);else for(var v=0;v<a.length;v++)i.log(a[v])}}function D(a){function v(x){var _=x.getRootNode&&x.getRootNode().contains(x);return x===x.ownerDocument.body||x.ownerDocument.body.contains(x)||_}return!v(a)||window.getComputedStyle(a)===null}function A(a){var v=r(a).container.childNodes[0],x=window.getComputedStyle(v);return!x.width||x.width.indexOf("px")===-1}function w(){var a=window.getComputedStyle(e),v={};return v.position=a.position,v.width=e.offsetWidth,v.height=e.offsetHeight,v.top=a.top,v.right=a.right,v.bottom=a.bottom,v.left=a.left,v.widthCSS=a.width,v.heightCSS=a.height,v}function H(){var a=w();r(e).startSize={width:a.width,height:a.height},n("Element start size",r(e).startSize)}function f(){r(e).listeners=[]}function y(){if(n("storeStyle invoked."),!r(e)){n("Aborting because element has been uninstalled");return}var a=w();r(e).style=a}function I(a,v,x){r(a).lastWidth=v,r(a).lastHeight=x}function O(a){return T(a).childNodes[0]}function U(){return 2*g.width+1}function et(){return 2*g.height+1}function rt(a){return a+10+U()}function it(a){return a+10+et()}function Ct(a){return a*2+U()}function Ht(a){return a*2+et()}function dt(a,v,x){var _=T(a),G=P(a),Y=rt(v),K=it(x),j=Ct(v),p=Ht(x);_.scrollLeft=Y,_.scrollTop=K,G.scrollLeft=j,G.scrollTop=p}function ct(){var a=r(e).container;if(!a){a=document.createElement("div"),a.className=d,a.style.cssText=c(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),r(e).container=a,N(a),e.appendChild(a);var v=function(){r(e).onRendered&&r(e).onRendered()};k(a,"animationstart",v),r(e).onAnimationStart=v}return a}function Tt(){function a(){var C=r(e).style;if(C.position==="static"){e.style.setProperty("position","relative",o.important?"important":"");var F=function(X,J,It,at){function Mt(Nt){return Nt.replace(/[^-\d\.]/g,"")}var ot=It[at];ot!=="auto"&&Mt(ot)!=="0"&&(X.warn("An element that is positioned static has style."+at+"="+ot+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+at+" will be set to 0. Element: ",J),J.style[at]=0)};F(i,e,C,"top"),F(i,e,C,"right"),F(i,e,C,"bottom"),F(i,e,C,"left")}}function v(C,F,X,J){return C=C?C+"px":"0",F=F?F+"px":"0",X=X?X+"px":"0",J=J?J+"px":"0",["left: "+C,"top: "+F,"right: "+J,"bottom: "+X]}if(n("Injecting elements"),!r(e)){n("Aborting because element has been uninstalled");return}a();var x=r(e).container;x||(x=ct());var _=g.width,G=g.height,Y=c(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),K=c(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(v(-(1+_),-(1+G),-G,-_))),j=c(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),p=c(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),M=c(["position: absolute","left: 0","top: 0"]),V=c(["position: absolute","width: 200%","height: 200%"]),B=document.createElement("div"),R=document.createElement("div"),Q=document.createElement("div"),lt=document.createElement("div"),nt=document.createElement("div"),ft=document.createElement("div");B.dir="ltr",B.style.cssText=Y,B.className=d,R.className=d,R.style.cssText=K,Q.style.cssText=j,lt.style.cssText=M,nt.style.cssText=p,ft.style.cssText=V,Q.appendChild(lt),nt.appendChild(ft),R.appendChild(Q),R.appendChild(nt),B.appendChild(R),x.appendChild(B);function ht(){var C=r(e);C&&C.onExpand?C.onExpand():n("Aborting expand scroll handler: element has been uninstalled")}function vt(){var C=r(e);C&&C.onShrink?C.onShrink():n("Aborting shrink scroll handler: element has been uninstalled")}k(Q,"scroll",ht),k(nt,"scroll",vt),r(e).onExpandScroll=ht,r(e).onShrinkScroll=vt}function At(){function a(j,p,M){var V=O(j),B=rt(p),R=it(M);V.style.setProperty("width",B+"px",o.important?"important":""),V.style.setProperty("height",R+"px",o.important?"important":"")}function v(j){var p=e.offsetWidth,M=e.offsetHeight,V=p!==r(e).lastWidth||M!==r(e).lastHeight;n("Storing current size",p,M),I(e,p,M),s.add(0,function(){if(V){if(!r(e)){n("Aborting because element has been uninstalled");return}if(!x()){n("Aborting because element container has not been initialized");return}if(o.debug){var R=e.offsetWidth,Q=e.offsetHeight;(R!==p||Q!==M)&&i.warn(u.get(e),"Scroll: Size changed before updating detector elements.")}a(e,p,M)}}),s.add(1,function(){if(!r(e)){n("Aborting because element has been uninstalled");return}if(!x()){n("Aborting because element container has not been initialized");return}dt(e,p,M)}),V&&j&&s.add(2,function(){if(!r(e)){n("Aborting because element has been uninstalled");return}if(!x()){n("Aborting because element container has not been initialized");return}j()})}function x(){return!!r(e).container}function _(){function j(){return r(e).lastNotifiedWidth===void 0}n("notifyListenersIfNeeded invoked");var p=r(e);if(j()&&p.lastWidth===p.startSize.width&&p.lastHeight===p.startSize.height)return n("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(p.lastWidth===p.lastNotifiedWidth&&p.lastHeight===p.lastNotifiedHeight)return n("Not notifying: Size already notified");n("Current size not notified, notifying..."),p.lastNotifiedWidth=p.lastWidth,p.lastNotifiedHeight=p.lastHeight,ee(r(e).listeners,function(M){M(e)})}function G(){if(n("startanimation triggered."),A(e)){n("Ignoring since element is still unrendered...");return}n("Element rendered.");var j=T(e),p=P(e);(j.scrollLeft===0||j.scrollTop===0||p.scrollLeft===0||p.scrollTop===0)&&(n("Scrollbars out of sync. Updating detector elements..."),v(_))}function Y(){if(n("Scroll detected."),A(e)){n("Scroll event fired while unrendered. Ignoring...");return}v(_)}if(n("registerListenersAndPositionElements invoked."),!r(e)){n("Aborting because element has been uninstalled");return}r(e).onRendered=G,r(e).onExpand=Y,r(e).onShrink=Y;var K=r(e).style;a(e,K.width,K.height)}function Ot(){if(n("finalizeDomMutation invoked."),!r(e)){n("Aborting because element has been uninstalled");return}var a=r(e).style;I(e,a.width,a.height),dt(e,a.width,a.height)}function jt(){E(e)}function ut(){n("Installing..."),f(),H(),s.add(0,y),s.add(1,Tt),s.add(2,At),s.add(3,Ot),s.add(4,jt)}n("Making detectable..."),D(e)?(n("Element is detached"),ct(),n("Waiting until element is attached..."),r(e).onRendered=function(){n("Element is now attached"),ut()}):ut()}function L(o){var e=r(o);e&&(e.onExpandScroll&&S(T(o),"scroll",e.onExpandScroll),e.onShrinkScroll&&S(P(o),"scroll",e.onShrinkScroll),e.onAnimationStart&&S(e.container,"animationstart",e.onAnimationStart),e.container&&o.removeChild(e.container))}return{makeDetectable:m,addListener:W,uninstall:L,initDocument:h}},tt=xt.forEach,ie=Ft,ne=$t,ae=qt,oe=Ut,se=Gt,pt=Lt,de=Kt,$=Zt,ce=te,ue=re;function yt(t){return Array.isArray(t)||t.length!==void 0}function wt(t){if(Array.isArray(t))return t;var i=[];return tt(t,function(s){i.push(s)}),i}function St(t){return t&&t.nodeType===1}var le=function(t){t=t||{};var i;if(t.idHandler)i={get:function(m){return t.idHandler.get(m,!0)},set:t.idHandler.set};else{var s=ae(),r=oe({idGenerator:s,stateHandler:$});i=r}var u=t.reporter;if(!u){var g=u===!1;u=se(g)}var l=q(t,"batchProcessor",de({reporter:u})),d={};d.callOnAdd=!!q(t,"callOnAdd",!0),d.debug=!!q(t,"debug",!1);var h=ne(i),c=ie({stateHandler:$}),b,z=q(t,"strategy","object"),N=q(t,"important",!1),k={reporter:u,batchProcessor:l,stateHandler:$,idHandler:i,important:N};if(z==="scroll"&&(pt.isLegacyOpera()?(u.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),z="object"):pt.isIE(9)&&(u.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),z="object")),z==="scroll")b=ue(k);else if(z==="object")b=ce(k);else throw new Error("Invalid strategy name: "+z);var S={};function T(m,L,o){function e(H){var f=h.get(H);tt(f,function(I){I(H)})}function E(H,f,y){h.add(f,y),H&&y(f)}if(o||(o=L,L=m,m={}),!L)throw new Error("At least one element required.");if(!o)throw new Error("Listener required.");if(St(L))L=[L];else if(yt(L))L=wt(L);else return u.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var n=0,D=q(m,"callOnAdd",d.callOnAdd),A=q(m,"onReady",function(){}),w=q(m,"debug",d.debug);tt(L,function(f){$.getState(f)||($.initState(f),i.set(f));var y=i.get(f);if(w&&u.log("Attaching listener to element",y,f),!c.isDetectable(f)){if(w&&u.log(y,"Not detectable."),c.isBusy(f)){w&&u.log(y,"System busy making it detectable"),E(D,f,o),S[y]=S[y]||[],S[y].push(function(){n++,n===L.length&&A()});return}return w&&u.log(y,"Making detectable..."),c.markBusy(f,!0),b.makeDetectable({debug:w,important:N},f,function(O){if(w&&u.log(y,"onElementDetectable"),$.getState(O)){c.markAsDetectable(O),c.markBusy(O,!1),b.addListener(O,e),E(D,O,o);var U=$.getState(O);if(U&&U.startSize){var et=O.offsetWidth,rt=O.offsetHeight;(U.startSize.width!==et||U.startSize.height!==rt)&&e(O)}S[y]&&tt(S[y],function(it){it()})}else w&&u.log(y,"Element uninstalled before being detectable.");delete S[y],n++,n===L.length&&A()})}w&&u.log(y,"Already detecable, adding listener."),E(D,f,o),n++}),n===L.length&&A()}function P(m){if(!m)return u.error("At least one element is required.");if(St(m))m=[m];else if(yt(m))m=wt(m);else return u.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");tt(m,function(L){h.removeAllListeners(L),b.uninstall(L),$.cleanState(L)})}function W(m){b.initDocument&&b.initDocument(m)}return{listenTo:T,removeListener:h.removeListener,removeAllListeners:h.removeAllListeners,uninstall:P,initDocument:W}};function q(t,i,s){var r=t[i];return r==null&&s!==void 0?s:r}const fe=Bt(le);function he(t){var s;const i=t.container instanceof HTMLElement?t.container:(s=t.container)==null?void 0:s.current;if(!i){console.error("Resize detector: container element is not available.");return}t._erd=fe({strategy:"scroll"}),t._erdWidth=i.offsetWidth,t._erd.listenTo(i,r=>{const u=r.offsetWidth;t._erdWidth!==u&&(t.resize(t.props),t._erdWidth=u)})}function ve(t){var s;const i=t.container instanceof HTMLElement?t.container:(s=t.container)==null?void 0:s.current;if(!i){console.error("Resize detector: container element is not available.");return}t._erd.removeAllListeners(i)}const ge={addListener:he,removeListener:ve};exports.containerListeners=ge;exports.windowListeners=_t; //# sourceMappingURL=react-calendar-timeline.resize-detector.cjs.js.map