Socket
Socket
Sign inDemoInstall

react-router-magic

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router-magic - npm Package Compare versions

Comparing version 0.3.4 to 0.4.1

2

lib/index.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],e):"object"==typeof exports?exports.ReactRouterMagic=e(require("react"),require("prop-types")):t.ReactRouterMagic=e(t.React,t.PropTypes)}(this,function(t,e){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=14)}([function(e,r){e.exports=t},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Store=function(){function t(t){this.listeners=[],this.state=t,this.subscribe=this.subscribe.bind(this)}return t.prototype.setState=function(t){return this.state=t,this.broadcast(this.state),this},t.prototype.broadcast=function(t){this.listeners.forEach(function(e){return e(t)})},t.prototype.getState=function(){return this.state},t.prototype.subscribe=function(t){var e=this;return this.listeners.push(t),function(){var r=e.listeners.indexOf(t);r>-1&&e.listeners.splice(r,1)}},t}()},function(t,r){t.exports=e},function(t,e,r){"use strict";function o(t,e){return i(t)?t(e.location,e.match):t}function n(t,e,r){return!1===e["switch"]&&t.switchIndex!==undefined&&console.warn("You should not set switchIndex props yourself"),e["switch"]&&t.switchIndex===undefined&&console.warn("Error: Switch children are supposed to have switchIndex passed from parent"),(!e["switch"]||t.switchIndex===undefined||e["switch"].matchIndex===t.switchIndex)&&r}Object.defineProperty(e,"__esModule",{value:!0});var i=r(7);e.execValOrFunc=o,e.checkSwitchState=n},function(t,e,r){function o(t){return null===t||t===undefined}function n(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&(0>=t.length||"number"==typeof t[0]))}function i(t,e,r){var i,a;if(o(t)||o(e))return!1;if(t.prototype!==e.prototype)return!1;if(s(t))return!!s(e)&&(t=c.call(t),e=c.call(e),p(t,e,r));if(n(t)){if(!n(e))return!1;if(t.length!==e.length)return!1;for(i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}try{var h=u(t),f=u(e)}catch(l){return!1}if(h.length!=f.length)return!1;for(h.sort(),f.sort(),i=h.length-1;i>=0;i--)if(h[i]!=f[i])return!1;for(i=h.length-1;i>=0;i--)if(a=h[i],!p(t[a],e[a],r))return!1;return typeof t==typeof e}var c=Array.prototype.slice,u=r(13),s=r(12),p=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?r.strict?t===e:t==e:i(t,e,r))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(1),u=r(3),s=r(8),p=function(t){function e(e,r){var o=t.call(this,e,r)||this;return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.update(t.props)})),this.update(this.props)},e.prototype.componentWillReceiveProps=function(t){this.update(t)},e.prototype.render=function(){return null},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.update=function(t){var e=this.context.router.history,r=this.context.routerStore.getState(),o=u.checkSwitchState(t,r,u.execValOrFunc(this.props.match,r)),n=!0===this.props.push;if(!1!==o){var i=u.execValOrFunc(this.props.to,r),c=s(i)?{pathname:i}:i;n?e.push(c):e.replace(c)}},e}(n.Component);p.displayName="Redirect",p.contextTypes={routerStore:i.instanceOf(c.Store),router:i.any},e.Redirect=p},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(7),u=r(4),s=r(0),p=r(1),a=r(3),h=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.matchResult=null,!r.routerStore||!r.routerStore.getState())throw Error("Route need a RouterProvider as ancestor");var n=r.routerStore.getState();return o.matchResult=a.execValOrFunc(e.match,n),!0!==e.passif&&(o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)})),o}return o(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props,e=t.component,r=t.render,o=t.children,i={match:this.matchResult,location:this.context.routerStore.getState().location};return e?!1!==this.matchResult?n.createElement(e,i):null:r?!1!==this.matchResult?r(i):null:c(o)?o(i):o?n.Children.only(o):null},e.prototype.update=function(t,e){void 0===e&&(e=!0);var r=this.context.routerStore.getState();this.matchResult=a.execValOrFunc(t.match,r),this.matchResult=a.checkSwitchState(t,r,this.matchResult);var o={location:r.location,match:this.matchResult,"switch":!1};this.routerStore?u(this.routerStore.getState(),o)||(this.routerStore.setState(o),e&&this.forceUpdate()):(this.routerStore=new p.Store(o),e&&this.forceUpdate())},e}(s.Component);h.displayName="Route",h.childContextTypes={routerStore:i.instanceOf(p.Store)},h.contextTypes={routerStore:i.instanceOf(p.Store)},e.Route=h},function(t,e){function r(t){var e=o(t)?u.call(t):"";return e==n||e==i}function o(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}var n="[object Function]",i="[object GeneratorFunction]",c=Object.prototype,u=c.toString;t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}function o(t){return"string"==typeof t||!u(t)&&r(t)&&c.call(t)==n}var n="[object String]",i=Object.prototype,c=i.toString,u=Array.isArray;t.exports=o},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),n=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(t);o.length>n;n++)0>e.indexOf(o[n])&&(r[o[n]]=t[o[n]]);return r};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(1),u=r(2),s=r(3),p=r(8),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.forceUpdate()}))},e.prototype.componentWillReceiveProps=function(t){var e=this;this.props.noSubscribe!==t.noSubscribe&&(t.noSubscribe&&this.unsubscribe?this.unsubscribe():this.unsubscribe=this.context.routerStore.subscribe(function(){e.forceUpdate()}))},e.prototype.render=function(){var t=this,e=this.props,r=e.renderChild,o=n(e,["renderChild"]),i=this.context.routerStore.getState(),c=s.execValOrFunc(o.isActive,i),u=s.execValOrFunc(o.to,i);return r({href:this.context.router.history.createHref(p(u)?{pathname:u}:u),navigate:function(){return t.navigate()},match:c,location:i.location,handleAnchorClick:function(e){return t.handleAnchorClick(e)}})},e.prototype.navigate=function(){var t=this.props.replace,e=void 0!==t&&t,r=this.context.routerStore.getState(),o=s.execValOrFunc(this.props.to,r),n=p(o)?{pathname:o}:o,i=this.context.router.history;e?i.replace(n):i.push(n)},e.prototype.isModifiedEvent=function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)},e.prototype.handleAnchorClick=function(t,e){t.defaultPrevented||0!==t.button||e||this.isModifiedEvent(t)||(t.preventDefault(),this.navigate())},e}(i.Component);a.displayName="NavProvider",a.contextTypes={routerStore:u.instanceOf(c.Store),router:u.any},e.NavProvider=a},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(4),u=r(0),s=r(1),p=function(t){function e(e){var r=t.call(this,e)||this;return r.routerStore=new s.Store({location:e.location,match:null,"switch":!1}),r}return o(e,t),e.prototype.componentWillReceiveProps=function(t){c(t.location,this.props.location)||this.routerStore.setState({location:t.location,match:null,"switch":!1})},e.prototype.getChildContext=function(){return{router:{history:this.props.history},routerStore:this.routerStore}},e.prototype.render=function(){return n.Children.only(this.props.children)},e}(u.Component);p.displayName="RouterProvider",p.childContextTypes={routerStore:i.instanceOf(s.Store),router:i.any},e.RouterProvider=p},function(t,e,r){"use strict";function o(t,e){return t.type===e}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(0),u=r(2),s=r(1),p=r(6),a=r(5),h=r(3),f=r(4),l=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.validChildren=[],!r.routerStore||!r.routerStore.getState())throw Error("Route need a RouterProvider as ancestor");return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o.update(e,!1),o}return n(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.render=function(){return i.createElement("div",null,i.Children.toArray(this.validChildren.map(function(t,e){return i.cloneElement(t,{switchIndex:e})})))},e.prototype.updateValidChildren=function(t){var e=this;this.validChildren=[],i.Children.forEach(t.children,function(t){i.isValidElement(t)&&(o(t,p.Route)||o(t,a.Redirect)?e.validChildren.push(t):console.warn("Switch only accept Route or Redirect components as children"))})},e.prototype.update=function(t,e){void 0===e&&(e=!0),this.updateValidChildren(t);var r=this.context.routerStore.getState(),o=null,n=null;this.validChildren.forEach(function(t,e){if(null===n){var i=h.execValOrFunc(t.props,r);!1!==i&&(o=i,n=e)}});var i={location:r.location,match:r.match,"switch":{match:o,matchIndex:n}};this.routerStore?f(this.routerStore.getState(),i)||(this.routerStore.setState(i),e&&this.forceUpdate()):(this.routerStore=new s.Store(i),e&&this.forceUpdate())},e}(c.Component);l.displayName="Switch",l.childContextTypes={routerStore:u.instanceOf(s.Store)},l.contextTypes={routerStore:u.instanceOf(s.Store)},e.Switch=l},function(t,e){function r(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}e=t.exports="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}()?r:o,e.supported=r,e.unsupported=o},function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:r,e.shim=r},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Route=r(6).Route,e.Switch=r(11).Switch,e.NavProvider=r(9).NavProvider,e.RouterProvider=r(10).RouterProvider,e.Redirect=r(5).Redirect}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],e):"object"==typeof exports?exports.ReactRouterMagic=e(require("react"),require("prop-types")):t.ReactRouterMagic=e(t.React,t.PropTypes)}(this,function(t,e){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=14)}([function(e,r){e.exports=t},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Store=function(){function t(t){this.listeners=[],this.state=t,this.subscribe=this.subscribe.bind(this)}return t.prototype.setState=function(t){return this.state=t,this.broadcast(this.state),this},t.prototype.broadcast=function(t){this.listeners.forEach(function(e){return e(t)})},t.prototype.getState=function(){return this.state},t.prototype.subscribe=function(t){var e=this;return this.listeners.push(t),function(){var r=e.listeners.indexOf(t);r>-1&&e.listeners.splice(r,1)}},t}()},function(t,r){t.exports=e},function(t,e,r){"use strict";function o(t,e){return i(t)?t(e.location,e.match):t}function n(t,e,r){return!1===e["switch"]&&t.switchIndex!==undefined&&console.warn("You should not set switchIndex props yourself"),e["switch"]&&t.switchIndex===undefined&&console.warn("Error: Switch children are supposed to have switchIndex passed from parent"),(!e["switch"]||!1!==e["switch"].matchIndex)&&((!e["switch"]||t.switchIndex===undefined||e["switch"].matchIndex===t.switchIndex)&&r)}Object.defineProperty(e,"__esModule",{value:!0});var i=r(7);e.execValOrFunc=o,e.checkSwitchState=n},function(t,e,r){function o(t){return null===t||t===undefined}function n(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&(0>=t.length||"number"==typeof t[0]))}function i(t,e,r){var i,a;if(o(t)||o(e))return!1;if(t.prototype!==e.prototype)return!1;if(s(t))return!!s(e)&&(t=c.call(t),e=c.call(e),p(t,e,r));if(n(t)){if(!n(e))return!1;if(t.length!==e.length)return!1;for(i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}try{var h=u(t),f=u(e)}catch(l){return!1}if(h.length!=f.length)return!1;for(h.sort(),f.sort(),i=h.length-1;i>=0;i--)if(h[i]!=f[i])return!1;for(i=h.length-1;i>=0;i--)if(a=h[i],!p(t[a],e[a],r))return!1;return typeof t==typeof e}var c=Array.prototype.slice,u=r(13),s=r(12),p=t.exports=function(t,e,r){return r||(r={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?r.strict?t===e:t==e:i(t,e,r))}},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(1),u=r(3),s=r(8),p=function(t){function e(e,r){var o=t.call(this,e,r)||this;return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.update(t.props)})),this.update(this.props)},e.prototype.componentWillReceiveProps=function(t){this.update(t)},e.prototype.render=function(){return null},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.update=function(t){var e=this.context.router.history,r=this.context.routerStore.getState(),o=u.checkSwitchState(t,r,u.execValOrFunc(this.props.match,r)),n=!0===this.props.push;if(!1!==o){var i=u.execValOrFunc(this.props.to,r),c=s(i)?{pathname:i}:i;n?e.push(c):e.replace(c)}},e}(n.Component);p.displayName="Redirect",p.contextTypes={routerStore:i.instanceOf(c.Store),router:i.any},e.Redirect=p},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(7),u=r(4),s=r(0),p=r(1),a=r(3),h=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.matchResult=null,!r.routerStore||!r.routerStore.getState())throw Error("Route need a RouterProvider as ancestor");var n=r.routerStore.getState();return o.matchResult=a.execValOrFunc(e.match,n),!0!==e.passif&&(o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)})),o.update(o.props,!1),o}return o(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.componentWillUnmount=function(){this.unsubscribe&&this.unsubscribe()},e.prototype.render=function(){var t=this.props,e=t.component,r=t.render,o=t.children,i={match:this.matchResult,location:this.context.routerStore.getState().location};return e?!1!==this.matchResult?n.createElement(e,i):null:r?!1!==this.matchResult?r(i):null:c(o)?o(i):o?n.Children.only(o):null},e.prototype.update=function(t,e){void 0===e&&(e=!0);var r=this.context.routerStore.getState();this.matchResult=a.execValOrFunc(t.match,r),this.matchResult=a.checkSwitchState(t,r,this.matchResult);var o={location:r.location,match:this.matchResult,"switch":!1};this.routerStore?u(this.routerStore.getState(),o)||(this.routerStore.setState(o),e&&this.forceUpdate()):(this.routerStore=new p.Store(o),e&&this.forceUpdate())},e}(s.Component);h.displayName="Route",h.childContextTypes={routerStore:i.instanceOf(p.Store)},h.contextTypes={routerStore:i.instanceOf(p.Store)},e.Route=h},function(t,e){function r(t){var e=o(t)?u.call(t):"";return e==n||e==i}function o(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}var n="[object Function]",i="[object GeneratorFunction]",c=Object.prototype,u=c.toString;t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}function o(t){return"string"==typeof t||!u(t)&&r(t)&&c.call(t)==n}var n="[object String]",i=Object.prototype,c=i.toString,u=Array.isArray;t.exports=o},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),n=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(t);o.length>n;n++)0>e.indexOf(o[n])&&(r[o[n]]=t[o[n]]);return r};Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(1),u=r(2),s=r(3),p=r(8),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.componentDidMount=function(){var t=this;!0!==this.props.noSubscribe&&(this.unsubscribe=this.context.routerStore.subscribe(function(){t.forceUpdate()}))},e.prototype.componentWillReceiveProps=function(t){var e=this;this.props.noSubscribe!==t.noSubscribe&&(t.noSubscribe&&this.unsubscribe?this.unsubscribe():this.unsubscribe=this.context.routerStore.subscribe(function(){e.forceUpdate()}))},e.prototype.render=function(){var t=this,e=this.props,r=e.renderChild,o=n(e,["renderChild"]),i=this.context.routerStore.getState(),c=s.execValOrFunc(o.isActive,i),u=s.execValOrFunc(o.to,i);return r({href:this.context.router.history.createHref(p(u)?{pathname:u}:u),navigate:function(){return t.navigate()},match:c,location:i.location,handleAnchorClick:function(e){return t.handleAnchorClick(e)}})},e.prototype.navigate=function(){var t=this.props.replace,e=void 0!==t&&t,r=this.context.routerStore.getState(),o=s.execValOrFunc(this.props.to,r),n=p(o)?{pathname:o}:o,i=this.context.router.history;e?i.replace(n):i.push(n)},e.prototype.isModifiedEvent=function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)},e.prototype.handleAnchorClick=function(t,e){t.defaultPrevented||0!==t.button||e||this.isModifiedEvent(t)||(t.preventDefault(),this.navigate())},e}(i.Component);a.displayName="NavProvider",a.contextTypes={routerStore:u.instanceOf(c.Store),router:u.any},e.NavProvider=a},function(t,e,r){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),i=r(2),c=r(4),u=r(0),s=r(1),p=function(t){function e(e){var r=t.call(this,e)||this;return r.routerStore=new s.Store({location:e.location,match:null,"switch":!1}),r}return o(e,t),e.prototype.componentWillReceiveProps=function(t){c(t.location,this.props.location)||this.routerStore.setState({location:t.location,match:null,"switch":!1})},e.prototype.getChildContext=function(){return{router:{history:this.props.history},routerStore:this.routerStore}},e.prototype.render=function(){return n.Children.only(this.props.children)},e}(u.Component);p.displayName="RouterProvider",p.childContextTypes={routerStore:i.instanceOf(s.Store),router:i.any},e.RouterProvider=p},function(t,e,r){"use strict";function o(t,e){return t.type===e}var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),c=r(0),u=r(2),s=r(1),p=r(6),a=r(5),h=r(3),f=r(4),l=function(t){function e(e,r){var o=t.call(this,e,r)||this;if(o.validChildren=[],!r.routerStore||!r.routerStore.getState())throw Error("Switch need a RouterProvider as ancestor");return o.unsubscribe=r.routerStore.subscribe(function(){o.update(o.props)}),o.update(e,!1),o}return n(e,t),e.prototype.getChildContext=function(){return{routerStore:this.routerStore}},e.prototype.componentWillReceiveProps=function(t){this.update(t,!1)},e.prototype.render=function(){return i.createElement("div",null,i.Children.toArray(this.validChildren.map(function(t,e){return i.cloneElement(t,{switchIndex:e})})))},e.prototype.updateValidChildren=function(t){var e=this;this.validChildren=[],i.Children.forEach(t.children,function(t){i.isValidElement(t)&&(o(t,p.Route)||o(t,a.Redirect)?e.validChildren.push(t):console.warn("Switch only accept Route or Redirect components as children"))})},e.prototype.update=function(t,e){void 0===e&&(e=!0),this.updateValidChildren(t);var r=this.context.routerStore.getState(),o=null,n=!1;this.validChildren.forEach(function(t,e){if(!1===n){var i=h.execValOrFunc(t.props.match,r);!1!==i&&(o=i,n=e)}});var i={location:r.location,match:r.match,"switch":{match:o,matchIndex:n}};this.routerStore?f(this.routerStore.getState(),i)||(this.routerStore.setState(i),e&&this.forceUpdate()):(this.routerStore=new s.Store(i),e&&this.forceUpdate())},e}(c.Component);l.displayName="Switch",l.childContextTypes={routerStore:u.instanceOf(s.Store)},l.contextTypes={routerStore:u.instanceOf(s.Store)},e.Switch=l},function(t,e){function r(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}e=t.exports="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}()?r:o,e.supported=r,e.unsupported=o},function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}e=t.exports="function"==typeof Object.keys?Object.keys:r,e.shim=r},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Route=r(6).Route,e.Switch=r(11).Switch,e.NavProvider=r(9).NavProvider,e.RouterProvider=r(10).RouterProvider,e.Redirect=r(5).Redirect}])});
//# sourceMappingURL=index.js.map

@@ -11,3 +11,3 @@ /// <reference types="react" />

match: Match;
matchIndex: number | null;
matchIndex: number | false;
};

@@ -14,0 +14,0 @@ };

@@ -7,3 +7,3 @@ import { RouterStoreState } from './RouterProvider';

export declare function checkSwitchState(props: {
switchIndex?: number;
switchIndex?: number | false;
}, parentRouterState: RouterStoreState, match: Match): Match;
{
"name": "react-router-magic",
"version": "0.3.4",
"version": "0.4.1",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -20,3 +20,3 @@ import isFunction = require('lodash.isfunction');

export function checkSwitchState(
props: { switchIndex?: number },
props: { switchIndex?: number | false },
parentRouterState: RouterStoreState,

@@ -33,2 +33,8 @@ match: Match,

parentRouterState.switch &&
parentRouterState.switch.matchIndex === false
) {
return false;
}
if (
parentRouterState.switch &&
props.switchIndex !== undefined &&

@@ -35,0 +41,0 @@ parentRouterState.switch.matchIndex !== props.switchIndex

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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