UNPKG

remeasure

Version:

Get position and size of the DOM element for any React Component

77 lines 31.7 kB
!(function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("prop-types"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define("remeasure",["prop-types","react","react-dom"],n):"object"==typeof exports?exports.remeasure=n(require("prop-types"),require("react"),require("react-dom")):e.remeasure=n(e["prop-types"],e.react,e["react-dom"])})(window,(function(e,n,t){return (function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)})({"./node_modules/debounce/index.js": /*!****************************************!*\ !*** ./node_modules/debounce/index.js ***! \****************************************/ /*! no static exports found */ /*! exports used: default */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n){function t(e,n,t){var r,o,i,u,s;function c(){var a=Date.now()-u;a<n&&a>=0?r=setTimeout(c,n-a):(r=null,t||(s=e.apply(i,o),i=o=null))}null==n&&(n=100);var a=function(){i=this,o=arguments,u=Date.now();var a=t&&!r;return r||(r=setTimeout(c,n)),a&&(s=e.apply(i,o),i=o=null),s};return a.clear=function(){r&&(clearTimeout(r),r=null)},a.flush=function(){r&&(s=e.apply(i,o),i=o=null,clearTimeout(r),r=null)},a}t.debounce=t,e.exports=t},"./node_modules/performance-now/lib/performance-now.js": /*!*************************************************************!*\ !*** ./node_modules/performance-now/lib/performance-now.js ***! \*************************************************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n,t){(function(n){(function(){var t,r,o,i,u,s;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:void 0!==n&&null!==n&&n.hrtime?(e.exports=function(){return(t()-u)/1e6},r=n.hrtime,i=(t=function(){var e;return 1e9*(e=r())[0]+e[1]})(),s=1e9*n.uptime(),u=i-s):Date.now?(e.exports=function(){return Date.now()-o},o=Date.now()):(e.exports=function(){return(new Date).getTime()-o},o=(new Date).getTime())}).call(this)}).call(this,t(/*! ./../../process/browser.js */"./node_modules/process/browser.js"))},"./node_modules/process/browser.js": /*!*****************************************!*\ !*** ./node_modules/process/browser.js ***! \*****************************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n){var t,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!(function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}})();var c,a=[],f=!1,l=-1;function d(){f&&c&&(f=!1,c.length?a=c.concat(a):l=-1,a.length&&h())}function h(){if(!f){var e=s(d);f=!0;for(var n=a.length;n;){for(c=a,a=[];++l<n;)c&&c[l].run();l=-1,n=a.length}c=null,f=!1,(function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(n){try{return r.call(null,e)}catch(n){return r.call(this,e)}}})(e)}}function p(e,n){this.fun=e,this.array=n}function v(){}o.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];a.push(new p(e,n)),1!==a.length||f||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},"./node_modules/raf/index.js": /*!***********************************!*\ !*** ./node_modules/raf/index.js ***! \***********************************/ /*! no static exports found */ /*! exports used: default */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n,t){(function(n){for(var r=t(/*! performance-now */"./node_modules/performance-now/lib/performance-now.js"),o="undefined"==typeof window?n:window,i=["moz","webkit"],u="AnimationFrame",s=o["request"+u],c=o["cancel"+u]||o["cancelRequest"+u],a=0;!s&&a<i.length;a++)s=o[i[a]+"Request"+u],c=o[i[a]+"Cancel"+u]||o[i[a]+"CancelRequest"+u];if(!s||!c){var f=0,l=0,d=[];s=function(e){if(0===d.length){var n=r(),t=Math.max(0,1e3/60-(n-f));f=t+n,setTimeout((function(){var e=d.slice(0);d.length=0;for(var n=0;n<e.length;n++)if(!e[n].cancelled)try{e[n].callback(f)}catch(e){setTimeout((function(){throw e}),0)}}),Math.round(t))}return d.push({handle:++l,callback:e,cancelled:!1}),l},c=function(e){for(var n=0;n<d.length;n++)d[n].handle===e&&(d[n].cancelled=!0)}}e.exports=function(e){return s.call(o,e)},e.exports.cancel=function(){c.apply(o,arguments)},e.exports.polyfill=function(e){e||(e=o),e.requestAnimationFrame=s,e.cancelAnimationFrame=c}}).call(this,t(/*! ./../webpack/buildin/global.js */"./node_modules/webpack/buildin/global.js"))},"./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js": /*!*************************************************************************!*\ !*** ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js ***! \*************************************************************************/ /*! exports provided: default */ /*! exports used: default */ /*! ModuleConcatenation bailout: Module uses injected variables (global) */function(e,n,t){"use strict";(function(e){var t=(function(){if("undefined"!=typeof Map)return Map;function e(e,n){var t=-1;return e.some((function(e,r){return e[0]===n&&(t=r,!0)})),t}return (function(){function n(){this.__entries__=[]}var t={size:{configurable:!0}};return t.size.get=function(){return this.__entries__.length},n.prototype.get=function(n){var t=e(this.__entries__,n),r=this.__entries__[t];return r&&r[1]},n.prototype.set=function(n,t){var r=e(this.__entries__,n);~r?this.__entries__[r][1]=t:this.__entries__.push([n,t])},n.prototype.delete=function(n){var t=this.__entries__,r=e(t,n);~r&&t.splice(r,1)},n.prototype.has=function(n){return!!~e(this.__entries__,n)},n.prototype.clear=function(){this.__entries__.splice(0)},n.prototype.forEach=function(e,n){void 0===n&&(n=null);for(var t=0,r=this.__entries__;t<r.length;t+=1){var o=r[t];e.call(n,o[1],o[0])}},Object.defineProperties(n.prototype,t),n})()})(),r="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,o=void 0!==e&&e.Math===Math?e:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),i="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(o):function(e){return setTimeout((function(){return e(Date.now())}),1e3/60)},u=2,s=["top","right","bottom","left","width","height","size","weight"],c="undefined"!=typeof MutationObserver,a=function(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=(function(e,n){var t=!1,r=!1,o=0;function s(){t&&(t=!1,e()),r&&a()}function c(){i(s)}function a(){var e=Date.now();if(t){if(e-o<u)return;r=!0}else t=!0,r=!1,setTimeout(c,n);o=e}return a})(this.refresh.bind(this),20)};a.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},a.prototype.removeObserver=function(e){var n=this.observers_,t=n.indexOf(e);~t&&n.splice(t,1),!n.length&&this.connected_&&this.disconnect_()},a.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},a.prototype.updateObservers_=function(){var e=this.observers_.filter((function(e){return e.gatherActive(),e.hasActive()}));return e.forEach((function(e){return e.broadcastActive()})),e.length>0},a.prototype.connect_=function(){r&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),c?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){r&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(e){var n=e.propertyName;void 0===n&&(n=""),s.some((function(e){return!!~n.indexOf(e)}))&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null;var f=function(e,n){for(var t=0,r=Object.keys(n);t<r.length;t+=1){var o=r[t];Object.defineProperty(e,o,{value:n[o],enumerable:!1,writable:!1,configurable:!0})}return e},l=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||o},d=b(0,0,0,0);function h(e){return parseFloat(e)||0}function p(e){for(var n=[],t=arguments.length-1;t-- >0;)n[t]=arguments[t+1];return n.reduce((function(n,t){return n+h(e["border-"+t+"-width"])}),0)}function v(e){var n=e.clientWidth,t=e.clientHeight;if(!n&&!t)return d;var r=l(e).getComputedStyle(e),o=(function(e){for(var n={},t=0,r=["top","right","bottom","left"];t<r.length;t+=1){var o=r[t],i=e["padding-"+o];n[o]=h(i)}return n})(r),i=o.left+o.right,u=o.top+o.bottom,s=h(r.width),c=h(r.height);if("border-box"===r.boxSizing&&(Math.round(s+i)!==n&&(s-=p(r,"left","right")+i),Math.round(c+u)!==t&&(c-=p(r,"top","bottom")+u)),!(function(e){return e===l(e).document.documentElement})(e)){var a=Math.round(s+i)-n,f=Math.round(c+u)-t;1!==Math.abs(a)&&(s-=a),1!==Math.abs(f)&&(c-=f)}return b(o.left,o.top,s,c)}var m="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof l(e).SVGGraphicsElement}:function(e){return e instanceof l(e).SVGElement&&"function"==typeof e.getBBox};function y(e){return r?m(e)?(function(e){var n=e.getBBox();return b(0,0,n.width,n.height)})(e):v(e):d}function b(e,n,t,r){return{x:e,y:n,width:t,height:r}}var _=function(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=b(0,0,0,0),this.target=e};_.prototype.isActive=function(){var e=y(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},_.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e};var g=function(e,n){var t=(function(e){var n=e.x,t=e.y,r=e.width,o=e.height,i="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,u=Object.create(i.prototype);return f(u,{x:n,y:t,width:r,height:o,top:t,right:n+r,bottom:o+t,left:n}),u})(n);f(this,{target:e,contentRect:t})},E=function(e,n,r){if(this.activeObservations_=[],this.observations_=new t,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=n,this.callbackCtx_=r};E.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof l(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(e)||(n.set(e,new _(e)),this.controller_.addObserver(this),this.controller_.refresh())}},E.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof l(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(e)&&(n.delete(e),n.size||this.controller_.removeObserver(this))}},E.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},E.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach((function(n){n.isActive()&&e.activeObservations_.push(n)}))},E.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,n=this.activeObservations_.map((function(e){return new g(e.target,e.broadcastRect())}));this.callback_.call(e,n,e),this.clearActive()}},E.prototype.clearActive=function(){this.activeObservations_.splice(0)},E.prototype.hasActive=function(){return this.activeObservations_.length>0};var w="undefined"!=typeof WeakMap?new WeakMap:new t,O=function(e){if(!(this instanceof O))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=a.getInstance(),t=new E(e,n,this);w.set(this,t)};["observe","unobserve","disconnect"].forEach((function(e){O.prototype[e]=function(){return(n=w.get(this))[e].apply(n,arguments);var n}}));var M=void 0!==o.ResizeObserver?o.ResizeObserver:O;n.a=M}).call(this,t(/*! ./../../webpack/buildin/global.js */"./node_modules/webpack/buildin/global.js"))},"./node_modules/webpack/buildin/global.js": /*!***********************************!*\ !*** (webpack)/buildin/global.js ***! \***********************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n){var t;t=(function(){return this})();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},"./src/constants.js": /*!**************************!*\ !*** ./src/constants.js ***! \**************************/ /*! exports provided: IS_LEGACY_REACT, COMPONENT_WILL_MOUNT, COMPONENT_WILL_RECEIVE_PROPS, IS_PRODUCTION, SOURCES, KEYS, KEY_NAMES, FUNCTION_NAME_REGEXP, NATURAL_REGEXP, VOID_ELEMENT_TAG_NAMES */ /*! exports used: COMPONENT_WILL_MOUNT, COMPONENT_WILL_RECEIVE_PROPS, FUNCTION_NAME_REGEXP, IS_PRODUCTION, KEYS, KEY_NAMES, NATURAL_REGEXP, SOURCES, VOID_ELEMENT_TAG_NAMES */ /*! ModuleConcatenation bailout: Module uses injected variables (process) */function(e,n,t){"use strict";(function(e){t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return s})),t.d(n,"d",(function(){return c})),t.d(n,"h",(function(){return a})),t.d(n,"e",(function(){return f})),t.d(n,"f",(function(){return l})),t.d(n,"c",(function(){return d})),t.d(n,"g",(function(){return h})),t.d(n,"i",(function(){return p}));var r=t(/*! react */"react"),o=t.n(r),i=(function(){try{var e=o.a.version.split(".").slice(0,2).map((function(e){return~~e}));return e[0]<16||16===e[0]&&e[1]<3}catch(e){return!0}})(),u=i?"componentWillMount":"UNSAFE_componentWillMount",s=i?"componentWillReceiveProps":"UNSAFE_componentWillReceiveProps",c=!(!e||!e.env),a={CLIENT_RECT:"CLIENT_RECT",ELEMENT:"ELEMENT"},f=[{key:"bottom",source:a.CLIENT_RECT},{key:"left",source:a.CLIENT_RECT},{key:"height",source:a.CLIENT_RECT},{key:"right",source:a.CLIENT_RECT},{key:"top",source:a.CLIENT_RECT},{key:"width",source:a.CLIENT_RECT},{key:"clientLeft",source:a.ELEMENT},{key:"clientHeight",source:a.ELEMENT},{key:"clientTop",source:a.ELEMENT},{key:"clientWidth",source:a.ELEMENT},{key:"naturalHeight",source:a.ELEMENT},{key:"naturalWidth",source:a.ELEMENT},{key:"offsetLeft",source:a.ELEMENT},{key:"offsetHeight",source:a.ELEMENT},{key:"offsetTop",source:a.ELEMENT},{key:"offsetWidth",source:a.ELEMENT},{key:"scrollLeft",source:a.ELEMENT},{key:"scrollHeight",source:a.ELEMENT},{key:"scrollTop",source:a.ELEMENT},{key:"scrollWidth",source:a.ELEMENT}],l=f.map((function(e){return e.key})),d=/^\s*function\s*([^\(]*)/i,h=/natural/,p=["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","MENUITEM","META","PARAM","SOURCE","TRACK","WBR"]}).call(this,t(/*! ./../node_modules/process/browser.js */"./node_modules/process/browser.js"))},"./src/index.js": /*!**********************************!*\ !*** ./src/index.js + 9 modules ***! \**********************************/ /*! exports provided: measure, Measured */ /*! all exports used */ /*! ModuleConcatenation bailout: Cannot concat with ./src/constants.js (<- Module uses injected variables (process)) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/debounce/index.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/raf/index.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */ /*! ModuleConcatenation bailout: Cannot concat with external "react" (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with external "react-dom" (<- Module is not an ECMAScript module) */function(e,n,t){"use strict";t.r(n);var r=t("./node_modules/debounce/index.js"),o=t.n(r),i="function"==typeof Map,u="function"==typeof Set,s="function"==typeof WeakSet,c=Object.keys,a=function(e,n){return e&&"object"==typeof e&&n.add(e)},f=function(e,n,t,r){for(var o=0;o<e.length;o++)if(t(e[o],n,r))return!0;return!1},l=function(e,n,t,r){if(e.length!==n.length)return!1;for(var o=0;o<e.length;o++)if(!f(n,e[o],t,r))return!1;return!0},d=function(e,n){return e===n||e!=e&&n!=n},h=function(e){return e.constructor===Object},p=function(e){return"function"==typeof e.then},v=function(e){return!(!e.$$typeof||!e._store)},m=function(e){return function(n){var t=e||n;return function(e,n,r){void 0===r&&(r=s?new WeakSet:Object.create({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}}));var o=r.has(e),i=r.has(n);return o||i?o&&i:(a(e,r),a(n,r),t(e,n,r))}}},y=function(e){var n={keys:[],values:[]};return e.forEach((function(e,t){return n.keys.push(t)&&n.values.push(e)})),n},b=function(e,n,t,r){if(e.length!==n.length)return!1;for(var o=0;o<e.length;o++)if(!t(e[o],n[o],r))return!1;return!0},_=function(e){var n=e?function(e,n,t,r){return l(e.keys,n.keys,t,r)&&l(e.values,n.values,t,r)}:function(e,n,t,r){return l(e.values,n.values,t,r)};return function(e,t,r,o){return n(y(e),y(t),r,o)}},g=function(e,n,t,r){var o,i=c(e),u=c(n);if(i.length!==u.length)return!1;for(var s=0;s<i.length;s++){if(o=i[s],!f(u,o,d))return!1;if(("_owner"!==o||!v(e)||!v(n))&&!t(e[o],n[o],r))return!1}return!0},E=function(e,n){return e.source===n.source&&e.global===n.global&&e.ignoreCase===n.ignoreCase&&e.multiline===n.multiline&&e.unicode===n.unicode&&e.sticky===n.sticky&&e.lastIndex===n.lastIndex},w=Array.isArray,O=_(!0),M=_(!1),T=function(e){var n="function"==typeof e?e(t):t;function t(e,t,r){if(d(e,t))return!0;var o=typeof e;if(o!==typeof t||"object"!==o||!e||!t)return!1;if(h(e)&&h(t))return g(e,t,n,r);var s=w(e),c=w(t);if(s||c)return s===c&&b(e,t,n,r);var a=e instanceof Date,f=t instanceof Date;if(a||f)return a===f&&d(e.getTime(),t.getTime());var l=e instanceof RegExp,v=t instanceof RegExp;if(l||v)return l===v&&E(e,t);if(p(e)||p(t))return e===t;if(i){var m=e instanceof Map,y=t instanceof Map;if(m||y)return m===y&&O(e,t,n,r)}if(u){var _=e instanceof Set,T=t instanceof Set;if(_||T)return _===T&&M(e,t,n,r)}return g(e,t,n,r)}return t},R=(T(m()),T(m(d)),T()),k=(T((function(){return d})),function(e){for(var n=new Array(e.length),t=0;t<e.length;t++)n[t]=e[t];return n}),C=function(e,n){var t="function"==typeof n?n:(function(e){return function(n,t){if(n.length!==t.length)return!1;for(var r=0;r<n.length;r++)if(!e(n[r],t[r]))return!1;return!0}})(e);return function(e,n){for(var r=0;r<e.length;r++)if(t(e[r],n))return r;return-1}},j=function(e,n){return e===n||e!=e&&n!=n},x=function(e,n,t){},z=function(e,n,t){for(var r=t;r--;)e[r+1]=e[r];e[0]=n},A=function(e,n,t){var r=e.keys[0];e.values[0]=e.values[0].then((function(r){return n.onCacheHit(e,n,t),n.onCacheChange(e,n,t),r})).catch((function(t){var o=C(n.isEqual)(e.keys,r);throw~o&&(e.keys.splice(o,1),e.values.splice(o,1)),t}))};function L(e,n){if(e.isMemoized)return e;var t=n||{},r=t.isEqual,o=void 0===r?j:r,i=t.isMatchingKey,u=t.isPromise,s=void 0!==u&&u,c=t.maxSize,a=void 0===c?1:c,f=t.onCacheAdd,l=void 0===f?x:f,d=t.onCacheChange,h=void 0===d?x:d,p=t.onCacheHit,v=void 0===p?x:p,m=t.transformKey,y=(function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o})(t,["isEqual","isMatchingKey","isPromise","maxSize","onCacheAdd","onCacheChange","onCacheHit","transformKey"]),b=Object.assign({},y,{isEqual:o,isMatchingKey:i,isPromise:s,maxSize:a,onCacheAdd:l,onCacheChange:h,onCacheHit:v,transformKey:m}),_=C(o,i),g=!(!m&&!i),E={keys:[],get size(){return E.keys.length},values:[]},w=E.keys,O=E.values;function M(){var n=g?k(arguments):arguments,t=m?m(n):n,r=_(w,t);if(~r)v(E,b,M),r&&(z(w,w[r],r),z(O,O[r],r),h(E,b,M));else{w.length>=a&&(w.pop(),O.pop());var o=g?t:k(n),i=e.apply(this,arguments);z(w,o,w.length),z(O,i,O.length),s&&A(E,b,M),l(E,b,M),h(E,b,M)}return O[0]}return Object.defineProperties(M,{cache:{configurable:!0,get:function(){return E}},cacheSnapshot:{configurable:!0,get:function(){return{keys:k(E.keys),size:E.size,values:k(E.values)}}},isMemoized:{configurable:!0,get:function(){return!0}},options:{configurable:!0,get:function(){return b}}}),M}t("prop-types");var N=t("react"),D=t.n(N),S=t("react-dom"),P=t("./node_modules/raf/index.js"),W=t.n(P),q=t("./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js"),I=t("./src/constants.js");var V=function(e){e.children,e.debounce,e.flatten,e.inheritedMethods;var n=e.keys,t=(e.namespace,e.renderOnResize,e.renderOnWindowResize,(function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o})(e,["children","debounce","flatten","inheritedMethods","keys","namespace","renderOnResize","renderOnWindowResize"])),r=Array.isArray(n)?n:Object.keys(t).filter((function(e){return t[e]}));return r.length?r.reduce((function(e,n){var t=I.f.indexOf(n);return~t&&e.push(I.e[t]),e}),[]):I.e};function H(){return(H=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function F(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var K=function(){return I.f.reduce((function(e,n){return e[n]=null,e}),{})},G=function(e){return function(){e.keys=V(e.props),e.setRenderMethod(e.props)}},U=function(e){return function(){e._isMounted=!0,e.element=Object(S.findDOMNode)(e),e.setResizeObserver()}},Y=function(e){return function(n){return e.setRenderMethod(n)}},$=function(e,n){var t=e.props.debounce,r=function(n){var t=e.element?e.element.getBoundingClientRect():{},r=n&&"resize"===n.type,o=I.e.reduce((function(n,r){return n[r.key]=~e.keys.indexOf(r)?e.element?(function(e,n){return e.hasOwnProperty(n)?e[n]:e[n.replace(I.g,"scroll")]})(r.source===I.h.CLIENT_RECT?t:e.element,r.key):0:null,n}),{});e._isMounted&&(!r&&R(e.state,o)||e.setState((function(){return o})))};return n&&"number"==typeof t?o()(r,t):function(e){return W()((function(){return r(e)}))}},J=function(e){return function(n){var t=n.debounce,r=e.props.debounce,o=Object(S.findDOMNode)(e),i=o!==e.element,u=r!==t,s=i||u;i&&(e.element=o),u&&(e.setValuesViaDebounce=$(e,!0)),s&&e.setResizeObserver();var c=V(e.props);!s&&R(e.keys,c)||(e.keys=c,e.resizeMethod())}},Q=function(e){return function(){e._isMounted=!1,e.disconnectObserver(),e.element=null,e.keys=[],e.resizeMethod=null}},X=function(e){return function(){var n=e.props,t=n.renderOnResize;n.renderOnWindowResize&&window.addEventListener("resize",e.resizeMethod),t&&(!I.d&&(function(e){return!!~I.i.indexOf(e.tagName)})(e.element)&&console.warn("WARNING: You are attempting to listen to resizes on a void element, which is not supported. You should wrap this element in an element that supports children, such as a <div>, to ensure correct behavior."),e.resizeObserver=new q.a(e.resizeMethod),e.resizeObserver.observe(e.element))}},Z=function(e){return function(){e.resizeObserver&&(e.resizeObserver.disconnect(e.element),e.resizeObserver=null),window.removeEventListener("resize",e.resizeMethod)}},ee=function(e){return L((function(n,t){var r,o=e.keys.reduce((function(e,t){var r=t.key;return e[r]=n[r]||0,e}),{});return t?((r={})[t]=o,r):o}))},ne=function(e,n){return function(t){e[n]=Object(S.findDOMNode)(t)}},te=function(e){return function(n){var t=n.children,r=n.component,o=n.render,i=t||r||o||null;I.d||"function"==typeof i||console.error('ERROR: You must provide a render function, or either a "render" or "component" prop that passes a functional component.'),i!==e.RenderComponent&&(e.RenderComponent=i)}},re=function(e){return function(){var n="number"==typeof e.props.debounce?e.setValuesViaDebounce:e.setValuesViaRaf;e.resizeObserver&&e.disconnectObserver(),n!==e.resizeMethod&&(e.resizeMethod=n,n()),e.element&&e.connectObserver()}},oe=(function(e){function n(){for(var n,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return B(F(F(n=e.call.apply(e,[this].concat(r))||this)),"state",K()),B(F(F(n)),"componentDidMount",U(F(F(n)))),B(F(F(n)),"componentDidUpdate",J(F(F(n)))),B(F(F(n)),"componentWillUnmount",Q(F(F(n)))),B(F(F(n)),I.a,G(F(F(n)))),B(F(F(n)),I.b,Y(F(F(n)))),B(F(F(n)),"_isMounted",!1),B(F(F(n)),"element",null),B(F(F(n)),"keys",[]),B(F(F(n)),"RenderComponent",null),B(F(F(n)),"resizeMethod",null),B(F(F(n)),"resizeObserver",null),B(F(F(n)),"connectObserver",X(F(F(n)))),B(F(F(n)),"disconnectObserver",Z(F(F(n)))),B(F(F(n)),"getPassedValues",ee(F(F(n)))),B(F(F(n)),"setElementRef",ne(F(F(n)),"element")),B(F(F(n)),"setRenderMethod",te(F(F(n)))),B(F(F(n)),"setResizeObserver",re(F(F(n)))),B(F(F(n)),"setValuesViaDebounce",$(F(F(n)),!0)),B(F(F(n)),"setValuesViaRaf",$(F(F(n)),!1)),n}return (function(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n})(n,e),n.prototype.render=function(){if(!this.RenderComponent)return null;var e=this.props,n=(e.children,e.component,e.debounce,e.keys,e.namespace),t=(e.render,e.renderOnResize,e.renderOnWindowResize,(function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o})(e,["children","component","debounce","keys","namespace","render","renderOnResize","renderOnWindowResize"])),r=this.RenderComponent;return D.a.createElement(r,H({},t,this.getPassedValues(this.state,n)))},n})(N.Component);B(oe,"displayName","Measured"),B(oe,"defaultProps",{renderOnResize:!0,renderOnWindowResize:!1});var ie=oe;function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(){return(se=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function ce(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}function ae(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function fe(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var le=function(e){return function(n){e.originalComponent=n}},de=function(e){var n,t,r=Object.getPrototypeOf(e),o=r===N.Component||r===N.PureComponent;return t=n=(function(n){function t(){return n.apply(this,arguments)||this}return ae(t,n),t.prototype.render=function(){var n=this.props,t=n._measuredComponentChildren,r=n._measuredComponentRef,i=ce(n,["_measuredComponentChildren","_measuredComponentRef"]);return D.a.createElement(e,se({children:t,ref:o?r:null},i))},t})(N.Component),fe(n,"displayName","Measured("+(function(e){if(e.displayName)return e.displayName;if(e.name)return e.name;var n=e.toString().match(I.c);return n&&n[1]||"Component"})(e)+")"),t},he=function(e,n){n.children,n.render;var t=ce(n,["children","render"]);return function(n){var r,o,i=de(n);return o=r=(function(n){function r(){for(var e,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return fe(ue(ue(e=n.call.apply(n,[this].concat(r))||this)),"originalComponent",null),fe(ue(ue(e)),"setOriginalRef",le(ue(ue(e)))),e}return ae(r,n),r.prototype.render=function(){var n=this.props,r=n.children,o=(n.render,ce(n,["children","render"]));return D.a.createElement(ie,se({},o,t,{_measuredComponentChildren:r,_measuredComponentRef:this.setOriginalRef,component:i,keys:e}))},r})(N.Component),fe(r,"displayName","MeasuredHoc"),o}},pe=function(e,n){return void 0===n&&(n={}),"function"==typeof e?he(I.f,n)(e):he(function(e){return Array.isArray(e)?I.f.reduce((function(n,t){return~e.indexOf(t)&&n.push(t),n}),[]):"string"==typeof e&&~I.f.indexOf(e)?[e]:I.f}(e),e&&e.constructor===Object?e:n)};I.f.forEach((function(e){pe[e]=function(n){return"function"==typeof n?pe([e])(n):pe([e],n)}})),t.d(n,"measure",(function(){return pe})),t.d(n,"Measured",(function(){return ie}))},0: /*!****************************!*\ !*** multi ./src/index.js ***! \****************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n,t){e.exports=t(/*! /home/tquetano/git/remeasure/src/index.js */"./src/index.js")},"prop-types": /*!*****************************!*\ !*** external "prop-types" ***! \*****************************/ /*! no static exports found */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(n,t){n.exports=e},react: /*!************************!*\ !*** external "react" ***! \************************/ /*! no static exports found */ /*! exports used: Component, PureComponent, default */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t){e.exports=n},"react-dom": /*!****************************!*\ !*** external "react-dom" ***! \****************************/ /*! no static exports found */ /*! exports used: findDOMNode */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,n){e.exports=t}})}));