redux-responsive
Advanced tools
11
index.js
@@ -349,3 +349,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
// return the new type if the query matches otherwise the previous one | ||
return matchMedia(mediaQueries[query]).matches ? mediaQueries[query] : result; | ||
return matchMedia(mediaQueries[query]).matches ? query : result; | ||
// use the default orientation | ||
@@ -547,5 +547,5 @@ }, defaultOrientation); | ||
// the function to call when calculating the new responsive state | ||
function refreshResponsiveState() { | ||
store.dispatch(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__actions_creators__["a" /* calculateResponsiveState */])(window)); | ||
} | ||
var refreshResponsiveState = function refreshResponsiveState() { | ||
return store.dispatch(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__actions_creators__["a" /* calculateResponsiveState */])(window)); | ||
}; | ||
@@ -572,2 +572,5 @@ // get the object of media queries corresponding to the breakpoints in the store | ||
// make sure we update the responsive state when the browser changes orientation | ||
window.addEventListener('orientationchange', refreshResponsiveState); | ||
// if we are supposed to calculate the initial state | ||
@@ -574,0 +577,0 @@ if (calculateInitialState) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["redux-responsive"]=t():e["redux-responsive"]=t()}(this,function(){return function(e){function __webpack_require__(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r.exports}var t={};return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.i=function(e){return e},__webpack_require__.d=function(e,t,n){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=8)}([function(e,t,n){"use strict";var r=n(7);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(2);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";t.a="redux-responsive/CALCULATE_RESPONSIVE_STATE"},function(e,t,n){e.exports=n(12)},,function(e,t,n){"use strict";var r=n(11);t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.calculateInitialState,i=void 0===t||t;return function(e){return function(){var t=e.apply(void 0,arguments);return"undefined"!=typeof window&&void 0!==window.matchMedia&&n.i(r.a)({store:t,window:window,calculateInitialState:i}),t}}}},function(e,t,n){"use strict";function getOrderMap(e){var t=Object.keys(e).sort(function(t,n){var r=e[t],i=e[n];return"number"==typeof r&&"string"==typeof i?-1:"number"==typeof i&&"string"==typeof r?1:r>=i?1:-1});return s(e,function(e,n,r){var i=t.indexOf(r);-1!==i&&(e[r]=i)})}function getLessThan(e,t){var n=t[e];return s(t,function(e,r,i){"number"==typeof r&&t[i]?e[i]=n<t[i]:e[i]=!1})}function getIs(e,t){return s(t,function(n,r,i){"number"==typeof r&&t[i]?n[i]=i===e:n[i]=!1})}function getGreaterThan(e,t){var n=t[e];return s(t,function(e,r,i){e[i]="number"==typeof r&&n>t[i]})}function getMediaType(e,t,n){return void 0===e?n:Object.keys(t).reduce(function(n,r){return e(t[r]).matches?r:n},n)}function getOrientation(e){if(void 0===e)return c;var t={portrait:"(orientation: portrait)",landscape:"(orientation: landscape)"};return Object.keys(t).reduce(function(n,r){return e(t[r]).matches?t[r]:n},c)}var r=n(3),i=n.n(r),o=n(2),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a={extraSmall:480,small:768,medium:992,large:1200},c=null,s=function(e,t){var n={};return Object.keys(e).forEach(function(r){return t(n,e[r],r)}),n};t.a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.initialMediaType,r=t.infinity,c=void 0===r?"infinity":r,s=t.extraFields,f=void 0===s?function(){return{}}:s;e||(e=a),e[c]=1/0;var p=i.a.asObject(e),_=getOrderMap(e);return function(t,r){var i=r.type,a=r.matchMedia;if(i===o.a||void 0===t){var s=!t&&n?n:getMediaType(a,p,c),d=getOrientation(a),v={_responsiveState:!0,lessThan:getLessThan(s,_),greaterThan:getGreaterThan(s,_),is:getIs(s,e),mediaType:s,orientation:d,breakpoints:e};return u({},v,f(v))}return t}}},function(e,t,n){"use strict";var r=n(1);t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.innerWidth,n=e.innerHeight,i=e.matchMedia;return{type:r.a,innerWidth:t,innerHeight:n,matchMedia:i}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),i=n(5),o=n(1);n.d(t,"CALCULATE_RESPONSIVE_STATE",function(){return o.a});var u=n(0);n.d(t,"calculateResponsiveState",function(){return u.a}),n.d(t,"createResponsiveStateReducer",function(){return a}),n.d(t,"createResponsiveStoreEnhancer",function(){return c}),n.d(t,"responsiveStateReducer",function(){return s}),n.d(t,"responsiveStoreEnhancer",function(){return f});var a=r.a,c=i.a,s=a(),f=c()},,function(e,t,n){"use strict";function getBreakpoints(e){var t=e.getState(),n=void 0;if(!(n=!0===t["@@__IMMUTABLE_ITERABLE__@@"]?t.findKey(function(e){return e._responsiveState}):Object.keys(t).reduce(function(e,n){return t[n]&&t[n]._responsiveState?n:e},!1)))throw new Error("Could not find responsive state reducer. Currently, redux-responsive can onlybe used if the responsive reducer is at the root of your reducer tree.If you are still running into trouble, please open a ticket on github.");return t["@@__IMMUTABLE_ITERABLE__@@"]?t.get(n).breakpoints:t[n].breakpoints}t.a=getBreakpoints},function(e,t,n){"use strict";var r=n(3),i=n.n(r),o=n(0),u=n(10);t.a=function(e){function refreshResponsiveState(){t.dispatch(n.i(o.a)(r))}var t=e.store,r=e.window,a=e.calculateInitialState,c=i.a.asObject(n.i(u.a)(t));Object.keys(c).forEach(function(e){r.matchMedia(c[e]).addListener(function(e){e.matches&&refreshResponsiveState()})}),a&&refreshResponsiveState()}},function(e,t,n){var r,i,o={asArray:function(e){var t=this.getBreakPoints(e),n=this.getCustomQueries(e);return this._translate(this._makeSteps(this._toSortedArray(t))).concat(this._objToArr(n))},asObject:function(e){return this._arrToObj(this.asArray(e))},getBreakPoints:function(e){return Object.keys(e).reduce(function(t,n){return"number"==typeof e[n]&&(t[n]=e[n]),t},{})},getCustomQueries:function(e){return Object.keys(e).reduce(function(t,n){return"string"==typeof e[n]&&(t[n]=e[n]),t},{})},_toSortedArray:function(e){return Object.keys(e).map(function(t){return[t,e[t]]}).sort(function(e,t){return e[1]-t[1]})},_makeSteps:function(e){return e[e.length-1][1]===1/0?e:e.concat([1/0])},_translate:function(e){return e.map(function(t,n){return 0===n?[t[0],"screen and (max-width: "+t[1]+"px)"]:n===e.length-1?[t[0]||"default","screen and (min-width: "+(e[n-1][1]+1)+"px)"]:[t[0],"screen and (min-width: "+(e[n-1][1]+1)+"px) and (max-width: "+t[1]+"px)"]})},_objToArr:function(e){return Object.keys(e).map(function(t){return[t,e[t]]})},_arrToObj:function(e){return e.reduce(function(e,t){return e[t[0]]=t[1],e},{})}};void 0!==e&&void 0!==e.exports?e.exports=o:(r=[],void 0!==(i=function(){return o}.apply(t,r))&&(e.exports=i))}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["redux-responsive"]=t():e["redux-responsive"]=t()}(this,function(){return function(e){function __webpack_require__(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r.exports}var t={};return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.i=function(e){return e},__webpack_require__.d=function(e,t,n){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=8)}([function(e,t,n){"use strict";var r=n(7);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(2);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";t.a="redux-responsive/CALCULATE_RESPONSIVE_STATE"},function(e,t,n){e.exports=n(12)},,function(e,t,n){"use strict";var r=n(11);t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.calculateInitialState,i=void 0===t||t;return function(e){return function(){var t=e.apply(void 0,arguments);return"undefined"!=typeof window&&void 0!==window.matchMedia&&n.i(r.a)({store:t,window:window,calculateInitialState:i}),t}}}},function(e,t,n){"use strict";function getOrderMap(e){var t=Object.keys(e).sort(function(t,n){var r=e[t],i=e[n];return"number"==typeof r&&"string"==typeof i?-1:"number"==typeof i&&"string"==typeof r?1:r>=i?1:-1});return s(e,function(e,n,r){var i=t.indexOf(r);-1!==i&&(e[r]=i)})}function getLessThan(e,t){var n=t[e];return s(t,function(e,r,i){"number"==typeof r&&t[i]?e[i]=n<t[i]:e[i]=!1})}function getIs(e,t){return s(t,function(n,r,i){"number"==typeof r&&t[i]?n[i]=i===e:n[i]=!1})}function getGreaterThan(e,t){var n=t[e];return s(t,function(e,r,i){e[i]="number"==typeof r&&n>t[i]})}function getMediaType(e,t,n){return void 0===e?n:Object.keys(t).reduce(function(n,r){return e(t[r]).matches?r:n},n)}function getOrientation(e){if(void 0===e)return c;var t={portrait:"(orientation: portrait)",landscape:"(orientation: landscape)"};return Object.keys(t).reduce(function(n,r){return e(t[r]).matches?r:n},c)}var r=n(3),i=n.n(r),o=n(2),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a={extraSmall:480,small:768,medium:992,large:1200},c=null,s=function(e,t){var n={};return Object.keys(e).forEach(function(r){return t(n,e[r],r)}),n};t.a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.initialMediaType,r=t.infinity,c=void 0===r?"infinity":r,s=t.extraFields,f=void 0===s?function(){return{}}:s;e||(e=a),e[c]=1/0;var d=i.a.asObject(e),p=getOrderMap(e);return function(t,r){var i=r.type,a=r.matchMedia;if(i===o.a||void 0===t){var s=!t&&n?n:getMediaType(a,d,c),_=getOrientation(a),v={_responsiveState:!0,lessThan:getLessThan(s,p),greaterThan:getGreaterThan(s,p),is:getIs(s,e),mediaType:s,orientation:_,breakpoints:e};return u({},v,f(v))}return t}}},function(e,t,n){"use strict";var r=n(1);t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.innerWidth,n=e.innerHeight,i=e.matchMedia;return{type:r.a,innerWidth:t,innerHeight:n,matchMedia:i}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),i=n(5),o=n(1);n.d(t,"CALCULATE_RESPONSIVE_STATE",function(){return o.a});var u=n(0);n.d(t,"calculateResponsiveState",function(){return u.a}),n.d(t,"createResponsiveStateReducer",function(){return a}),n.d(t,"createResponsiveStoreEnhancer",function(){return c}),n.d(t,"responsiveStateReducer",function(){return s}),n.d(t,"responsiveStoreEnhancer",function(){return f});var a=r.a,c=i.a,s=a(),f=c()},,function(e,t,n){"use strict";function getBreakpoints(e){var t=e.getState(),n=void 0;if(!(n=!0===t["@@__IMMUTABLE_ITERABLE__@@"]?t.findKey(function(e){return e._responsiveState}):Object.keys(t).reduce(function(e,n){return t[n]&&t[n]._responsiveState?n:e},!1)))throw new Error("Could not find responsive state reducer. Currently, redux-responsive can onlybe used if the responsive reducer is at the root of your reducer tree.If you are still running into trouble, please open a ticket on github.");return t["@@__IMMUTABLE_ITERABLE__@@"]?t.get(n).breakpoints:t[n].breakpoints}t.a=getBreakpoints},function(e,t,n){"use strict";var r=n(3),i=n.n(r),o=n(0),u=n(10);t.a=function(e){var t=e.store,r=e.window,a=e.calculateInitialState,c=function(){return t.dispatch(n.i(o.a)(r))},s=i.a.asObject(n.i(u.a)(t));Object.keys(s).forEach(function(e){r.matchMedia(s[e]).addListener(function(e){e.matches&&c()})}),r.addEventListener("orientationchange",c),a&&c()}},function(e,t,n){var r,i,o={asArray:function(e){var t=this.getBreakPoints(e),n=this.getCustomQueries(e);return this._translate(this._makeSteps(this._toSortedArray(t))).concat(this._objToArr(n))},asObject:function(e){return this._arrToObj(this.asArray(e))},getBreakPoints:function(e){return Object.keys(e).reduce(function(t,n){return"number"==typeof e[n]&&(t[n]=e[n]),t},{})},getCustomQueries:function(e){return Object.keys(e).reduce(function(t,n){return"string"==typeof e[n]&&(t[n]=e[n]),t},{})},_toSortedArray:function(e){return Object.keys(e).map(function(t){return[t,e[t]]}).sort(function(e,t){return e[1]-t[1]})},_makeSteps:function(e){return e[e.length-1][1]===1/0?e:e.concat([1/0])},_translate:function(e){return e.map(function(t,n){return 0===n?[t[0],"screen and (max-width: "+t[1]+"px)"]:n===e.length-1?[t[0]||"default","screen and (min-width: "+(e[n-1][1]+1)+"px)"]:[t[0],"screen and (min-width: "+(e[n-1][1]+1)+"px) and (max-width: "+t[1]+"px)"]})},_objToArr:function(e){return Object.keys(e).map(function(t){return[t,e[t]]})},_arrToObj:function(e){return e.reduce(function(e,t){return e[t[0]]=t[1],e},{})}};void 0!==e&&void 0!==e.exports?e.exports=o:(r=[],void 0!==(i=function(){return o}.apply(t,r))&&(e.exports=i))}])}); |
@@ -183,3 +183,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
// return the new type if the query matches otherwise the previous one | ||
return matchMedia(mediaQueries[query]).matches ? mediaQueries[query] : result; | ||
return matchMedia(mediaQueries[query]).matches ? query : result; | ||
// use the default orientation | ||
@@ -186,0 +186,0 @@ }, defaultOrientation); |
@@ -17,5 +17,5 @@ // see: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries | ||
// the function to call when calculating the new responsive state | ||
function refreshResponsiveState() { | ||
store.dispatch(calculateResponsiveState(window)); | ||
} | ||
var refreshResponsiveState = function refreshResponsiveState() { | ||
return store.dispatch(calculateResponsiveState(window)); | ||
}; | ||
@@ -42,2 +42,5 @@ // get the object of media queries corresponding to the breakpoints in the store | ||
// make sure we update the responsive state when the browser changes orientation | ||
window.addEventListener('orientationchange', refreshResponsiveState); | ||
// if we are supposed to calculate the initial state | ||
@@ -44,0 +47,0 @@ if (calculateInitialState) { |
{ | ||
"name": "redux-responsive", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "Utilities for easily creating responsive designs in a redux architecture.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -184,3 +184,3 @@ // third party imports | ||
// return the new type if the query matches otherwise the previous one | ||
return matchMedia(mediaQueries[query]).matches ? mediaQueries[query] : result | ||
return matchMedia(mediaQueries[query]).matches ? query : result | ||
// use the default orientation | ||
@@ -187,0 +187,0 @@ }, defaultOrientation) |
@@ -13,5 +13,3 @@ // see: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries | ||
// the function to call when calculating the new responsive state | ||
function refreshResponsiveState() { | ||
store.dispatch(calculateResponsiveState(window)) | ||
} | ||
const refreshResponsiveState = () => store.dispatch(calculateResponsiveState(window)) | ||
@@ -39,2 +37,5 @@ // get the object of media queries corresponding to the breakpoints in the store | ||
// make sure we update the responsive state when the browser changes orientation | ||
window.addEventListener('orientationchange', refreshResponsiveState) | ||
// if we are supposed to calculate the initial state | ||
@@ -41,0 +42,0 @@ if (calculateInitialState) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
188555
0.37%2800
0.14%0
-100%