Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-sizes

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-sizes - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

dist/react-sizes.js

@@ -1524,3 +1524,3 @@ (function (global, factory) {

_this.throttledDispatchSizes = lodash_throttle(_this.dispatchSizes, _this.context.throttle || 200);
_this.throttledDispatchSizes = lodash_throttle(_this.dispatchSizes, (_this.context[contextKey] || {}).throttle || 200);

@@ -1527,0 +1527,0 @@

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.ReactSizes={},t.React)}(this,function(t,e){"use strict";function n(t,e,n){function o(e){var n=l,r=p;return l=p=void 0,v=e,h=t.apply(r,n)}function a(t){var n=t-y;return void 0===y||n>=e||0>n||m&&t-v>=d}function u(){var t=T();if(a(t))return c(t);b=setTimeout(u,function(t){var n=e-(t-y);return m?O(n,d-(t-v)):n}(t))}function c(t){return b=void 0,k&&l?o(t):(l=p=void 0,h)}function s(){var t=T(),n=a(t);if(l=arguments,p=this,y=t,n){if(void 0===b)return function(t){return v=t,b=setTimeout(u,e),g?o(t):h}(y);if(m)return b=setTimeout(u,e),o(y)}return void 0===b&&(b=setTimeout(u,e)),h}var l,p,d,h,b,y,v=0,g=!1,m=!1,k=!0;if("function"!=typeof t)throw new TypeError(f);return e=i(e)||0,r(n)&&(g=!!n.leading,d=(m="maxWait"in n)?w(i(n.maxWait)||0,e):d,k="trailing"in n?!!n.trailing:k),s.cancel=function(){void 0!==b&&clearTimeout(b),v=0,l=y=p=b=void 0},s.flush=function(){return void 0===b?h:c(T())},s}function r(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function i(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||!!t&&"object"==typeof t&&m.call(t)==s}(t))return c;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(l,"");var n=d.test(t);return n||h.test(t)?b(t.slice(2),n?2:8):p.test(t)?c:+t}function o(t){return function(){return t}}var a="default"in e?e.default:e,u="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="Expected a function",c=NaN,s="[object Symbol]",l=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,h=/^0o[0-7]+$/i,b=parseInt,y="object"==typeof u&&u&&u.Object===Object&&u,v="object"==typeof self&&self&&self.Object===Object&&self,g=y||v||Function("return this")(),m=Object.prototype.toString,w=Math.max,O=Math.min,T=function(){return g.Date.now()},k=function(t,e,i){var o=!0,a=!0;if("function"!=typeof t)throw new TypeError(f);return r(i)&&(o="leading"in i?!!i.leading:o,a="trailing"in i?!!i.trailing:a),n(t,e,{leading:o,maxWait:e,trailing:a})},j=function(t,e){for(var n in t)if(!(n in e))return!0;for(var r in e)if(t[r]!==e[r])return!0;return!1},P=function(t){var e=t.fallbackWidth,n=void 0===e?null:e,r=t.fallbackHeight,i=void 0===r?null:r,o="undefined"!=typeof window;return{width:o?window.innerWidth:n,height:o?window.innerHeight:i,canUseDOM:o}},S=function(){};S.thatReturns=o,S.thatReturnsFalse=o(!1),S.thatReturnsTrue=o(!0),S.thatReturnsNull=o(null),S.thatReturnsThis=function(){return this},S.thatReturnsArgument=function(t){return t};var _=S,x=function(t,e,n,r,i,o,a,u){if(!t){var f;if(void 0===e)f=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,o,a,u],s=0;(f=Error(e.replace(/%s/g,function(){return c[s++]}))).name="Invariant Violation"}throw f.framesToPop=1,f}},z="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",W=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){t.exports=function(){function t(t,e,n,r,i,o){o!==z&&x(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e};return n.checkPropTypes=_,n.PropTypes=n,n}()}),E=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},R=function(){function t(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),C=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},D=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},M=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},A="_ReactSizesConfig_",F=C({},A,W.shape({fallbackWidth:W.number,fallbackHeight:W.number,throttle:W.number})),N=function(t){return 480>t.width},I=function(t){return t.width>=1024},U=function(t){return!I(t)},L=Object.freeze({isMobile:N,isTablet:function(t){var e=t.width;return e>=480&&1024>e},isDesktop:I,isGtMobile:function(t){return!N(t)},isGtTablet:function(t){return I(t)},isStTablet:function(t){return N(t)},isStDesktop:U,isTabletAndGreater:function(t){return!N(t)},isTabletAndSmaller:function(t){return!U(t)}}),$=Object.assign(function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return function(t){var r,i,o=function(t,e){return n.map(function(n){return n(t,e)}).reduce(function(t,e){return D({},t,e)},{})};return i=r=function(n){function r(t,e){E(this,r);var n=M(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e));return n.dispatchSizes=function(){var t=n.getPropsToPass();j(t,n.state.propsToPass)&&n.setState({propsToPass:t})},n.throttledDispatchSizes=k(n.dispatchSizes,n.context.throttle||200),n.getWindowSizesWithFallback=function(){var t=n.context[A]||{},e=t.fallbackHeight,r=t.fallbackWidth;return P({fallbackHeight:void 0===e?null:e,fallbackWidth:void 0===r?null:r})},n.getPropsToPass=function(){return o(n.getWindowSizesWithFallback(),n.props)},n.state={initialSizes:n.getWindowSizesWithFallback(),propsToPass:n.getPropsToPass()},n}return H(r,e.Component),R(r,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.throttledDispatchSizes),this.dispatchSizes()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.throttledDispatchSizes)}},{key:"render",value:function(){return a.createElement(t,D({},this.props,this.state.propsToPass))}}]),r}(),r.displayName="withSizes("+(t.displayName||t.name||("string"==typeof t&&t.length>0?t:"Unknown"))+")",r.contextTypes=F,i}},D({},L)),G=function(t){function n(){return E(this,n),M(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return H(n,e.Component),R(n,[{key:"getChildContext",value:function(){var t=this.props.config,e=void 0===t?{}:t;return C({},A,{fallbackWidth:e.fallbackWidth||null,fallbackHeight:e.fallbackHeight||null,throttle:e.throttle||200})}},{key:"render",value:function(){return this.props.children}}]),n}();G.childContextTypes=F;var q=function(t){var e=t.children,n=t.render,r=function(t,e){var n={};for(var r in t)0>e.indexOf(r)&&Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}(t,["children","render"]),i=e||n;return i?i(r):null};t.withSizes=$,t.SizesProvider=G,t.createSizedComponent=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return $(e)(q)},t.presets=L,t.default=$,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.ReactSizes={},t.React)}(this,function(t,e){"use strict";function n(t,e,n){function o(e){var n=l,r=p;return l=p=void 0,v=e,h=t.apply(r,n)}function a(t){var n=t-y;return void 0===y||n>=e||0>n||m&&t-v>=d}function u(){var t=T();if(a(t))return c(t);b=setTimeout(u,function(t){var n=e-(t-y);return m?O(n,d-(t-v)):n}(t))}function c(t){return b=void 0,k&&l?o(t):(l=p=void 0,h)}function s(){var t=T(),n=a(t);if(l=arguments,p=this,y=t,n){if(void 0===b)return function(t){return v=t,b=setTimeout(u,e),g?o(t):h}(y);if(m)return b=setTimeout(u,e),o(y)}return void 0===b&&(b=setTimeout(u,e)),h}var l,p,d,h,b,y,v=0,g=!1,m=!1,k=!0;if("function"!=typeof t)throw new TypeError(f);return e=i(e)||0,r(n)&&(g=!!n.leading,d=(m="maxWait"in n)?w(i(n.maxWait)||0,e):d,k="trailing"in n?!!n.trailing:k),s.cancel=function(){void 0!==b&&clearTimeout(b),v=0,l=y=p=b=void 0},s.flush=function(){return void 0===b?h:c(T())},s}function r(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function i(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||!!t&&"object"==typeof t&&m.call(t)==s}(t))return c;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(l,"");var n=d.test(t);return n||h.test(t)?b(t.slice(2),n?2:8):p.test(t)?c:+t}function o(t){return function(){return t}}var a="default"in e?e.default:e,u="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="Expected a function",c=NaN,s="[object Symbol]",l=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,h=/^0o[0-7]+$/i,b=parseInt,y="object"==typeof u&&u&&u.Object===Object&&u,v="object"==typeof self&&self&&self.Object===Object&&self,g=y||v||Function("return this")(),m=Object.prototype.toString,w=Math.max,O=Math.min,T=function(){return g.Date.now()},k=function(t,e,i){var o=!0,a=!0;if("function"!=typeof t)throw new TypeError(f);return r(i)&&(o="leading"in i?!!i.leading:o,a="trailing"in i?!!i.trailing:a),n(t,e,{leading:o,maxWait:e,trailing:a})},j=function(t,e){for(var n in t)if(!(n in e))return!0;for(var r in e)if(t[r]!==e[r])return!0;return!1},P=function(t){var e=t.fallbackWidth,n=void 0===e?null:e,r=t.fallbackHeight,i=void 0===r?null:r,o="undefined"!=typeof window;return{width:o?window.innerWidth:n,height:o?window.innerHeight:i,canUseDOM:o}},S=function(){};S.thatReturns=o,S.thatReturnsFalse=o(!1),S.thatReturnsTrue=o(!0),S.thatReturnsNull=o(null),S.thatReturnsThis=function(){return this},S.thatReturnsArgument=function(t){return t};var _=S,x=function(t,e,n,r,i,o,a,u){if(!t){var f;if(void 0===e)f=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,o,a,u],s=0;(f=Error(e.replace(/%s/g,function(){return c[s++]}))).name="Invariant Violation"}throw f.framesToPop=1,f}},z="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",W=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){t.exports=function(){function t(t,e,n,r,i,o){o!==z&&x(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e};return n.checkPropTypes=_,n.PropTypes=n,n}()}),E=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},R=function(){function t(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),C=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},D=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},M=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},A="_ReactSizesConfig_",F=C({},A,W.shape({fallbackWidth:W.number,fallbackHeight:W.number,throttle:W.number})),N=function(t){return 480>t.width},I=function(t){return t.width>=1024},U=function(t){return!I(t)},L=Object.freeze({isMobile:N,isTablet:function(t){var e=t.width;return e>=480&&1024>e},isDesktop:I,isGtMobile:function(t){return!N(t)},isGtTablet:function(t){return I(t)},isStTablet:function(t){return N(t)},isStDesktop:U,isTabletAndGreater:function(t){return!N(t)},isTabletAndSmaller:function(t){return!U(t)}}),$=Object.assign(function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return function(t){var r,i,o=function(t,e){return n.map(function(n){return n(t,e)}).reduce(function(t,e){return D({},t,e)},{})};return i=r=function(n){function r(t,e){E(this,r);var n=M(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e));return n.dispatchSizes=function(){var t=n.getPropsToPass();j(t,n.state.propsToPass)&&n.setState({propsToPass:t})},n.throttledDispatchSizes=k(n.dispatchSizes,(n.context[A]||{}).throttle||200),n.getWindowSizesWithFallback=function(){var t=n.context[A]||{},e=t.fallbackHeight,r=t.fallbackWidth;return P({fallbackHeight:void 0===e?null:e,fallbackWidth:void 0===r?null:r})},n.getPropsToPass=function(){return o(n.getWindowSizesWithFallback(),n.props)},n.state={initialSizes:n.getWindowSizesWithFallback(),propsToPass:n.getPropsToPass()},n}return H(r,e.Component),R(r,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.throttledDispatchSizes),this.dispatchSizes()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.throttledDispatchSizes)}},{key:"render",value:function(){return a.createElement(t,D({},this.props,this.state.propsToPass))}}]),r}(),r.displayName="withSizes("+(t.displayName||t.name||("string"==typeof t&&t.length>0?t:"Unknown"))+")",r.contextTypes=F,i}},D({},L)),G=function(t){function n(){return E(this,n),M(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return H(n,e.Component),R(n,[{key:"getChildContext",value:function(){var t=this.props.config,e=void 0===t?{}:t;return C({},A,{fallbackWidth:e.fallbackWidth||null,fallbackHeight:e.fallbackHeight||null,throttle:e.throttle||200})}},{key:"render",value:function(){return this.props.children}}]),n}();G.childContextTypes=F;var q=function(t){var e=t.children,n=t.render,r=function(t,e){var n={};for(var r in t)0>e.indexOf(r)&&Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}(t,["children","render"]),i=e||n;return i?i(r):null};t.withSizes=$,t.SizesProvider=G,t.createSizedComponent=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return $(e)(q)},t.presets=L,t.default=$,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -81,3 +81,3 @@ 'use strict';

_this.throttledDispatchSizes = (0, _lodash2.default)(_this.dispatchSizes, _this.context.throttle || 200);
_this.throttledDispatchSizes = (0, _lodash2.default)(_this.dispatchSizes, (_this.context[_contextTypes.contextKey] || {}).throttle || 200);

@@ -84,0 +84,0 @@

@@ -81,3 +81,3 @@ 'use strict';

_this.throttledDispatchSizes = (0, _lodash2.default)(_this.dispatchSizes, _this.context.throttle || 200);
_this.throttledDispatchSizes = (0, _lodash2.default)(_this.dispatchSizes, (_this.context[_contextTypes.contextKey] || {}).throttle || 200);

@@ -84,0 +84,0 @@

{
"name": "react-sizes",
"version": "1.0.3",
"version": "1.0.4",
"description": "Hoc to easily map window sizes to props.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -57,3 +57,3 @@ /* eslint-disable no-console */

this.dispatchSizes,
this.context.throttle || 200
(this.context[contextKey] || {}).throttle || 200
)

@@ -60,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc