Commit c5c99a13 by Wee

chore: bump devDependencies versions

parent 737c7402
es
dist
node_modules
umd
/*.js
......
import React from 'react'
import ReactDOM from 'react-dom'
import { createMemoryHistory as createHistory } from 'history'
import { MemoryRouter, Router, Route } from 'react-router'
import renderStrict from './utils/renderStrict'
import PropTypes from 'prop-types'
import { MemoryRouter, Route, Router } from 'react-router'
import { createMemoryHistory } from 'history'
describe('A <Route>', () => {
it('renders at the root', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
afterEach(() => {
ReactDOM.unmountComponentAtNode(node)
})
describe('without a <Router>', () => {
it('throws an error', () => {
jest.spyOn(console, 'error').mockImplementation(() => {})
ReactDOM.render(
<MemoryRouter initialEntries={['/']}>
<Route path="/" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(() => {
renderStrict(<Route />, node)
}).toThrow(/You should not use <Route> outside a <Router>/)
})
expect(node.innerHTML).toContain(TEXT)
})
it('renders when it matches', () => {
const text = 'cupcakes'
it('does not render when it does not match', () => {
const TEXT = 'bubblegum'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/cupcakes']}>
<Route path="/cupcakes" render={() => <h1>{text}</h1>} />
ReactDOM.render(
<MemoryRouter initialEntries={['/bunnies']}>
<Route path="/flowers" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
expect(node.innerHTML).not.toContain(TEXT)
})
it('renders when it matches at the root URL', () => {
const text = 'cupcakes'
it('can use a `location` prop instead of `context.router.route.location`', () => {
const TEXT = 'tamarind chutney'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/" render={() => <h1>{text}</h1>} />
ReactDOM.render(
<MemoryRouter initialEntries={['/mint']}>
<Route location={{ pathname: '/tamarind' }} path="/tamarind" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
expect(node.innerHTML).toContain(TEXT)
})
it('does not render when it does not match', () => {
const text = 'bubblegum'
it('supports preact by nulling out children prop when empty array is passed', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/bunnies']}>
<Route path="/flowers" render={() => <h1>{text}</h1>} />
ReactDOM.render(
<MemoryRouter initialEntries={['/']}>
<Route path="/" render={() => <h1>{TEXT}</h1>}>
{[]}
</Route>
</MemoryRouter>,
node
)
expect(node.innerHTML).not.toContain(text)
expect(node.innerHTML).toContain(TEXT)
})
it('matches using nextContext when updating', () => {
const history = createHistory({
initialEntries: ['/sushi/california']
})
const node = document.createElement('div')
renderStrict(
<Router history={history}>
<Route path="/sushi/:roll" render={({ match }) => <h1>{match.url}</h1>} />
</Router>,
let push
ReactDOM.render(
<MemoryRouter initialEntries={['/sushi/california']}>
<Route
path="/sushi/:roll"
render={({ history, match }) => {
push = history.push
return <div>{match.url}</div>
}}
/>
</MemoryRouter>,
node
)
push('/sushi/spicy-tuna')
expect(node.innerHTML).toContain('/sushi/spicy-tuna')
})
history.push('/sushi/spicy-tuna')
it('throws with no <Router>', () => {
const node = document.createElement('div')
expect(node.innerHTML).toContain('/sushi/spicy-tuna')
spyOn(console, 'error')
expect(() => {
ReactDOM.render(<Route path="/" render={() => null} />, node)
}).toThrow(/You should not use <Route> or withRouter\(\) outside a <Router>/)
})
})
describe('with dynamic segments in the path', () => {
describe('A <Route> with dynamic segments in the path', () => {
it('decodes them', () => {
renderStrict(
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/a%20dynamic%20segment']}>
<Route path="/:id" render={({ match }) => <h1>{match.params.id}</h1>} />
<Route path="/:id" render={({ match }) => <div>{match.params.id}</div>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain('a dynamic segment')
})
})
})
describe('with an array of paths', () => {
it('matches the first provided path', () => {
describe('A unicode <Route>', () => {
it('is able to match', () => {
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/hello']}>
<Route path={['/hello', '/world']} render={() => <div>Hello World</div>} />
<MemoryRouter initialEntries={['/パス名']}>
<Route path="/パス名" render={({ match }) => <div>{match.url}</div>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain('Hello World')
expect(node.innerHTML).toContain('/パス名')
})
})
it('matches other provided paths', () => {
describe('<Route render>', () => {
const history = createMemoryHistory()
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/other', '/world']} initialIndex={1}>
<Route path={['/hello', '/world']} render={() => <div>Hello World</div>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain('Hello World')
afterEach(() => {
ReactDOM.unmountComponentAtNode(node)
})
it('provides the matched path as a string', () => {
it('renders its return value', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/other', '/world']} initialIndex={1}>
<Route path={['/hello', '/world']} render={({ match }) => <div>{match.path}</div>} />
<MemoryRouter initialEntries={['/']}>
<Route path="/" render={() => <div>{TEXT}</div>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain('/world')
expect(node.innerHTML).toContain(TEXT)
})
it("doesn't remount when moving from one matching path to another", () => {
const node = document.createElement('div')
const history = createHistory()
const mount = jest.fn()
class MatchedRoute extends React.Component {
componentWillMount() {
mount()
}
it('receives { match, location, history } props', () => {
let actual = null
render() {
return <div>Hello World</div>
}
}
history.push('/hello')
ReactDOM.render(
<Router history={history}>
<Route path={['/hello', '/world']} component={MatchedRoute} />
<Route path="/" render={props => (actual = props) && null} />
</Router>,
node
)
expect(mount).toHaveBeenCalledTimes(1)
expect(node.innerHTML).toContain('Hello World')
history.push('/world/somewhere/else')
expect(mount).toHaveBeenCalledTimes(1)
expect(node.innerHTML).toContain('Hello World')
})
expect(actual.history).toBe(history)
expect(typeof actual.match).toBe('object')
expect(typeof actual.location).toBe('object')
})
})
describe('with a unicode path', () => {
it('is able to match', () => {
renderStrict(
<MemoryRouter initialEntries={['/パス名']}>
<Route path="/パス名" render={({ match }) => <h1>{match.url}</h1>} />
</MemoryRouter>,
node
)
describe('<Route component>', () => {
const history = createMemoryHistory()
const node = document.createElement('div')
expect(node.innerHTML).toContain('/パス名')
})
afterEach(() => {
ReactDOM.unmountComponentAtNode(node)
})
describe('with escaped special characters in the path', () => {
it('is able to match', () => {
renderStrict(
<MemoryRouter initialEntries={['/pizza (1)']}>
<Route path="/pizza \(1\)" render={({ match }) => <h1>{match.url}</h1>} />
it('renders the component', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
const Home = () => <div>{TEXT}</div>
ReactDOM.render(
<MemoryRouter initialEntries={['/']}>
<Route path="/" component={Home} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain('/pizza (1)')
})
expect(node.innerHTML).toContain(TEXT)
})
describe('with `exact=true`', () => {
it('renders when the URL does not have a trailing slash', () => {
const text = 'bubblegum'
it('receives { match, location, history } props', () => {
let actual = null
const Component = props => (actual = props) && null
renderStrict(
<MemoryRouter initialEntries={['/somepath/']}>
<Route exact path="/somepath" render={() => <h1>{text}</h1>} />
</MemoryRouter>,
ReactDOM.render(
<Router history={history}>
<Route path="/" component={Component} />
</Router>,
node
)
expect(node.innerHTML).toContain(text)
expect(actual.history).toBe(history)
expect(typeof actual.match).toBe('object')
expect(typeof actual.location).toBe('object')
})
})
it('renders when the URL has trailing slash', () => {
const text = 'bubblegum'
describe('<Route children>', () => {
const history = createMemoryHistory()
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/somepath']}>
<Route exact path="/somepath/" render={() => <h1>{text}</h1>} />
afterEach(() => {
ReactDOM.unmountComponentAtNode(node)
})
it('renders a function', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/']}>
<Route path="/" children={() => <div>{TEXT}</div>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
expect(node.innerHTML).toContain(TEXT)
})
describe('and `strict=true`', () => {
it('does not render when the URL has a trailing slash', () => {
const text = 'bubblegum'
renderStrict(
<MemoryRouter initialEntries={['/somepath/']}>
<Route exact strict path="/somepath" render={() => <h1>{text}</h1>} />
it('renders a child element', () => {
const TEXT = 'Mrs. Kato'
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/']}>
<Route path="/">
<div>{TEXT}</div>
</Route>
</MemoryRouter>,
node
)
expect(node.innerHTML).not.toContain(text)
expect(node.innerHTML).toContain(TEXT)
})
it('does not render when the URL does not have a trailing slash', () => {
const text = 'bubblegum'
it('receives { match, location, history } props', () => {
let actual = null
renderStrict(
<MemoryRouter initialEntries={['/somepath']}>
<Route exact strict path="/somepath/" render={() => <h1>{text}</h1>} />
</MemoryRouter>,
ReactDOM.render(
<Router history={history}>
<Route path="/" children={props => (actual = props) && null} />
</Router>,
node
)
expect(node.innerHTML).not.toContain(text)
})
})
expect(actual.history).toBe(history)
expect(typeof actual.match).toBe('object')
expect(typeof actual.location).toBe('object')
})
})
describe('the `location` prop', () => {
it('overrides `context.location`', () => {
const text = 'bubblegum'
describe('A <Route exact>', () => {
it('renders when the URL does not have a trailing slash', () => {
const TEXT = 'bubblegum'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/cupcakes']}>
<Route location={{ pathname: '/bubblegum' }} path="/bubblegum" render={() => <h1>{text}</h1>} />
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath/']}>
<Route exact path="/somepath" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
})
expect(node.innerHTML).toContain(TEXT)
})
describe('the `children` prop', () => {
describe('that is an element', () => {
it('renders', () => {
const text = 'bubblegum'
it('renders when the URL has trailing slash', () => {
const TEXT = 'bubblegum'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/">
<h1>{text}</h1>
</Route>
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath']}>
<Route exact path="/somepath/" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
})
expect(node.innerHTML).toContain(TEXT)
})
})
describe('that is a function', () => {
it('receives { history, location, match } props', () => {
const history = createHistory()
describe('A <Route exact strict>', () => {
it('does not render when the URL has a trailing slash', () => {
const TEXT = 'bubblegum'
const node = document.createElement('div')
let props = null
renderStrict(
<Router history={history}>
<Route
path="/"
children={p => {
props = p
return null
}}
/>
</Router>,
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath/']}>
<Route exact strict path="/somepath" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(props).not.toBe(null)
expect(props.history).toBe(history)
expect(typeof props.location).toBe('object')
expect(typeof props.match).toBe('object')
expect(node.innerHTML).not.toContain(TEXT)
})
it('renders', () => {
const text = 'bubblegum'
it('does not render when the URL does not have a trailing slash', () => {
const TEXT = 'bubblegum'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/" children={() => <h1>{text}</h1>} />
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath']}>
<Route exact strict path="/somepath/" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
expect(node.innerHTML).not.toContain(TEXT)
})
})
describe('that returns `undefined`', () => {
it('logs a warning to the console and renders nothing', () => {
jest.spyOn(console, 'warn').mockImplementation(() => {})
describe('A <Route location>', () => {
it('can use a `location` prop instead of `router.location`', () => {
const TEXT = 'tamarind chutney'
const node = document.createElement('div')
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/" children={() => undefined} />
ReactDOM.render(
<MemoryRouter initialEntries={['/mint']}>
<Route location={{ pathname: '/tamarind' }} path="/tamarind" render={() => <h1>{TEXT}</h1>} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toEqual('')
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining('You returned `undefined` from the `children` function')
)
})
})
expect(node.innerHTML).toContain(TEXT)
})
describe('that is an empty array (as in Preact)', () => {
it('ignores the children', () => {
const text = 'bubblegum'
describe('children', () => {
it("uses parent's prop location", () => {
const TEXT = 'cheddar pretzel'
const node = document.createElement('div')
renderStrict(
<MemoryRouter>
<Route render={() => <h1>{text}</h1>}>{[]}</Route>
ReactDOM.render(
<MemoryRouter initialEntries={['/popcorn']}>
<Route
location={{ pathname: '/pretzels/cheddar' }}
path="/pretzels"
render={() => <Route path="/pretzels/cheddar" render={() => <h1>{TEXT}</h1>} />}
/>
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
})
})
expect(node.innerHTML).toContain(TEXT)
})
describe('the `component` prop', () => {
it('renders the component', () => {
const text = 'bubblegum'
const Home = () => <h1>{text}</h1>
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/" component={Home} />
it("continues to use parent's prop location after navigation", () => {
const TEXT = 'cheddar pretzel'
const node = document.createElement('div')
let push
ReactDOM.render(
<MemoryRouter initialEntries={['/popcorn']}>
<Route
location={{ pathname: '/pretzels/cheddar' }}
path="/pretzels"
render={({ history }) => {
push = history.push
return <Route path="/pretzels/cheddar" render={() => <h1>{TEXT}</h1>} />
}}
/>
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
expect(node.innerHTML).toContain(TEXT)
push('/chips')
expect(node.innerHTML).toContain(TEXT)
})
})
})
it('receives { history, location, match } props', () => {
const history = createHistory()
let props = null
const Component = p => {
props = p
describe('A pathless <Route>', () => {
let rootContext
const ContextChecker = (props, context) => {
rootContext = context
return null
}
renderStrict(
<Router history={history}>
<Route path="/" component={Component} />
</Router>,
node
)
expect(props).not.toBe(null)
expect(props.history).toBe(history)
expect(typeof props.location).toBe('object')
expect(typeof props.match).toBe('object')
})
it("won't throw a prop-type warning when passed valid React components that aren't functions", () => {
function forwardRef(Component) {
class ForwardComponent extends React.Component {
render() {
const { forwardedRef, ...rest } = this.props
return <Component ref={forwardedRef} {...rest} />
}
}
return React.forwardRef((props, ref) => {
return <ForwardComponent {...props} forwardedRef={ref} />
})
ContextChecker.contextTypes = {
router: PropTypes.object
}
const history = createHistory()
const Component = () => null
const WrappedComponent = forwardRef(Component)
jest.spyOn(console, 'error').mockImplementation(() => {})
ReactDOM.render(
<Router history={history}>
<Route path="/" component={WrappedComponent} />
</Router>,
node
)
expect(console.error).not.toHaveBeenCalled()
})
afterEach(() => {
rootContext = undefined
})
describe('the `render` prop', () => {
it('renders its return value', () => {
const text = 'Mrs. Kato'
renderStrict(
<MemoryRouter initialEntries={['/']}>
<Route path="/" render={() => <h1>{text}</h1>} />
it('inherits its parent match', () => {
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath']}>
<Route component={ContextChecker} />
</MemoryRouter>,
node
)
expect(node.innerHTML).toContain(text)
const { match } = rootContext.router.route
expect(match.path).toBe('/')
expect(match.url).toBe('/')
expect(match.isExact).toBe(false)
expect(match.params).toEqual({})
})
it('receives { history, location, match } props', () => {
const history = createHistory()
let props = null
renderStrict(
<Router history={history}>
<Route
path="/"
render={p => {
props = p
return null
}}
/>
</Router>,
it('does not render when parent match is null', () => {
const node = document.createElement('div')
ReactDOM.render(
<MemoryRouter initialEntries={['/somepath']}>
<Route path="/no-match" children={() => <Route component={ContextChecker} />} />
</MemoryRouter>,
node
)
expect(props).not.toBe(null)
expect(props.history).toBe(history)
expect(typeof props.location).toBe('object')
expect(typeof props.match).toBe('object')
})
expect(rootContext).toBe(undefined)
})
})
import React from "react";
let StrictMode = function(props) {
return props.children || null;
};
if (React.StrictMode) {
StrictMode = React.StrictMode;
}
export default StrictMode;
import React from "react";
import ReactDOM from "react-dom";
import StrictMode from "./StrictMode";
function renderStrict(element, node) {
ReactDOM.render(<StrictMode>{element}</StrictMode>, node);
}
export default renderStrict;
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var warning = require("warning");
var invariant = require("invariant");
var React = require("react");
var PropTypes = require("prop-types");
var ReactDOM = require("react-dom");
var react_router_1 = require("react-router");
var react_is_1 = require("react-is");
var isEmptyChildren = function (children) { return React.Children.count(children) === 0; };
var LiveState;
(function (LiveState) {
LiveState["NORMAL_RENDER_MATCHED"] = "normal matched render";
LiveState["NORMAL_RENDER_UNMATCHED"] = "normal unmatched render (unmount)";
LiveState["NORMAL_RENDER_ON_INIT"] = "normal render (matched or unmatched)";
LiveState["HIDE_RENDER"] = "hide route when livePath matched";
})(LiveState || (LiveState = {}));
var debugLog = function (message) {
// console.log(message)
};
/**
* The public API for matching a single path and rendering.
*/
var LiveRoute = /** @class */ (function (_super) {
__extends(LiveRoute, _super);
function LiveRoute() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.routeDom = null;
_this.state = {
match: _this.computeMatch(_this.props, _this.context.router)
};
_this.liveState = LiveState.NORMAL_RENDER_ON_INIT;
_this.scrollPosBackup = null;
_this.previousDisplayStyle = null;
return _this;
}
LiveRoute.prototype.getChildContext = function () {
return {
router: __assign({}, this.context.router, { route: {
location: this.props.location || this.context.router.route.location,
match: this.state.match
} })
};
};
LiveRoute.prototype.componentWillMount = function () {
warning(!(this.props.component && this.props.render), 'You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored');
warning(!(this.props.component && this.props.children && !isEmptyChildren(this.props.children)), 'You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored');
warning(!(this.props.render && this.props.children && !isEmptyChildren(this.props.children)), 'You should not use <Route render> and <Route children> in the same route; <Route children> will be ignored');
};
LiveRoute.prototype.componentDidMount = function () {
// backup router and get DOM when mounting
if (this.doesRouteEnableLive() && this.state.match) {
this._latestMatchedRouter = this.context.router;
this.getRouteDom();
}
};
LiveRoute.prototype.componentWillReceiveProps = function (nextProps, nextContext) {
warning(!(nextProps.location && !this.props.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.');
warning(!(!nextProps.location && this.props.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.');
var match = this.computeMatch(nextProps, nextContext.router);
var computedMatch = match;
// recompute match if enable live
if (this.doesRouteEnableLive()) {
computedMatch = this.computeMatchWithLive(this.props, nextProps, nextContext, match);
}
this.setState({
match: computedMatch
});
};
// get route of DOM
LiveRoute.prototype.componentDidUpdate = function (prevProps, prevState) {
if (!this.doesRouteEnableLive()) {
return;
}
// restore display when matched normally
debugLog(this.liveState);
if (this.liveState === LiveState.NORMAL_RENDER_MATCHED) {
this.showRoute();
this.restoreScrollPosition();
this.clearScroll();
}
// get DOM if match and render
if (this.state.match) {
this.getRouteDom();
}
};
// clear on unmounting
LiveRoute.prototype.componentWillUnmount = function () {
this.clearScroll();
};
LiveRoute.prototype.doesRouteEnableLive = function () {
return this.props.livePath || this.props.alwaysLive;
};
/**
* @param {*} props: this.props
* @param {*} nextProps: nextProps
* @param {*} nextContext: nextContext
* @param {*} match: computed `match` of current path
* @returns
* the returned object will be computed by following orders:
* If path matched (no matter livePath matched or not), return normal computed `match`
* If livePath matched, return latest normal render `match`
* If livePath unmatched, return normal computed `match`
* @memberof Route
* Back up current router every time it is rendered normally, backing up to the next livePath rendering
*/
LiveRoute.prototype.computeMatchWithLive = function (props, nextProps, nextContext, match) {
debugLog(">>> " + this.props.name + " <<<");
// compute if livePath match
var livePath = nextProps.livePath, alwaysLive = nextProps.alwaysLive;
var nextPropsWithLivePath = __assign({}, nextProps, { paths: livePath });
var prevMatch = this.computeMatch(props, this.context.router);
var livePathMatch = this.computePathsMatch(nextPropsWithLivePath, nextContext.router);
// normal matched render
if (match) {
debugLog('--- NORMAL MATCH FLAG ---');
if (this.liveState === LiveState.HIDE_RENDER && typeof this.props.onReappear === 'function') {
this.props.onReappear({ location: location, livePath: livePath, alwaysLive: alwaysLive });
}
this.liveState = LiveState.NORMAL_RENDER_MATCHED;
return match;
}
// hide render
if ((livePathMatch || props.alwaysLive) && this.routeDom) {
// backup router when from normal match render to hide render
if (prevMatch) {
this._latestMatchedRouter = this.context.router;
}
if (typeof this.props.onHide === 'function') {
this.props.onHide({ location: location, livePath: livePath, alwaysLive: alwaysLive });
}
debugLog('--- HIDE FLAG ---');
this.liveState = LiveState.HIDE_RENDER;
this.saveScrollPosition();
this.hideRoute();
return prevMatch;
}
// normal unmatched unmount
debugLog('--- NORMAL UNMATCH FLAG ---');
this.liveState = LiveState.NORMAL_RENDER_UNMATCHED;
this.clearScroll();
this.clearDomData();
};
LiveRoute.prototype.computePathsMatch = function (_a, router) {
var computedMatch = _a.computedMatch, location = _a.location, paths = _a.paths, strict = _a.strict, exact = _a.exact, sensitive = _a.sensitive;
invariant(router, 'You should not use <Route> or withRouter() outside a <Router>');
var route = router.route;
var pathname = (location || route.location).pathname;
// livePath could accept a string or an array of string
if (Array.isArray(paths)) {
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
var path = paths_1[_i];
if (typeof path !== 'string') {
continue;
}
var currPath = react_router_1.matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, router.match);
// return if one of the livePaths is matched
if (currPath) {
return currPath;
}
}
return null;
}
else {
return react_router_1.matchPath(pathname, { path: paths, strict: strict, exact: exact, sensitive: sensitive }, router.match);
}
};
LiveRoute.prototype.computeMatch = function (_a, router) {
var computedMatch = _a.computedMatch, location = _a.location, path = _a.path, strict = _a.strict, exact = _a.exact, sensitive = _a.sensitive;
// DO NOT use the computedMatch from Switch!
// react-live-route: ignore match from <Switch>, actually LiveRoute should not be wrapped by <Switch>.
// if (computedMatch) return computedMatch // <Switch> already computed the match for us
invariant(router, 'You should not use <Route> or withRouter() outside a <Router>');
var route = router.route;
var pathname = (location || route.location).pathname;
return react_router_1.matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, route.match);
};
// get DOM of Route
LiveRoute.prototype.getRouteDom = function () {
var routeDom = ReactDOM.findDOMNode(this);
this.routeDom = routeDom;
};
// backup scroll and hide DOM
LiveRoute.prototype.hideRoute = function () {
if (this.routeDom && this.routeDom.style.display !== 'none') {
debugLog('--- hide route ---');
this.previousDisplayStyle = this.routeDom.style.display;
this.routeDom.style.display = 'none';
}
};
// reveal DOM display
LiveRoute.prototype.showRoute = function () {
if (this.routeDom && this.previousDisplayStyle !== null) {
this.routeDom.style.display = this.previousDisplayStyle;
}
};
// save scroll position before hide DOM
LiveRoute.prototype.saveScrollPosition = function () {
if (this.routeDom && this.scrollPosBackup === null) {
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
debugLog("saved top = " + scrollTop + ", left = " + scrollLeft);
this.scrollPosBackup = { top: scrollTop, left: scrollLeft };
}
};
// restore the scroll position before hide
LiveRoute.prototype.restoreScrollPosition = function () {
var scroll = this.scrollPosBackup;
debugLog(scroll);
if (scroll && this.routeDom) {
window.scrollTo(scroll.left, scroll.top);
}
};
// clear scroll position
LiveRoute.prototype.clearDomData = function () {
if (this.doesRouteEnableLive()) {
this.routeDom = null;
this.previousDisplayStyle = null;
}
};
// clear scroll position
LiveRoute.prototype.clearScroll = function () {
if (this.doesRouteEnableLive()) {
this.scrollPosBackup = null;
}
};
// normally render or unmount Route
LiveRoute.prototype.renderRoute = function (component, render, props, match) {
debugLog(match);
if (component)
return match ? React.createElement(component, props) : null;
if (render)
return match ? render(props) : null;
};
LiveRoute.prototype.render = function () {
var match = this.state.match;
var _a = this.props, children = _a.children, component = _a.component, render = _a.render, livePath = _a.livePath, alwaysLive = _a.alwaysLive, onHide = _a.onHide;
var _b = this.context.router, history = _b.history, route = _b.route, staticContext = _b.staticContext;
var location = this.props.location || route.location;
var props = { match: match, location: location, history: history, staticContext: staticContext };
// only affect LiveRoute
if ((livePath || alwaysLive) && (component || render)) {
debugLog('=== RENDER FLAG: ' + this.liveState + ' ===');
if (this.liveState === LiveState.NORMAL_RENDER_MATCHED ||
this.liveState === LiveState.NORMAL_RENDER_UNMATCHED ||
this.liveState === LiveState.NORMAL_RENDER_ON_INIT) {
// normal render
return this.renderRoute(component, render, props, match);
}
else if (this.liveState === LiveState.HIDE_RENDER) {
// hide render
var prevRouter = this._latestMatchedRouter;
var history_1 = prevRouter.history, route_1 = prevRouter.route, staticContext_1 = prevRouter.staticContext; // load properties from prevRouter and fake props of latest normal render
var liveProps = { match: match, location: location, history: history_1, staticContext: staticContext_1 };
return this.renderRoute(component, render, liveProps, true);
}
}
// the following is the same as Route of react-router, just render it normally
if (component)
return match ? React.createElement(component, props) : null;
if (render)
return match ? render(props) : null;
if (typeof children === 'function')
return children(props);
if (children && !isEmptyChildren(children))
return React.Children.only(children);
return null;
};
LiveRoute.propTypes = {
computedMatch: PropTypes.object,
path: PropTypes.string,
exact: PropTypes.bool,
strict: PropTypes.bool,
sensitive: PropTypes.bool,
component: function (props, propName) {
if (props[propName] && !react_is_1.isValidElementType(props[propName])) {
return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
}
},
render: PropTypes.func,
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
location: PropTypes.object,
onHide: PropTypes.func,
livePath: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
alwaysLive: PropTypes.bool,
name: PropTypes.string // for LiveRoute debug
};
LiveRoute.defaultProps = {
alwaysLive: false
};
LiveRoute.contextTypes = {
router: PropTypes.shape({
history: PropTypes.object.isRequired,
route: PropTypes.object.isRequired,
staticContext: PropTypes.object
})
};
LiveRoute.childContextTypes = {
router: PropTypes.object.isRequired
};
return LiveRoute;
}(React.Component));
exports.LiveRoute = LiveRoute;
//# sourceMappingURL=LiveRoute.js.map
\ No newline at end of file
{"version":3,"file":"LiveRoute.js","sourceRoot":"","sources":["../src/LiveRoute.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,qCAAsC;AACtC,6BAA8B;AAC9B,sCAAuC;AACvC,oCAAqC;AACrC,6CAAwC;AACxC,qCAA6C;AAE7C,IAAM,eAAe,GAAG,UAAA,QAAQ,IAAI,OAAA,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAApC,CAAoC,CAAA;AAExE,IAAK,SAKJ;AALD,WAAK,SAAS;IACZ,4DAA+C,CAAA;IAC/C,0EAA6D,CAAA;IAC7D,2EAA8D,CAAA;IAC9D,6DAAgD,CAAA;AAClD,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAoBD,IAAM,QAAQ,GAAG,UAAC,OAAY;IAC5B,uBAAuB;AACzB,CAAC,CAAA;AAED;;GAEG;AACH;IAAwB,6BAA4B;IAApD;QAAA,qEAuUC;QAjSC,cAAQ,GAAa,IAAI,CAAA;QAczB,WAAK,GAAG;YACN,KAAK,EAAE,KAAI,CAAC,YAAY,CAAC,KAAI,CAAC,KAAY,EAAE,KAAI,CAAC,OAAO,CAAC,MAAM,CAAC;SACjE,CAAA;QAED,eAAS,GAAc,SAAS,CAAC,qBAAqB,CAAA;QACtD,qBAAe,GAAyC,IAAI,CAAA;QAC5D,0BAAoB,GAAkB,IAAI,CAAA;;IA6Q5C,CAAC;IA/RC,mCAAe,GAAf;QACE,OAAO;YACL,MAAM,eACD,IAAI,CAAC,OAAO,CAAC,MAAM,IACtB,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ;oBACnE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;i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E,SAAS,CAAC,MAAM;QAC1B,MAAM,EAAE,SAAS,CAAC,IAAI;QACtB,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QAClE,UAAU,EAAE,SAAS,CAAC,IAAI;QAC1B,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,sBAAsB;KAC9C,CAAA;IAEM,sBAAY,GAAG;QACpB,UAAU,EAAE,KAAK;KAClB,CAAA;IAEM,sBAAY,GAAG;QACpB,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC;YACtB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;YACpC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;YAClC,aAAa,EAAE,SAAS,CAAC,MAAM;SAChC,CAAC;KACH,CAAA;IAEM,2BAAiB,GAAG;QACzB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;KACpC,CAAA;IAoSH,gBAAC;CAAA,AAvUD,CAAwB,KAAK,CAAC,SAAS,GAuUtC;AAEQ,8BAAS"}
\ No newline at end of file
{
"name": "react-live-route",
"version": "1.3.0",
"description": "A living route for react-router-v4",
"description": "A living route for react-router v4",
"repository": "fi3ework/react-live-route",
"license": "MIT",
"authors": "fi3ework",
......@@ -12,7 +12,7 @@
"build": "rm -fr dist && tsc",
"dev": "tsc -b -w --pretty",
"prepare": "npm run build",
"lint": "eslint modules",
"lint": "tslint src",
"test": "jest"
},
"peerDependencies": {
......@@ -32,15 +32,12 @@
"@types/jest": "^24.0.9",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
"jest": "^23.1.0",
"react-addons-test-utils": "^15.6.2",
"jest": "^24.5.0",
"ts-jest": "^24.0.0",
"tslint-config-prettier": "^1.17.0"
},
"jest": {
"setupFiles": [
"raf/polyfill"
]
"tslint": "^5.14.0",
"tslint-config-alloy": "^0.2.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.3.3333"
},
"keywords": [
"react",
......
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"removeComments": false,
"strict": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
......@@ -17,7 +20,10 @@
"noImplicitAny": false,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": false
"downlevelIteration": true,
"noUnusedLocals": false,
"noUnusedParameters": false
},
"include": ["src"]
"include": ["src/**/*.tsx"],
"exclude": ["node_modules", "dist", "__test__"]
}
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"linterOptions": {
"exclude": ["node_modules/**/*.ts"]
},
"rules": {
"no-var-requires": false,
"max-classes-per-file": false,
// "prettier": true,
"arrow-parens": false,
"arrow-return-shorthand": [false],
"comment-format": [true, "check-space"],
"import-blacklist": [true, "rxjs"],
"interface-over-type-literal": false,
"interface-name": false,
"member-access": false,
"member-ordering": [true, { "order": "fields-first" }],
// "newline-before-return": false,]
"no-any": false,
"no-empty-interface": false,
"no-import-side-effect": false,
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
"no-invalid-this": [true, "check-function-in-method"],
"no-null-keyword": false,
"no-require-imports": false,
"no-this-assignment": [true, { "allow-destructuring": true }],
"no-trailing-whitespace": true,
"no-unused-variable": [false, "react"],
"object-literal-sort-keys": false,
"object-literal-shorthand": false,
"one-variable-per-declaration": [false],
"only-arrow-functions": [true, "allow-declarations"],
"ordered-imports": [false],
"no-console": [false],
"prefer-method-signature": false,
"prefer-template": [true, "allow-single-concat"],
"quotemark": [true, "single", "jsx-double"],
"triple-equals": [true, "allow-null-check"],
// "type-literal-delimiter": true,
"typedef": {
"severity": "off",
"options": ["parameter", "property-declaration"]
},
"variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case", "allow-leading-underscore"],
// tslint-react
"jsx-no-lambda": false
},
"jsRules": {
"object-literal-sort-keys": false // Disable for javascript
}
"extends": ["tslint-config-alloy", "tslint-config-prettier"]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment