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.1 to 1.0.2

dist/react-sizes.js

2

dist/react-sizes.min.js

@@ -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";var n="default"in e?e.default:e,r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i="Expected a function",o=NaN,a="[object Symbol]",u=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,p="object"==typeof self&&self&&self.Object===Object&&self,d="object"==typeof r&&r&&r.Object===Object&&r||p||Function("return this")(),h=Object.prototype.toString,b=Math.max,v=Math.min,y=function(){return d.Date.now()};function g(t,e,n){var r,o,a,u,f,c,s=0,l=!1,p=!1,d=!0;if("function"!=typeof t)throw new TypeError(i);function h(e){var n=r,i=o;return r=o=void 0,s=e,u=t.apply(i,n)}function g(t){var n=t-c;return void 0===c||n>=e||0>n||p&&t-s>=a}function O(){var t,n,r=y();if(g(r))return T(r);f=setTimeout(O,(n=e-((t=r)-c),p?v(n,a-(t-s)):n))}function T(t){return f=void 0,d&&r?h(t):(r=o=void 0,u)}function k(){var t,n=y(),i=g(n);if(r=arguments,o=this,c=n,i){if(void 0===f)return s=t=c,f=setTimeout(O,e),l?h(t):u;if(p)return f=setTimeout(O,e),h(c)}return void 0===f&&(f=setTimeout(O,e)),u}return e=w(e)||0,m(n)&&(l=!!n.leading,a=(p="maxWait"in n)?b(w(n.maxWait)||0,e):a,d="trailing"in n?!!n.trailing:d),k.cancel=function(){void 0!==f&&clearTimeout(f),s=0,r=c=o=f=void 0},k.flush=function(){return void 0===f?u:T(y())},k}function m(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function w(t){if("number"==typeof t)return t;if("symbol"==typeof(e=t)||(n=e)&&"object"==typeof n&&h.call(e)==a)return o;var e,n;if(m(t)){var r="function"==typeof t.valueOf?t.valueOf():t;t=m(r)?r+"":r}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(u,"");var i=c.test(t);return i||s.test(t)?l(t.slice(2),i?2:8):f.test(t)?o:+t}var O=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new TypeError(i);return m(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),g(t,e,{leading:r,maxWait:e,trailing:o})},T=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},k=function(t){var e=t.fallbackWidth,n=t.fallbackHeight,r="undefined"!=typeof window;return{width:r?window.innerWidth:void 0===e?null:e,height:r?window.innerHeight:void 0===n?null:n,canUseDOM:r}};function S(t){return function(){return t}}var j=function(){};j.thatReturns=S,j.thatReturnsFalse=S(!1),j.thatReturnsTrue=S(!0),j.thatReturnsNull=S(null),j.thatReturnsThis=function(){return this},j.thatReturnsArgument=function(t){return t};var P=j;var _,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){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=P,n.PropTypes=n,n}()}(_={exports:{}},_.exports),_.exports),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}}(),D=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},C=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},M=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)},H=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=D({},A,W.shape({fallbackWidth:W.number,fallbackHeight:W.number,throttle:W.number})),N=function(t){return 480>t.width},U=function(t){return t.width>=1024},I=function(t){return!U(t)},L=Object.freeze({isMobile:N,isTablet:function(t){var e=t.width;return e>=480&&1024>e},isDesktop:U,isGtMobile:function(t){return!N(t)},isGtTablet:function(t){return U(t)},isStTablet:function(t){return N(t)},isStDesktop:I,isTabletAndGreater:function(t){return!N(t)},isTabletAndSmaller:function(t){return!I(t)}}),$=Object.assign(function(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];return function(t){var i,o,a,u=function(t,e){return r.map(function(n){return n(t,e)}).reduce(function(t,e){return C({},t,e)},{})};return o=i=function(r){function i(t,e){E(this,i);var n=H(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.dispatchSizes=function(){var t=n.getPropsToPass();T(t,n.state.propsToPass)&&n.setState({propsToPass:t})},n.throttledDispatchSizes=O(n.dispatchSizes,n.context.throttle||200),n.getWindowSizesWithFallback=function(){var t=n.context[A]||{},e=t.fallbackHeight,r=t.fallbackWidth;return k({fallbackHeight:void 0===e?null:e,fallbackWidth:void 0===r?null:r})},n.getPropsToPass=function(){return u(n.getWindowSizesWithFallback(),n.props)},n.state={initialSizes:n.getWindowSizesWithFallback(),propsToPass:n.getPropsToPass()},n}return M(i,e.Component),R(i,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.throttledDispatchSizes),this.state.initialSizes.canUseDOM||this.dispatchSizes()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.throttledDispatchSizes)}},{key:"render",value:function(){return n.createElement(t,C({},this.props,this.state.propsToPass))}}]),i}(),i.displayName="withSizes("+((a=t).displayName||a.name||("string"==typeof a&&a.length>0?a:"Unknown"))+")",i.contextTypes=F,o}},C({},L)),G=function(t){function n(){return E(this,n),H(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return M(n,e.Component),R(n,[{key:"getChildContext",value:function(){var t=this.props.config,e=void 0===t?{}:t;return D({},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})},S=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},j=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}},P=function(){};P.thatReturns=o,P.thatReturnsFalse=o(!1),P.thatReturnsTrue=o(!0),P.thatReturnsNull=o(null),P.thatReturnsThis=function(){return this},P.thatReturnsArgument=function(t){return t};var _=P,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}}(),D=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},C=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},M=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)},H=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=D({},A,W.shape({fallbackWidth:W.number,fallbackHeight:W.number,throttle:W.number})),N=function(t){return 480>t.width},U=function(t){return t.width>=1024},I=function(t){return!U(t)},L=Object.freeze({isMobile:N,isTablet:function(t){var e=t.width;return e>=480&&1024>e},isDesktop:U,isGtMobile:function(t){return!N(t)},isGtTablet:function(t){return U(t)},isStTablet:function(t){return N(t)},isStDesktop:I,isTabletAndGreater:function(t){return!N(t)},isTabletAndSmaller:function(t){return!I(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 C({},t,e)},{})};return i=r=function(n){function r(t,e){E(this,r);var n=H(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e));return n.dispatchSizes=function(){var t=n.getPropsToPass();S(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 j({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 M(r,e.Component),R(r,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.throttledDispatchSizes),this.state.initialSizes.canUseDOM||this.dispatchSizes()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.throttledDispatchSizes)}},{key:"render",value:function(){return a.createElement(t,C({},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}},C({},L)),G=function(t){function n(){return E(this,n),H(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return M(n,e.Component),R(n,[{key:"getChildContext",value:function(){var t=this.props.config,e=void 0===t?{}:t;return D({},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})});
{
"name": "react-sizes",
"version": "1.0.1",
"version": "1.0.2",
"description": "Hoc to easily map window sizes to props.",

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

"files": [
"dist",
"lib",
"es",
"src"

@@ -30,0 +32,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