|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
- typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
- (factory((global.ReactRouterDOM = {}),global.React));
- }(this, (function (exports,React) { 'use strict';
-
- React = React && React.hasOwnProperty('default') ? React['default'] : React;
-
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule warning
- */
-
- var warning = function () {};
-
- {
- var printWarning = function printWarning(format, args) {
- var len = arguments.length;
- args = new Array(len > 2 ? len - 2 : 0);
- for (var key = 2; key < len; key++) {
- args[key - 2] = arguments[key];
- }
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.error(message);
- }
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
- };
-
- warning = function (condition, format, args) {
- var len = arguments.length;
- args = new Array(len > 2 ? len - 2 : 0);
- for (var key = 2; key < len; key++) {
- args[key - 2] = arguments[key];
- }
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
- if (!condition) {
- printWarning.apply(null, [format].concat(args));
- }
- };
- }
-
- var warning_1 = warning;
-
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
-
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
- function makeEmptyFunction(arg) {
- return function () {
- return arg;
- };
- }
-
- /**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
- var emptyFunction = function emptyFunction() {};
-
- emptyFunction.thatReturns = makeEmptyFunction;
- emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
- emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
- emptyFunction.thatReturnsNull = makeEmptyFunction(null);
- emptyFunction.thatReturnsThis = function () {
- return this;
- };
- emptyFunction.thatReturnsArgument = function (arg) {
- return arg;
- };
-
- var emptyFunction_1 = emptyFunction;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
- var validateFormat = function validateFormat(format) {};
-
- {
- validateFormat = function validateFormat(format) {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- };
- }
-
- function invariant(condition, format, a, b, c, d, e, f) {
- validateFormat(format);
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
- }
-
- var invariant_1 = invariant;
-
- /**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
-
- var warning$1 = emptyFunction_1;
-
- {
- var printWarning$1 = function printWarning(format) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.error(message);
- }
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
- };
-
- warning$1 = function warning(condition, format) {
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
-
- if (format.indexOf('Failed Composite propType: ') === 0) {
- return; // Ignore CompositeComponent proptype check.
- }
-
- if (!condition) {
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
- args[_key2 - 2] = arguments[_key2];
- }
-
- printWarning$1.apply(undefined, [format].concat(args));
- }
- };
- }
-
- var warning_1$1 = warning$1;
-
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- /* eslint-disable no-unused-vars */
-
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
- }
-
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
-
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
- };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
-
- var ReactPropTypesSecret_1 = ReactPropTypesSecret;
-
- {
- var invariant$1 = invariant_1;
- var warning$2 = warning_1$1;
- var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
- var loggedTypeFailures = {};
- }
-
- /**
- * Assert that the values match with the type specs.
- * Error messages are memorized and will only be shown once.
- *
- * @param {object} typeSpecs Map of name to a ReactPropType
- * @param {object} values Runtime values that need to be type-checked
- * @param {string} location e.g. "prop", "context", "child context"
- * @param {string} componentName Name of the component for error messages.
- * @param {?Function} getStack Returns the component stack.
- * @private
- */
- function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
- {
- for (var typeSpecName in typeSpecs) {
- if (typeSpecs.hasOwnProperty(typeSpecName)) {
- var error;
- // Prop type validation may throw. In case they do, we don't want to
- // fail the render phase where it didn't fail before. So we log it.
- // After these have been cleaned up, we'll let them throw.
- try {
- // This is intentionally an invariant that gets caught. It's the same
- // behavior as without this statement except with a better message.
- invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
- } catch (ex) {
- error = ex;
- }
- warning$2(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
- // Only monitor this failure once because there tends to be a lot of the
- // same error.
- loggedTypeFailures[error.message] = true;
-
- var stack = getStack ? getStack() : '';
-
- warning$2(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
- }
- }
- }
- }
- }
-
- var checkPropTypes_1 = checkPropTypes;
-
- var factoryWithTypeCheckers = function (isValidElement, throwOnDirectAccess) {
- /* global Symbol */
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
-
- /**
- * Returns the iterator method function contained on the iterable object.
- *
- * Be sure to invoke the function with the iterable as context:
- *
- * var iteratorFn = getIteratorFn(myIterable);
- * if (iteratorFn) {
- * var iterator = iteratorFn.call(myIterable);
- * ...
- * }
- *
- * @param {?object} maybeIterable
- * @return {?function}
- */
- function getIteratorFn(maybeIterable) {
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- /**
- * Collection of methods that allow declaration and validation of props that are
- * supplied to React components. Example usage:
- *
- * var Props = require('ReactPropTypes');
- * var MyArticle = React.createClass({
- * propTypes: {
- * // An optional string prop named "description".
- * description: Props.string,
- *
- * // A required enum prop named "category".
- * category: Props.oneOf(['News','Photos']).isRequired,
- *
- * // A prop named "dialog" that requires an instance of Dialog.
- * dialog: Props.instanceOf(Dialog).isRequired
- * },
- * render: function() { ... }
- * });
- *
- * A more formal specification of how these methods are used:
- *
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
- * decl := ReactPropTypes.{type}(.isRequired)?
- *
- * Each and every declaration produces a function with the same signature. This
- * allows the creation of custom validation functions. For example:
- *
- * var MyLink = React.createClass({
- * propTypes: {
- * // An optional string or URI prop named "href".
- * href: function(props, propName, componentName) {
- * var propValue = props[propName];
- * if (propValue != null && typeof propValue !== 'string' &&
- * !(propValue instanceof URI)) {
- * return new Error(
- * 'Expected a string or an URI for ' + propName + ' in ' +
- * componentName
- * );
- * }
- * }
- * },
- * render: function() {...}
- * });
- *
- * @internal
- */
-
- var ANONYMOUS = '<<anonymous>>';
-
- // Important!
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
- var ReactPropTypes = {
- array: createPrimitiveTypeChecker('array'),
- bool: createPrimitiveTypeChecker('boolean'),
- func: createPrimitiveTypeChecker('function'),
- number: createPrimitiveTypeChecker('number'),
- object: createPrimitiveTypeChecker('object'),
- string: createPrimitiveTypeChecker('string'),
- symbol: createPrimitiveTypeChecker('symbol'),
-
- any: createAnyTypeChecker(),
- arrayOf: createArrayOfTypeChecker,
- element: createElementTypeChecker(),
- instanceOf: createInstanceTypeChecker,
- node: createNodeChecker(),
- objectOf: createObjectOfTypeChecker,
- oneOf: createEnumTypeChecker,
- oneOfType: createUnionTypeChecker,
- shape: createShapeTypeChecker,
- exact: createStrictShapeTypeChecker
- };
-
- /**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
- /*eslint-disable no-self-compare*/
- function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return x !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
- }
- /*eslint-enable no-self-compare*/
-
- /**
- * We use an Error-like object for backward compatibility as people may call
- * PropTypes directly and inspect their output. However, we don't use real
- * Errors anymore. We don't inspect their stack anyway, and creating them
- * is prohibitively expensive if they are created too often, such as what
- * happens in oneOfType() for any type before the one that matched.
- */
- function PropTypeError(message) {
- this.message = message;
- this.stack = '';
- }
- // Make `instanceof Error` still work for returned errors.
- PropTypeError.prototype = Error.prototype;
-
- function createChainableTypeChecker(validate) {
- {
- var manualPropTypeCallCache = {};
- var manualPropTypeWarningCount = 0;
- }
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
- componentName = componentName || ANONYMOUS;
- propFullName = propFullName || propName;
-
- if (secret !== ReactPropTypesSecret_1) {
- if (throwOnDirectAccess) {
- // New behavior only for users of `prop-types` package
- invariant_1(false, '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');
- } else if (typeof console !== 'undefined') {
- // Old behavior for people using React.PropTypes
- var cacheKey = componentName + ':' + propName;
- if (!manualPropTypeCallCache[cacheKey] &&
- // Avoid spamming the console because they are often not actionable except for lib authors
- manualPropTypeWarningCount < 3) {
- warning_1$1(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);
- manualPropTypeCallCache[cacheKey] = true;
- manualPropTypeWarningCount++;
- }
- }
- }
- if (props[propName] == null) {
- if (isRequired) {
- if (props[propName] === null) {
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
- }
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
- }
- return null;
- } else {
- return validate(props, propName, componentName, location, propFullName);
- }
- }
-
- var chainedCheckType = checkType.bind(null, false);
- chainedCheckType.isRequired = checkType.bind(null, true);
-
- return chainedCheckType;
- }
-
- function createPrimitiveTypeChecker(expectedType) {
- function validate(props, propName, componentName, location, propFullName, secret) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== expectedType) {
- // `propValue` being instance of, say, date/regexp, pass the 'object'
- // check, but we can offer a more precise error message here rather than
- // 'of type `object`'.
- var preciseType = getPreciseType(propValue);
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createAnyTypeChecker() {
- return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
- }
-
- function createArrayOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
- }
- var propValue = props[propName];
- if (!Array.isArray(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
- }
- for (var i = 0; i < propValue.length; i++) {
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
- if (error instanceof Error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createElementTypeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- if (!isValidElement(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createInstanceTypeChecker(expectedClass) {
- function validate(props, propName, componentName, location, propFullName) {
- if (!(props[propName] instanceof expectedClass)) {
- var expectedClassName = expectedClass.name || ANONYMOUS;
- var actualClassName = getClassName(props[propName]);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createEnumTypeChecker(expectedValues) {
- if (!Array.isArray(expectedValues)) {
- warning_1$1(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
- return emptyFunction_1.thatReturnsNull;
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- for (var i = 0; i < expectedValues.length; i++) {
- if (is(propValue, expectedValues[i])) {
- return null;
- }
- }
-
- var valuesString = JSON.stringify(expectedValues);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createObjectOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
- }
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
- }
- for (var key in propValue) {
- if (propValue.hasOwnProperty(key)) {
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
- if (error instanceof Error) {
- return error;
- }
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createUnionTypeChecker(arrayOfTypeCheckers) {
- if (!Array.isArray(arrayOfTypeCheckers)) {
- warning_1$1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
- return emptyFunction_1.thatReturnsNull;
- }
-
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (typeof checker !== 'function') {
- warning_1$1(false, 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);
- return emptyFunction_1.thatReturnsNull;
- }
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
- return null;
- }
- }
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createNodeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- if (!isNode(props[propName])) {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createShapeTypeChecker(shapeTypes) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
- }
- for (var key in shapeTypes) {
- var checker = shapeTypes[key];
- if (!checker) {
- continue;
- }
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
- if (error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createStrictShapeTypeChecker(shapeTypes) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
- }
- // We need to check all keys in case some are required but missing from
- // props.
- var allKeys = objectAssign({}, props[propName], shapeTypes);
- for (var key in allKeys) {
- var checker = shapeTypes[key];
- if (!checker) {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
- }
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
- if (error) {
- return error;
- }
- }
- return null;
- }
-
- return createChainableTypeChecker(validate);
- }
-
- function isNode(propValue) {
- switch (typeof propValue) {
- case 'number':
- case 'string':
- case 'undefined':
- return true;
- case 'boolean':
- return !propValue;
- case 'object':
- if (Array.isArray(propValue)) {
- return propValue.every(isNode);
- }
- if (propValue === null || isValidElement(propValue)) {
- return true;
- }
-
- var iteratorFn = getIteratorFn(propValue);
- if (iteratorFn) {
- var iterator = iteratorFn.call(propValue);
- var step;
- if (iteratorFn !== propValue.entries) {
- while (!(step = iterator.next()).done) {
- if (!isNode(step.value)) {
- return false;
- }
- }
- } else {
- // Iterator will provide entry [k,v] tuples rather than values.
- while (!(step = iterator.next()).done) {
- var entry = step.value;
- if (entry) {
- if (!isNode(entry[1])) {
- return false;
- }
- }
- }
- }
- } else {
- return false;
- }
-
- return true;
- default:
- return false;
- }
- }
-
- function isSymbol(propType, propValue) {
- // Native Symbol.
- if (propType === 'symbol') {
- return true;
- }
-
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
- if (propValue['@@toStringTag'] === 'Symbol') {
- return true;
- }
-
- // Fallback for non-spec compliant Symbols which are polyfilled.
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
- return true;
- }
-
- return false;
- }
-
- // Equivalent of `typeof` but with special handling for array and regexp.
- function getPropType(propValue) {
- var propType = typeof propValue;
- if (Array.isArray(propValue)) {
- return 'array';
- }
- if (propValue instanceof RegExp) {
- // Old webkits (at least until Android 4.0) return 'function' rather than
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
- // passes PropTypes.object.
- return 'object';
- }
- if (isSymbol(propType, propValue)) {
- return 'symbol';
- }
- return propType;
- }
-
- // This handles more types than `getPropType`. Only used for error messages.
- // See `createPrimitiveTypeChecker`.
- function getPreciseType(propValue) {
- if (typeof propValue === 'undefined' || propValue === null) {
- return '' + propValue;
- }
- var propType = getPropType(propValue);
- if (propType === 'object') {
- if (propValue instanceof Date) {
- return 'date';
- } else if (propValue instanceof RegExp) {
- return 'regexp';
- }
- }
- return propType;
- }
-
- // Returns a string that is postfixed to a warning about an invalid type.
- // For example, "undefined" or "of type array"
- function getPostfixForTypeWarning(value) {
- var type = getPreciseType(value);
- switch (type) {
- case 'array':
- case 'object':
- return 'an ' + type;
- case 'boolean':
- case 'date':
- case 'regexp':
- return 'a ' + type;
- default:
- return type;
- }
- }
-
- // Returns class name of the object, if any.
- function getClassName(propValue) {
- if (!propValue.constructor || !propValue.constructor.name) {
- return ANONYMOUS;
- }
- return propValue.constructor.name;
- }
-
- ReactPropTypes.checkPropTypes = checkPropTypes_1;
- ReactPropTypes.PropTypes = ReactPropTypes;
-
- return ReactPropTypes;
- };
-
- var propTypes = createCommonjsModule(function (module) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
- {
- var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
-
- var isValidElement = function (object) {
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
- };
-
- // By explicitly using `prop-types` you are opting into new development behavior.
- // http://fb.me/prop-types-in-prod
- var throwOnDirectAccess = true;
- module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
- }
- });
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
- var invariant$2 = function (condition, format, a, b, c, d, e, f) {
- {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- }
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
- };
-
- var invariant_1$1 = invariant$2;
-
- function isAbsolute(pathname) {
- return pathname.charAt(0) === '/';
- }
-
- // About 1.5x faster than the two-arg version of Array#splice()
- function spliceOne(list, index) {
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
- list[i] = list[k];
- }
-
- list.pop();
- }
-
- // This implementation is based heavily on node's url.parse
- function resolvePathname(to) {
- var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
-
- var toParts = to && to.split('/') || [];
- var fromParts = from && from.split('/') || [];
-
- var isToAbs = to && isAbsolute(to);
- var isFromAbs = from && isAbsolute(from);
- var mustEndAbs = isToAbs || isFromAbs;
-
- if (to && isAbsolute(to)) {
- // to is absolute
- fromParts = toParts;
- } else if (toParts.length) {
- // to is relative, drop the filename
- fromParts.pop();
- fromParts = fromParts.concat(toParts);
- }
-
- if (!fromParts.length) return '/';
-
- var hasTrailingSlash = void 0;
- if (fromParts.length) {
- var last = fromParts[fromParts.length - 1];
- hasTrailingSlash = last === '.' || last === '..' || last === '';
- } else {
- hasTrailingSlash = false;
- }
-
- var up = 0;
- for (var i = fromParts.length; i >= 0; i--) {
- var part = fromParts[i];
-
- if (part === '.') {
- spliceOne(fromParts, i);
- } else if (part === '..') {
- spliceOne(fromParts, i);
- up++;
- } else if (up) {
- spliceOne(fromParts, i);
- up--;
- }
- }
-
- if (!mustEndAbs) for (; up--; up) {
- fromParts.unshift('..');
- }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
-
- var result = fromParts.join('/');
-
- if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
-
- return result;
- }
-
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
-
- function valueEqual(a, b) {
- if (a === b) return true;
-
- if (a == null || b == null) return false;
-
- if (Array.isArray(a)) {
- return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
- return valueEqual(item, b[index]);
- });
- }
-
- var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
- var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
-
- if (aType !== bType) return false;
-
- if (aType === 'object') {
- var aValue = a.valueOf();
- var bValue = b.valueOf();
-
- if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
-
- var aKeys = Object.keys(a);
- var bKeys = Object.keys(b);
-
- if (aKeys.length !== bKeys.length) return false;
-
- return aKeys.every(function (key) {
- return valueEqual(a[key], b[key]);
- });
- }
-
- return false;
- }
-
- var addLeadingSlash = function addLeadingSlash(path) {
- return path.charAt(0) === '/' ? path : '/' + path;
- };
-
- var stripLeadingSlash = function stripLeadingSlash(path) {
- return path.charAt(0) === '/' ? path.substr(1) : path;
- };
-
- var hasBasename = function hasBasename(path, prefix) {
- return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
- };
-
- var stripBasename = function stripBasename(path, prefix) {
- return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
- };
-
- var stripTrailingSlash = function stripTrailingSlash(path) {
- return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
- };
-
- var parsePath = function parsePath(path) {
- var pathname = path || '/';
- var search = '';
- var hash = '';
-
- var hashIndex = pathname.indexOf('#');
- if (hashIndex !== -1) {
- hash = pathname.substr(hashIndex);
- pathname = pathname.substr(0, hashIndex);
- }
-
- var searchIndex = pathname.indexOf('?');
- if (searchIndex !== -1) {
- search = pathname.substr(searchIndex);
- pathname = pathname.substr(0, searchIndex);
- }
-
- return {
- pathname: pathname,
- search: search === '?' ? '' : search,
- hash: hash === '#' ? '' : hash
- };
- };
-
- var createPath = function createPath(location) {
- var pathname = location.pathname,
- search = location.search,
- hash = location.hash;
-
- var path = pathname || '/';
-
- if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;
-
- if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;
-
- return path;
- };
-
- 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;
- };
-
- var createLocation = function createLocation(path, state, key, currentLocation) {
- var location = void 0;
- if (typeof path === 'string') {
- // Two-arg form: push(path, state)
- location = parsePath(path);
- location.state = state;
- } else {
- // One-arg form: push(location)
- location = _extends({}, path);
-
- if (location.pathname === undefined) location.pathname = '';
-
- if (location.search) {
- if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
- } else {
- location.search = '';
- }
-
- if (location.hash) {
- if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
- } else {
- location.hash = '';
- }
-
- if (state !== undefined && location.state === undefined) location.state = state;
- }
-
- try {
- location.pathname = decodeURI(location.pathname);
- } catch (e) {
- if (e instanceof URIError) {
- throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
- } else {
- throw e;
- }
- }
-
- if (key) location.key = key;
-
- if (currentLocation) {
- // Resolve incomplete/relative pathname relative to current location.
- if (!location.pathname) {
- location.pathname = currentLocation.pathname;
- } else if (location.pathname.charAt(0) !== '/') {
- location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
- }
- } else {
- // When there is no prior location and pathname is empty, set it to /
- if (!location.pathname) {
- location.pathname = '/';
- }
- }
-
- return location;
- };
-
- var locationsAreEqual = function locationsAreEqual(a, b) {
- return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
- };
-
- var createTransitionManager = function createTransitionManager() {
- var prompt = null;
-
- var setPrompt = function setPrompt(nextPrompt) {
- warning_1(prompt == null, 'A history supports only one prompt at a time');
-
- prompt = nextPrompt;
-
- return function () {
- if (prompt === nextPrompt) prompt = null;
- };
- };
-
- var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {
- // TODO: If another transition starts while we're still confirming
- // the previous one, we may end up in a weird state. Figure out the
- // best way to handle this.
- if (prompt != null) {
- var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
-
- if (typeof result === 'string') {
- if (typeof getUserConfirmation === 'function') {
- getUserConfirmation(result, callback);
- } else {
- warning_1(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
-
- callback(true);
- }
- } else {
- // Return false from a transition hook to cancel the transition.
- callback(result !== false);
- }
- } else {
- callback(true);
- }
- };
-
- var listeners = [];
-
- var appendListener = function appendListener(fn) {
- var isActive = true;
-
- var listener = function listener() {
- if (isActive) fn.apply(undefined, arguments);
- };
-
- listeners.push(listener);
-
- return function () {
- isActive = false;
- listeners = listeners.filter(function (item) {
- return item !== listener;
- });
- };
- };
-
- var notifyListeners = function notifyListeners() {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- listeners.forEach(function (listener) {
- return listener.apply(undefined, args);
- });
- };
-
- return {
- setPrompt: setPrompt,
- confirmTransitionTo: confirmTransitionTo,
- appendListener: appendListener,
- notifyListeners: notifyListeners
- };
- };
-
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
-
- var addEventListener = function addEventListener(node, event, listener) {
- return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener);
- };
-
- var removeEventListener = function removeEventListener(node, event, listener) {
- return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener);
- };
-
- var getConfirmation = function getConfirmation(message, callback) {
- return callback(window.confirm(message));
- }; // eslint-disable-line no-alert
-
- /**
- * Returns true if the HTML5 history API is supported. Taken from Modernizr.
- *
- * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
- * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
- * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
- */
- var supportsHistory = function supportsHistory() {
- var ua = window.navigator.userAgent;
-
- if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
-
- return window.history && 'pushState' in window.history;
- };
-
- /**
- * Returns true if browser fires popstate on hash change.
- * IE10 and IE11 do not.
- */
- var supportsPopStateOnHashChange = function supportsPopStateOnHashChange() {
- return window.navigator.userAgent.indexOf('Trident') === -1;
- };
-
- /**
- * Returns false if using go(n) with hash history causes a full page reload.
- */
- var supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() {
- return window.navigator.userAgent.indexOf('Firefox') === -1;
- };
-
- /**
- * Returns true if a given popstate event is an extraneous WebKit event.
- * Accounts for the fact that Chrome on iOS fires real popstate events
- * containing undefined state when pressing the back button.
- */
- var isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) {
- return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
- };
-
- var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
-
- var _extends$1 = 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;
- };
-
- var PopStateEvent = 'popstate';
- var HashChangeEvent = 'hashchange';
-
- var getHistoryState = function getHistoryState() {
- try {
- return window.history.state || {};
- } catch (e) {
- // IE 11 sometimes throws when accessing window.history.state
- // See https://github.com/ReactTraining/history/pull/289
- return {};
- }
- };
-
- /**
- * Creates a history object that uses the HTML5 history API including
- * pushState, replaceState, and the popstate event.
- */
- var createBrowserHistory = function createBrowserHistory() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
- invariant_1$1(canUseDOM, 'Browser history needs a DOM');
-
- var globalHistory = window.history;
- var canUseHistory = supportsHistory();
- var needsHashChangeListener = !supportsPopStateOnHashChange();
-
- var _props$forceRefresh = props.forceRefresh,
- forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh,
- _props$getUserConfirm = props.getUserConfirmation,
- getUserConfirmation = _props$getUserConfirm === undefined ? getConfirmation : _props$getUserConfirm,
- _props$keyLength = props.keyLength,
- keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;
-
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
-
- var getDOMLocation = function getDOMLocation(historyState) {
- var _ref = historyState || {},
- key = _ref.key,
- state = _ref.state;
-
- var _window$location = window.location,
- pathname = _window$location.pathname,
- search = _window$location.search,
- hash = _window$location.hash;
-
- var path = pathname + search + hash;
-
- warning_1(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
-
- if (basename) path = stripBasename(path, basename);
-
- return createLocation(path, state, key);
- };
-
- var createKey = function createKey() {
- return Math.random().toString(36).substr(2, keyLength);
- };
-
- var transitionManager = createTransitionManager();
-
- var setState = function setState(nextState) {
- _extends$1(history, nextState);
-
- history.length = globalHistory.length;
-
- transitionManager.notifyListeners(history.location, history.action);
- };
-
- var handlePopState = function handlePopState(event) {
- // Ignore extraneous popstate events in WebKit.
- if (isExtraneousPopstateEvent(event)) return;
-
- handlePop(getDOMLocation(event.state));
- };
-
- var handleHashChange = function handleHashChange() {
- handlePop(getDOMLocation(getHistoryState()));
- };
-
- var forceNextPop = false;
-
- var handlePop = function handlePop(location) {
- if (forceNextPop) {
- forceNextPop = false;
- setState();
- } else {
- var action = 'POP';
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (ok) {
- setState({ action: action, location: location });
- } else {
- revertPop(location);
- }
- });
- }
- };
-
- var revertPop = function revertPop(fromLocation) {
- var toLocation = history.location;
-
- // TODO: We could probably make this more reliable by
- // keeping a list of keys we've seen in sessionStorage.
- // Instead, we just default to 0 for keys we don't know.
-
- var toIndex = allKeys.indexOf(toLocation.key);
-
- if (toIndex === -1) toIndex = 0;
-
- var fromIndex = allKeys.indexOf(fromLocation.key);
-
- if (fromIndex === -1) fromIndex = 0;
-
- var delta = toIndex - fromIndex;
-
- if (delta) {
- forceNextPop = true;
- go(delta);
- }
- };
-
- var initialLocation = getDOMLocation(getHistoryState());
- var allKeys = [initialLocation.key];
-
- // Public interface
-
- var createHref = function createHref(location) {
- return basename + createPath(location);
- };
-
- var push = function push(path, state) {
- warning_1(!((typeof path === 'undefined' ? 'undefined' : _typeof$1(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
-
- var action = 'PUSH';
- var location = createLocation(path, state, createKey(), history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- var href = createHref(location);
- var key = location.key,
- state = location.state;
-
- if (canUseHistory) {
- globalHistory.pushState({ key: key, state: state }, null, href);
-
- if (forceRefresh) {
- window.location.href = href;
- } else {
- var prevIndex = allKeys.indexOf(history.location.key);
- var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
-
- nextKeys.push(location.key);
- allKeys = nextKeys;
-
- setState({ action: action, location: location });
- }
- } else {
- warning_1(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');
-
- window.location.href = href;
- }
- });
- };
-
- var replace = function replace(path, state) {
- warning_1(!((typeof path === 'undefined' ? 'undefined' : _typeof$1(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
-
- var action = 'REPLACE';
- var location = createLocation(path, state, createKey(), history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- var href = createHref(location);
- var key = location.key,
- state = location.state;
-
- if (canUseHistory) {
- globalHistory.replaceState({ key: key, state: state }, null, href);
-
- if (forceRefresh) {
- window.location.replace(href);
- } else {
- var prevIndex = allKeys.indexOf(history.location.key);
-
- if (prevIndex !== -1) allKeys[prevIndex] = location.key;
-
- setState({ action: action, location: location });
- }
- } else {
- warning_1(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history');
-
- window.location.replace(href);
- }
- });
- };
-
- var go = function go(n) {
- globalHistory.go(n);
- };
-
- var goBack = function goBack() {
- return go(-1);
- };
-
- var goForward = function goForward() {
- return go(1);
- };
-
- var listenerCount = 0;
-
- var checkDOMListeners = function checkDOMListeners(delta) {
- listenerCount += delta;
-
- if (listenerCount === 1) {
- addEventListener(window, PopStateEvent, handlePopState);
-
- if (needsHashChangeListener) addEventListener(window, HashChangeEvent, handleHashChange);
- } else if (listenerCount === 0) {
- removeEventListener(window, PopStateEvent, handlePopState);
-
- if (needsHashChangeListener) removeEventListener(window, HashChangeEvent, handleHashChange);
- }
- };
-
- var isBlocked = false;
-
- var block = function block() {
- var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
-
- var unblock = transitionManager.setPrompt(prompt);
-
- if (!isBlocked) {
- checkDOMListeners(1);
- isBlocked = true;
- }
-
- return function () {
- if (isBlocked) {
- isBlocked = false;
- checkDOMListeners(-1);
- }
-
- return unblock();
- };
- };
-
- var listen = function listen(listener) {
- var unlisten = transitionManager.appendListener(listener);
- checkDOMListeners(1);
-
- return function () {
- checkDOMListeners(-1);
- unlisten();
- };
- };
-
- var history = {
- length: globalHistory.length,
- action: 'POP',
- location: initialLocation,
- createHref: createHref,
- push: push,
- replace: replace,
- go: go,
- goBack: goBack,
- goForward: goForward,
- block: block,
- listen: listen
- };
-
- return history;
- };
-
- var _extends$2 = 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;
- };
-
- var HashChangeEvent$1 = 'hashchange';
-
- var HashPathCoders = {
- hashbang: {
- encodePath: function encodePath(path) {
- return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);
- },
- decodePath: function decodePath(path) {
- return path.charAt(0) === '!' ? path.substr(1) : path;
- }
- },
- noslash: {
- encodePath: stripLeadingSlash,
- decodePath: addLeadingSlash
- },
- slash: {
- encodePath: addLeadingSlash,
- decodePath: addLeadingSlash
- }
- };
-
- var getHashPath = function getHashPath() {
- // We can't use window.location.hash here because it's not
- // consistent across browsers - Firefox will pre-decode it!
- var href = window.location.href;
- var hashIndex = href.indexOf('#');
- return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
- };
-
- var pushHashPath = function pushHashPath(path) {
- return window.location.hash = path;
- };
-
- var replaceHashPath = function replaceHashPath(path) {
- var hashIndex = window.location.href.indexOf('#');
-
- window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
- };
-
- var createHashHistory = function createHashHistory() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
- invariant_1$1(canUseDOM, 'Hash history needs a DOM');
-
- var globalHistory = window.history;
- var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
-
- var _props$getUserConfirm = props.getUserConfirmation,
- getUserConfirmation = _props$getUserConfirm === undefined ? getConfirmation : _props$getUserConfirm,
- _props$hashType = props.hashType,
- hashType = _props$hashType === undefined ? 'slash' : _props$hashType;
-
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
-
- var _HashPathCoders$hashT = HashPathCoders[hashType],
- encodePath = _HashPathCoders$hashT.encodePath,
- decodePath = _HashPathCoders$hashT.decodePath;
-
- var getDOMLocation = function getDOMLocation() {
- var path = decodePath(getHashPath());
-
- warning_1(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
-
- if (basename) path = stripBasename(path, basename);
-
- return createLocation(path);
- };
-
- var transitionManager = createTransitionManager();
-
- var setState = function setState(nextState) {
- _extends$2(history, nextState);
-
- history.length = globalHistory.length;
-
- transitionManager.notifyListeners(history.location, history.action);
- };
-
- var forceNextPop = false;
- var ignorePath = null;
-
- var handleHashChange = function handleHashChange() {
- var path = getHashPath();
- var encodedPath = encodePath(path);
-
- if (path !== encodedPath) {
- // Ensure we always have a properly-encoded hash.
- replaceHashPath(encodedPath);
- } else {
- var location = getDOMLocation();
- var prevLocation = history.location;
-
- if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
-
- if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.
-
- ignorePath = null;
-
- handlePop(location);
- }
- };
-
- var handlePop = function handlePop(location) {
- if (forceNextPop) {
- forceNextPop = false;
- setState();
- } else {
- var action = 'POP';
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (ok) {
- setState({ action: action, location: location });
- } else {
- revertPop(location);
- }
- });
- }
- };
-
- var revertPop = function revertPop(fromLocation) {
- var toLocation = history.location;
-
- // TODO: We could probably make this more reliable by
- // keeping a list of paths we've seen in sessionStorage.
- // Instead, we just default to 0 for paths we don't know.
-
- var toIndex = allPaths.lastIndexOf(createPath(toLocation));
-
- if (toIndex === -1) toIndex = 0;
-
- var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
-
- if (fromIndex === -1) fromIndex = 0;
-
- var delta = toIndex - fromIndex;
-
- if (delta) {
- forceNextPop = true;
- go(delta);
- }
- };
-
- // Ensure the hash is encoded properly before doing anything else.
- var path = getHashPath();
- var encodedPath = encodePath(path);
-
- if (path !== encodedPath) replaceHashPath(encodedPath);
-
- var initialLocation = getDOMLocation();
- var allPaths = [createPath(initialLocation)];
-
- // Public interface
-
- var createHref = function createHref(location) {
- return '#' + encodePath(basename + createPath(location));
- };
-
- var push = function push(path, state) {
- warning_1(state === undefined, 'Hash history cannot push state; it is ignored');
-
- var action = 'PUSH';
- var location = createLocation(path, undefined, undefined, history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- var path = createPath(location);
- var encodedPath = encodePath(basename + path);
- var hashChanged = getHashPath() !== encodedPath;
-
- if (hashChanged) {
- // We cannot tell if a hashchange was caused by a PUSH, so we'd
- // rather setState here and ignore the hashchange. The caveat here
- // is that other hash histories in the page will consider it a POP.
- ignorePath = path;
- pushHashPath(encodedPath);
-
- var prevIndex = allPaths.lastIndexOf(createPath(history.location));
- var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
-
- nextPaths.push(path);
- allPaths = nextPaths;
-
- setState({ action: action, location: location });
- } else {
- warning_1(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');
-
- setState();
- }
- });
- };
-
- var replace = function replace(path, state) {
- warning_1(state === undefined, 'Hash history cannot replace state; it is ignored');
-
- var action = 'REPLACE';
- var location = createLocation(path, undefined, undefined, history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- var path = createPath(location);
- var encodedPath = encodePath(basename + path);
- var hashChanged = getHashPath() !== encodedPath;
-
- if (hashChanged) {
- // We cannot tell if a hashchange was caused by a REPLACE, so we'd
- // rather setState here and ignore the hashchange. The caveat here
- // is that other hash histories in the page will consider it a POP.
- ignorePath = path;
- replaceHashPath(encodedPath);
- }
-
- var prevIndex = allPaths.indexOf(createPath(history.location));
-
- if (prevIndex !== -1) allPaths[prevIndex] = path;
-
- setState({ action: action, location: location });
- });
- };
-
- var go = function go(n) {
- warning_1(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');
-
- globalHistory.go(n);
- };
-
- var goBack = function goBack() {
- return go(-1);
- };
-
- var goForward = function goForward() {
- return go(1);
- };
-
- var listenerCount = 0;
-
- var checkDOMListeners = function checkDOMListeners(delta) {
- listenerCount += delta;
-
- if (listenerCount === 1) {
- addEventListener(window, HashChangeEvent$1, handleHashChange);
- } else if (listenerCount === 0) {
- removeEventListener(window, HashChangeEvent$1, handleHashChange);
- }
- };
-
- var isBlocked = false;
-
- var block = function block() {
- var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
-
- var unblock = transitionManager.setPrompt(prompt);
-
- if (!isBlocked) {
- checkDOMListeners(1);
- isBlocked = true;
- }
-
- return function () {
- if (isBlocked) {
- isBlocked = false;
- checkDOMListeners(-1);
- }
-
- return unblock();
- };
- };
-
- var listen = function listen(listener) {
- var unlisten = transitionManager.appendListener(listener);
- checkDOMListeners(1);
-
- return function () {
- checkDOMListeners(-1);
- unlisten();
- };
- };
-
- var history = {
- length: globalHistory.length,
- action: 'POP',
- location: initialLocation,
- createHref: createHref,
- push: push,
- replace: replace,
- go: go,
- goBack: goBack,
- goForward: goForward,
- block: block,
- listen: listen
- };
-
- return history;
- };
-
- var _typeof$2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
-
- var _extends$3 = 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;
- };
-
- var clamp = function clamp(n, lowerBound, upperBound) {
- return Math.min(Math.max(n, lowerBound), upperBound);
- };
-
- /**
- * Creates a history object that stores locations in memory.
- */
- var createMemoryHistory = function createMemoryHistory() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var getUserConfirmation = props.getUserConfirmation,
- _props$initialEntries = props.initialEntries,
- initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries,
- _props$initialIndex = props.initialIndex,
- initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex,
- _props$keyLength = props.keyLength,
- keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;
-
- var transitionManager = createTransitionManager();
-
- var setState = function setState(nextState) {
- _extends$3(history, nextState);
-
- history.length = history.entries.length;
-
- transitionManager.notifyListeners(history.location, history.action);
- };
-
- var createKey = function createKey() {
- return Math.random().toString(36).substr(2, keyLength);
- };
-
- var index = clamp(initialIndex, 0, initialEntries.length - 1);
- var entries = initialEntries.map(function (entry) {
- return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
- });
-
- // Public interface
-
- var createHref = createPath;
-
- var push = function push(path, state) {
- warning_1(!((typeof path === 'undefined' ? 'undefined' : _typeof$2(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
-
- var action = 'PUSH';
- var location = createLocation(path, state, createKey(), history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- var prevIndex = history.index;
- var nextIndex = prevIndex + 1;
-
- var nextEntries = history.entries.slice(0);
- if (nextEntries.length > nextIndex) {
- nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
- } else {
- nextEntries.push(location);
- }
-
- setState({
- action: action,
- location: location,
- index: nextIndex,
- entries: nextEntries
- });
- });
- };
-
- var replace = function replace(path, state) {
- warning_1(!((typeof path === 'undefined' ? 'undefined' : _typeof$2(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
-
- var action = 'REPLACE';
- var location = createLocation(path, state, createKey(), history.location);
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (!ok) return;
-
- history.entries[history.index] = location;
-
- setState({ action: action, location: location });
- });
- };
-
- var go = function go(n) {
- var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
-
- var action = 'POP';
- var location = history.entries[nextIndex];
-
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
- if (ok) {
- setState({
- action: action,
- location: location,
- index: nextIndex
- });
- } else {
- // Mimic the behavior of DOM histories by
- // causing a render after a cancelled POP.
- setState();
- }
- });
- };
-
- var goBack = function goBack() {
- return go(-1);
- };
-
- var goForward = function goForward() {
- return go(1);
- };
-
- var canGo = function canGo(n) {
- var nextIndex = history.index + n;
- return nextIndex >= 0 && nextIndex < history.entries.length;
- };
-
- var block = function block() {
- var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- return transitionManager.setPrompt(prompt);
- };
-
- var listen = function listen(listener) {
- return transitionManager.appendListener(listener);
- };
-
- var history = {
- length: entries.length,
- action: 'POP',
- location: entries[index],
- index: index,
- entries: entries,
- createHref: createHref,
- push: push,
- replace: replace,
- go: go,
- goBack: goBack,
- goForward: goForward,
- canGo: canGo,
- block: block,
- listen: listen
- };
-
- return history;
- };
-
- var _extends$4 = 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;
- };
-
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- /**
- * The public API for putting history on context.
- */
-
- var Router = function (_React$Component) {
- _inherits(Router, _React$Component);
-
- function Router() {
- var _temp, _this, _ret;
-
- _classCallCheck(this, Router);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
- match: _this.computeMatch(_this.props.history.location.pathname)
- }, _temp), _possibleConstructorReturn(_this, _ret);
- }
-
- Router.prototype.getChildContext = function getChildContext() {
- return {
- router: _extends$4({}, this.context.router, {
- history: this.props.history,
- route: {
- location: this.props.history.location,
- match: this.state.match
- }
- })
- };
- };
-
- Router.prototype.computeMatch = function computeMatch(pathname) {
- return {
- path: "/",
- url: "/",
- params: {},
- isExact: pathname === "/"
- };
- };
-
- Router.prototype.componentWillMount = function componentWillMount() {
- var _this2 = this;
-
- var _props = this.props,
- children = _props.children,
- history = _props.history;
-
- invariant_1$1(children == null || React.Children.count(children) === 1, "A <Router> may have only one child element");
-
- // Do this here so we can setState when a <Redirect> changes the
- // location in componentWillMount. This happens e.g. when doing
- // server rendering using a <StaticRouter>.
- this.unlisten = history.listen(function () {
- _this2.setState({
- match: _this2.computeMatch(history.location.pathname)
- });
- });
- };
-
- Router.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- warning_1(this.props.history === nextProps.history, "You cannot change <Router history>");
- };
-
- Router.prototype.componentWillUnmount = function componentWillUnmount() {
- this.unlisten();
- };
-
- Router.prototype.render = function render() {
- var children = this.props.children;
-
- return children ? React.Children.only(children) : null;
- };
-
- return Router;
- }(React.Component);
-
- Router.propTypes = {
- history: propTypes.object.isRequired,
- children: propTypes.node
- };
- Router.contextTypes = {
- router: propTypes.object
- };
- Router.childContextTypes = {
- router: propTypes.object.isRequired
- };
-
- // Written in this round about way for babel-transform-imports
-
- var _typeof$3 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
-
- var classCallCheck = function (instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- };
-
- var _extends$5 = 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;
- };
-
- var inherits = function (subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }
-
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- };
-
- var objectWithoutProperties = function (obj, keys) {
- var target = {};
-
- for (var i in obj) {
- if (keys.indexOf(i) >= 0) continue;
- if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
- target[i] = obj[i];
- }
-
- return target;
- };
-
- var possibleConstructorReturn = function (self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
-
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
- };
-
- /**
- * The public API for a <Router> that uses HTML5 history.
- */
-
- var BrowserRouter = function (_React$Component) {
- inherits(BrowserRouter, _React$Component);
-
- function BrowserRouter() {
- var _temp, _this, _ret;
-
- classCallCheck(this, BrowserRouter);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createBrowserHistory(_this.props), _temp), possibleConstructorReturn(_this, _ret);
- }
-
- BrowserRouter.prototype.componentWillMount = function componentWillMount() {
- warning_1(!this.props.history, "<BrowserRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { BrowserRouter as Router }`.");
- };
-
- BrowserRouter.prototype.render = function render() {
- return React.createElement(Router, { history: this.history, children: this.props.children });
- };
-
- return BrowserRouter;
- }(React.Component);
-
- BrowserRouter.propTypes = {
- basename: propTypes.string,
- forceRefresh: propTypes.bool,
- getUserConfirmation: propTypes.func,
- keyLength: propTypes.number,
- children: propTypes.node
- };
-
- /**
- * The public API for a <Router> that uses window.location.hash.
- */
-
- var HashRouter = function (_React$Component) {
- inherits(HashRouter, _React$Component);
-
- function HashRouter() {
- var _temp, _this, _ret;
-
- classCallCheck(this, HashRouter);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHashHistory(_this.props), _temp), possibleConstructorReturn(_this, _ret);
- }
-
- HashRouter.prototype.componentWillMount = function componentWillMount() {
- warning_1(!this.props.history, "<HashRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { HashRouter as Router }`.");
- };
-
- HashRouter.prototype.render = function render() {
- return React.createElement(Router, { history: this.history, children: this.props.children });
- };
-
- return HashRouter;
- }(React.Component);
-
- HashRouter.propTypes = {
- basename: propTypes.string,
- getUserConfirmation: propTypes.func,
- hashType: propTypes.oneOf(["hashbang", "noslash", "slash"]),
- children: propTypes.node
- };
-
- var isModifiedEvent = function isModifiedEvent(event) {
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
- };
-
- /**
- * The public API for rendering a history-aware <a>.
- */
-
- var Link = function (_React$Component) {
- inherits(Link, _React$Component);
-
- function Link() {
- var _temp, _this, _ret;
-
- classCallCheck(this, Link);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleClick = function (event) {
- if (_this.props.onClick) _this.props.onClick(event);
-
- if (!event.defaultPrevented && // onClick prevented default
- event.button === 0 && // ignore everything but left clicks
- !_this.props.target && // let browser handle "target=_blank" etc.
- !isModifiedEvent(event) // ignore clicks with modifier keys
- ) {
- event.preventDefault();
-
- var history = _this.context.router.history;
- var _this$props = _this.props,
- replace = _this$props.replace,
- to = _this$props.to;
-
-
- if (replace) {
- history.replace(to);
- } else {
- history.push(to);
- }
- }
- }, _temp), possibleConstructorReturn(_this, _ret);
- }
-
- Link.prototype.render = function render() {
- var _props = this.props,
- replace = _props.replace,
- to = _props.to,
- innerRef = _props.innerRef,
- props = objectWithoutProperties(_props, ["replace", "to", "innerRef"]); // eslint-disable-line no-unused-vars
-
- invariant_1$1(this.context.router, "You should not use <Link> outside a <Router>");
-
- invariant_1$1(to !== undefined, 'You must specify the "to" property');
-
- var history = this.context.router.history;
-
- var location = typeof to === "string" ? createLocation(to, null, null, history.location) : to;
-
- var href = history.createHref(location);
- return React.createElement("a", _extends$5({}, props, { onClick: this.handleClick, href: href, ref: innerRef }));
- };
-
- return Link;
- }(React.Component);
-
- Link.propTypes = {
- onClick: propTypes.func,
- target: propTypes.string,
- replace: propTypes.bool,
- to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired,
- innerRef: propTypes.oneOfType([propTypes.string, propTypes.func])
- };
- Link.defaultProps = {
- replace: false
- };
- Link.contextTypes = {
- router: propTypes.shape({
- history: propTypes.shape({
- push: propTypes.func.isRequired,
- replace: propTypes.func.isRequired,
- createHref: propTypes.func.isRequired
- }).isRequired
- }).isRequired
- };
-
- function _classCallCheck$1(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$1(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$1(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- /**
- * The public API for a <Router> that stores location in memory.
- */
-
- var MemoryRouter = function (_React$Component) {
- _inherits$1(MemoryRouter, _React$Component);
-
- function MemoryRouter() {
- var _temp, _this, _ret;
-
- _classCallCheck$1(this, MemoryRouter);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createMemoryHistory(_this.props), _temp), _possibleConstructorReturn$1(_this, _ret);
- }
-
- MemoryRouter.prototype.componentWillMount = function componentWillMount() {
- warning_1(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.");
- };
-
- MemoryRouter.prototype.render = function render() {
- return React.createElement(Router, { history: this.history, children: this.props.children });
- };
-
- return MemoryRouter;
- }(React.Component);
-
- MemoryRouter.propTypes = {
- initialEntries: propTypes.array,
- initialIndex: propTypes.number,
- getUserConfirmation: propTypes.func,
- keyLength: propTypes.number,
- children: propTypes.node
- };
-
- // Written in this round about way for babel-transform-imports
-
- var toString = {}.toString;
-
- var isarray = Array.isArray || function (arr) {
- return toString.call(arr) == '[object Array]';
- };
-
- /**
- * Expose `pathToRegexp`.
- */
- var pathToRegexp_1 = pathToRegexp;
- var parse_1 = parse;
- var compile_1 = compile;
- var tokensToFunction_1 = tokensToFunction;
- var tokensToRegExp_1 = tokensToRegExp;
-
- /**
- * The main path matching regexp utility.
- *
- * @type {RegExp}
- */
- var PATH_REGEXP = new RegExp([
- // Match escaped characters that would otherwise appear in future matches.
- // This allows the user to escape special characters that won't transform.
- '(\\\\.)',
- // Match Express-style parameters and un-named parameters with a prefix
- // and optional suffixes. Matches appear as:
- //
- // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
- // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
- // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
- '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'].join('|'), 'g');
-
- /**
- * Parse a string for the raw tokens.
- *
- * @param {string} str
- * @param {Object=} options
- * @return {!Array}
- */
- function parse(str, options) {
- var tokens = [];
- var key = 0;
- var index = 0;
- var path = '';
- var defaultDelimiter = options && options.delimiter || '/';
- var res;
-
- while ((res = PATH_REGEXP.exec(str)) != null) {
- var m = res[0];
- var escaped = res[1];
- var offset = res.index;
- path += str.slice(index, offset);
- index = offset + m.length;
-
- // Ignore already escaped sequences.
- if (escaped) {
- path += escaped[1];
- continue;
- }
-
- var next = str[index];
- var prefix = res[2];
- var name = res[3];
- var capture = res[4];
- var group = res[5];
- var modifier = res[6];
- var asterisk = res[7];
-
- // Push the current path onto the tokens.
- if (path) {
- tokens.push(path);
- path = '';
- }
-
- var partial = prefix != null && next != null && next !== prefix;
- var repeat = modifier === '+' || modifier === '*';
- var optional = modifier === '?' || modifier === '*';
- var delimiter = res[2] || defaultDelimiter;
- var pattern = capture || group;
-
- tokens.push({
- name: name || key++,
- prefix: prefix || '',
- delimiter: delimiter,
- optional: optional,
- repeat: repeat,
- partial: partial,
- asterisk: !!asterisk,
- pattern: pattern ? escapeGroup(pattern) : asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?'
- });
- }
-
- // Match any characters still remaining.
- if (index < str.length) {
- path += str.substr(index);
- }
-
- // If the path exists, push it onto the end.
- if (path) {
- tokens.push(path);
- }
-
- return tokens;
- }
-
- /**
- * Compile a string to a template function for the path.
- *
- * @param {string} str
- * @param {Object=} options
- * @return {!function(Object=, Object=)}
- */
- function compile(str, options) {
- return tokensToFunction(parse(str, options));
- }
-
- /**
- * Prettier encoding of URI path segments.
- *
- * @param {string}
- * @return {string}
- */
- function encodeURIComponentPretty(str) {
- return encodeURI(str).replace(/[\/?#]/g, function (c) {
- return '%' + c.charCodeAt(0).toString(16).toUpperCase();
- });
- }
-
- /**
- * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
- *
- * @param {string}
- * @return {string}
- */
- function encodeAsterisk(str) {
- return encodeURI(str).replace(/[?#]/g, function (c) {
- return '%' + c.charCodeAt(0).toString(16).toUpperCase();
- });
- }
-
- /**
- * Expose a method for transforming tokens into the path function.
- */
- function tokensToFunction(tokens) {
- // Compile all the tokens into regexps.
- var matches = new Array(tokens.length);
-
- // Compile all the patterns before compilation.
- for (var i = 0; i < tokens.length; i++) {
- if (typeof tokens[i] === 'object') {
- matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
- }
- }
-
- return function (obj, opts) {
- var path = '';
- var data = obj || {};
- var options = opts || {};
- var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
-
- for (var i = 0; i < tokens.length; i++) {
- var token = tokens[i];
-
- if (typeof token === 'string') {
- path += token;
-
- continue;
- }
-
- var value = data[token.name];
- var segment;
-
- if (value == null) {
- if (token.optional) {
- // Prepend partial segment prefixes.
- if (token.partial) {
- path += token.prefix;
- }
-
- continue;
- } else {
- throw new TypeError('Expected "' + token.name + '" to be defined');
- }
- }
-
- if (isarray(value)) {
- if (!token.repeat) {
- throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`');
- }
-
- if (value.length === 0) {
- if (token.optional) {
- continue;
- } else {
- throw new TypeError('Expected "' + token.name + '" to not be empty');
- }
- }
-
- for (var j = 0; j < value.length; j++) {
- segment = encode(value[j]);
-
- if (!matches[i].test(segment)) {
- throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`');
- }
-
- path += (j === 0 ? token.prefix : token.delimiter) + segment;
- }
-
- continue;
- }
-
- segment = token.asterisk ? encodeAsterisk(value) : encode(value);
-
- if (!matches[i].test(segment)) {
- throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"');
- }
-
- path += token.prefix + segment;
- }
-
- return path;
- };
- }
-
- /**
- * Escape a regular expression string.
- *
- * @param {string} str
- * @return {string}
- */
- function escapeString(str) {
- return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1');
- }
-
- /**
- * Escape the capturing group by escaping special characters and meaning.
- *
- * @param {string} group
- * @return {string}
- */
- function escapeGroup(group) {
- return group.replace(/([=!:$\/()])/g, '\\$1');
- }
-
- /**
- * Attach the keys as a property of the regexp.
- *
- * @param {!RegExp} re
- * @param {Array} keys
- * @return {!RegExp}
- */
- function attachKeys(re, keys) {
- re.keys = keys;
- return re;
- }
-
- /**
- * Get the flags for a regexp from the options.
- *
- * @param {Object} options
- * @return {string}
- */
- function flags(options) {
- return options.sensitive ? '' : 'i';
- }
-
- /**
- * Pull out keys from a regexp.
- *
- * @param {!RegExp} path
- * @param {!Array} keys
- * @return {!RegExp}
- */
- function regexpToRegexp(path, keys) {
- // Use a negative lookahead to match only capturing groups.
- var groups = path.source.match(/\((?!\?)/g);
-
- if (groups) {
- for (var i = 0; i < groups.length; i++) {
- keys.push({
- name: i,
- prefix: null,
- delimiter: null,
- optional: false,
- repeat: false,
- partial: false,
- asterisk: false,
- pattern: null
- });
- }
- }
-
- return attachKeys(path, keys);
- }
-
- /**
- * Transform an array into a regexp.
- *
- * @param {!Array} path
- * @param {Array} keys
- * @param {!Object} options
- * @return {!RegExp}
- */
- function arrayToRegexp(path, keys, options) {
- var parts = [];
-
- for (var i = 0; i < path.length; i++) {
- parts.push(pathToRegexp(path[i], keys, options).source);
- }
-
- var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
-
- return attachKeys(regexp, keys);
- }
-
- /**
- * Create a path regexp from string input.
- *
- * @param {string} path
- * @param {!Array} keys
- * @param {!Object} options
- * @return {!RegExp}
- */
- function stringToRegexp(path, keys, options) {
- return tokensToRegExp(parse(path, options), keys, options);
- }
-
- /**
- * Expose a function for taking tokens and returning a RegExp.
- *
- * @param {!Array} tokens
- * @param {(Array|Object)=} keys
- * @param {Object=} options
- * @return {!RegExp}
- */
- function tokensToRegExp(tokens, keys, options) {
- if (!isarray(keys)) {
- options = /** @type {!Object} */keys || options;
- keys = [];
- }
-
- options = options || {};
-
- var strict = options.strict;
- var end = options.end !== false;
- var route = '';
-
- // Iterate over the tokens and create our regexp string.
- for (var i = 0; i < tokens.length; i++) {
- var token = tokens[i];
-
- if (typeof token === 'string') {
- route += escapeString(token);
- } else {
- var prefix = escapeString(token.prefix);
- var capture = '(?:' + token.pattern + ')';
-
- keys.push(token);
-
- if (token.repeat) {
- capture += '(?:' + prefix + capture + ')*';
- }
-
- if (token.optional) {
- if (!token.partial) {
- capture = '(?:' + prefix + '(' + capture + '))?';
- } else {
- capture = prefix + '(' + capture + ')?';
- }
- } else {
- capture = prefix + '(' + capture + ')';
- }
-
- route += capture;
- }
- }
-
- var delimiter = escapeString(options.delimiter || '/');
- var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
-
- // In non-strict mode we allow a slash at the end of match. If the path to
- // match already ends with a slash, we remove it for consistency. The slash
- // is valid at the end of a path match, not in the middle. This is important
- // in non-ending mode, where "/test/" shouldn't match "/test//route".
- if (!strict) {
- route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
- }
-
- if (end) {
- route += '$';
- } else {
- // In non-ending mode, we need the capturing groups to match as much as
- // possible by using a positive lookahead to the end or next path segment.
- route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
- }
-
- return attachKeys(new RegExp('^' + route, flags(options)), keys);
- }
-
- /**
- * Normalize the given path string, returning a regular expression.
- *
- * An empty array can be passed in for the keys, which will hold the
- * placeholder key descriptions. For example, using `/user/:id`, `keys` will
- * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
- *
- * @param {(string|RegExp|Array)} path
- * @param {(Array|Object)=} keys
- * @param {Object=} options
- * @return {!RegExp}
- */
- function pathToRegexp(path, keys, options) {
- if (!isarray(keys)) {
- options = /** @type {!Object} */keys || options;
- keys = [];
- }
-
- options = options || {};
-
- if (path instanceof RegExp) {
- return regexpToRegexp(path, /** @type {!Array} */keys);
- }
-
- if (isarray(path)) {
- return arrayToRegexp( /** @type {!Array} */path, /** @type {!Array} */keys, options);
- }
-
- return stringToRegexp( /** @type {string} */path, /** @type {!Array} */keys, options);
- }
- pathToRegexp_1.parse = parse_1;
- pathToRegexp_1.compile = compile_1;
- pathToRegexp_1.tokensToFunction = tokensToFunction_1;
- pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
-
- var patternCache = {};
- var cacheLimit = 10000;
- var cacheCount = 0;
-
- var compilePath = function compilePath(pattern, options) {
- var cacheKey = "" + options.end + options.strict + options.sensitive;
- var cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
-
- if (cache[pattern]) return cache[pattern];
-
- var keys = [];
- var re = pathToRegexp_1(pattern, keys, options);
- var compiledPattern = { re: re, keys: keys };
-
- if (cacheCount < cacheLimit) {
- cache[pattern] = compiledPattern;
- cacheCount++;
- }
-
- return compiledPattern;
- };
-
- /**
- * Public API for matching a URL pathname to a path pattern.
- */
- var matchPath = function matchPath(pathname) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var parent = arguments[2];
-
- if (typeof options === "string") options = { path: options };
-
- var _options = options,
- path = _options.path,
- _options$exact = _options.exact,
- exact = _options$exact === undefined ? false : _options$exact,
- _options$strict = _options.strict,
- strict = _options$strict === undefined ? false : _options$strict,
- _options$sensitive = _options.sensitive,
- sensitive = _options$sensitive === undefined ? false : _options$sensitive;
-
- if (path == null) return parent;
-
- var _compilePath = compilePath(path, { end: exact, strict: strict, sensitive: sensitive }),
- re = _compilePath.re,
- keys = _compilePath.keys;
-
- var match = re.exec(pathname);
-
- if (!match) return null;
-
- var url = match[0],
- values = match.slice(1);
-
- var isExact = pathname === url;
-
- if (exact && !isExact) return null;
-
- return {
- path: path, // the path pattern used to match
- url: path === "/" && url === "" ? "/" : url, // the matched portion of the URL
- isExact: isExact, // whether or not we matched exactly
- params: keys.reduce(function (memo, key, index) {
- memo[key.name] = values[index];
- return memo;
- }, {})
- };
- };
-
- var _extends$6 = 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;
- };
-
- function _classCallCheck$2(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$2(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$2(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- var isEmptyChildren = function isEmptyChildren(children) {
- return React.Children.count(children) === 0;
- };
-
- /**
- * The public API for matching a single path and rendering.
- */
-
- var Route = function (_React$Component) {
- _inherits$2(Route, _React$Component);
-
- function Route() {
- var _temp, _this, _ret;
-
- _classCallCheck$2(this, Route);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = _possibleConstructorReturn$2(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
- match: _this.computeMatch(_this.props, _this.context.router)
- }, _temp), _possibleConstructorReturn$2(_this, _ret);
- }
-
- Route.prototype.getChildContext = function getChildContext() {
- return {
- router: _extends$6({}, this.context.router, {
- route: {
- location: this.props.location || this.context.router.route.location,
- match: this.state.match
- }
- })
- };
- };
-
- Route.prototype.computeMatch = function computeMatch(_ref, router) {
- var computedMatch = _ref.computedMatch,
- location = _ref.location,
- path = _ref.path,
- strict = _ref.strict,
- exact = _ref.exact,
- sensitive = _ref.sensitive;
-
- if (computedMatch) return computedMatch; // <Switch> already computed the match for us
-
- invariant_1$1(router, "You should not use <Route> or withRouter() outside a <Router>");
-
- var route = router.route;
-
- var pathname = (location || route.location).pathname;
-
- return matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }, route.match);
- };
-
- Route.prototype.componentWillMount = function componentWillMount() {
- warning_1(!(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_1(!(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_1(!(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");
- };
-
- Route.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps, nextContext) {
- warning_1(!(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_1(!(!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.');
-
- this.setState({
- match: this.computeMatch(nextProps, nextContext.router)
- });
- };
-
- Route.prototype.render = function render() {
- var match = this.state.match;
- var _props = this.props,
- children = _props.children,
- component = _props.component,
- render = _props.render;
- var _context$router = this.context.router,
- history = _context$router.history,
- route = _context$router.route,
- staticContext = _context$router.staticContext;
-
- var location = this.props.location || route.location;
- var props = { match: match, location: location, history: history, staticContext: staticContext };
-
- 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;
- };
-
- return Route;
- }(React.Component);
-
- Route.propTypes = {
- computedMatch: propTypes.object, // private, from <Switch>
- path: propTypes.string,
- exact: propTypes.bool,
- strict: propTypes.bool,
- sensitive: propTypes.bool,
- component: propTypes.func,
- render: propTypes.func,
- children: propTypes.oneOfType([propTypes.func, propTypes.node]),
- location: propTypes.object
- };
- Route.contextTypes = {
- router: propTypes.shape({
- history: propTypes.object.isRequired,
- route: propTypes.object.isRequired,
- staticContext: propTypes.object
- })
- };
- Route.childContextTypes = {
- router: propTypes.object.isRequired
- };
-
- // Written in this round about way for babel-transform-imports
-
- /**
- * A <Link> wrapper that knows if it's "active" or not.
- */
- var NavLink = function NavLink(_ref) {
- var to = _ref.to,
- exact = _ref.exact,
- strict = _ref.strict,
- location = _ref.location,
- activeClassName = _ref.activeClassName,
- className = _ref.className,
- activeStyle = _ref.activeStyle,
- style = _ref.style,
- getIsActive = _ref.isActive,
- ariaCurrent = _ref["aria-current"],
- rest = objectWithoutProperties(_ref, ["to", "exact", "strict", "location", "activeClassName", "className", "activeStyle", "style", "isActive", "aria-current"]);
-
- var path = (typeof to === "undefined" ? "undefined" : _typeof$3(to)) === "object" ? to.pathname : to;
-
- // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
- var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
-
- return React.createElement(Route, {
- path: escapedPath,
- exact: exact,
- strict: strict,
- location: location,
- children: function children(_ref2) {
- var location = _ref2.location,
- match = _ref2.match;
-
- var isActive = !!(getIsActive ? getIsActive(match, location) : match);
-
- return React.createElement(Link, _extends$5({
- to: to,
- className: isActive ? [className, activeClassName].filter(function (i) {
- return i;
- }).join(" ") : className,
- style: isActive ? _extends$5({}, style, activeStyle) : style,
- "aria-current": isActive && ariaCurrent || null
- }, rest));
- }
- });
- };
-
- NavLink.propTypes = {
- to: Link.propTypes.to,
- exact: propTypes.bool,
- strict: propTypes.bool,
- location: propTypes.object,
- activeClassName: propTypes.string,
- className: propTypes.string,
- activeStyle: propTypes.object,
- style: propTypes.object,
- isActive: propTypes.func,
- "aria-current": propTypes.oneOf(["page", "step", "location", "date", "time", "true"])
- };
-
- NavLink.defaultProps = {
- activeClassName: "active",
- "aria-current": "page"
- };
-
- function _classCallCheck$3(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$3(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$3(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- /**
- * The public API for prompting the user before navigating away
- * from a screen with a component.
- */
-
- var Prompt = function (_React$Component) {
- _inherits$3(Prompt, _React$Component);
-
- function Prompt() {
- _classCallCheck$3(this, Prompt);
-
- return _possibleConstructorReturn$3(this, _React$Component.apply(this, arguments));
- }
-
- Prompt.prototype.enable = function enable(message) {
- if (this.unblock) this.unblock();
-
- this.unblock = this.context.router.history.block(message);
- };
-
- Prompt.prototype.disable = function disable() {
- if (this.unblock) {
- this.unblock();
- this.unblock = null;
- }
- };
-
- Prompt.prototype.componentWillMount = function componentWillMount() {
- invariant_1$1(this.context.router, "You should not use <Prompt> outside a <Router>");
-
- if (this.props.when) this.enable(this.props.message);
- };
-
- Prompt.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- if (nextProps.when) {
- if (!this.props.when || this.props.message !== nextProps.message) this.enable(nextProps.message);
- } else {
- this.disable();
- }
- };
-
- Prompt.prototype.componentWillUnmount = function componentWillUnmount() {
- this.disable();
- };
-
- Prompt.prototype.render = function render() {
- return null;
- };
-
- return Prompt;
- }(React.Component);
-
- Prompt.propTypes = {
- when: propTypes.bool,
- message: propTypes.oneOfType([propTypes.func, propTypes.string]).isRequired
- };
- Prompt.defaultProps = {
- when: true
- };
- Prompt.contextTypes = {
- router: propTypes.shape({
- history: propTypes.shape({
- block: propTypes.func.isRequired
- }).isRequired
- }).isRequired
- };
-
- // Written in this round about way for babel-transform-imports
-
- var patternCache$1 = {};
- var cacheLimit$1 = 10000;
- var cacheCount$1 = 0;
-
- var compileGenerator = function compileGenerator(pattern) {
- var cacheKey = pattern;
- var cache = patternCache$1[cacheKey] || (patternCache$1[cacheKey] = {});
-
- if (cache[pattern]) return cache[pattern];
-
- var compiledGenerator = pathToRegexp_1.compile(pattern);
-
- if (cacheCount$1 < cacheLimit$1) {
- cache[pattern] = compiledGenerator;
- cacheCount$1++;
- }
-
- return compiledGenerator;
- };
-
- /**
- * Public API for generating a URL pathname from a pattern and parameters.
- */
- var generatePath = function generatePath() {
- var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "/";
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
-
- if (pattern === "/") {
- return pattern;
- }
- var generator = compileGenerator(pattern);
- return generator(params, { pretty: true });
- };
-
- var _extends$7 = 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;
- };
-
- function _classCallCheck$4(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$4(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$4(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- /**
- * The public API for updating the location programmatically
- * with a component.
- */
-
- var Redirect = function (_React$Component) {
- _inherits$4(Redirect, _React$Component);
-
- function Redirect() {
- _classCallCheck$4(this, Redirect);
-
- return _possibleConstructorReturn$4(this, _React$Component.apply(this, arguments));
- }
-
- Redirect.prototype.isStatic = function isStatic() {
- return this.context.router && this.context.router.staticContext;
- };
-
- Redirect.prototype.componentWillMount = function componentWillMount() {
- invariant_1$1(this.context.router, "You should not use <Redirect> outside a <Router>");
-
- if (this.isStatic()) this.perform();
- };
-
- Redirect.prototype.componentDidMount = function componentDidMount() {
- if (!this.isStatic()) this.perform();
- };
-
- Redirect.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
- var prevTo = createLocation(prevProps.to);
- var nextTo = createLocation(this.props.to);
-
- if (locationsAreEqual(prevTo, nextTo)) {
- warning_1(false, "You tried to redirect to the same route you're currently on: " + ("\"" + nextTo.pathname + nextTo.search + "\""));
- return;
- }
-
- this.perform();
- };
-
- Redirect.prototype.computeTo = function computeTo(_ref) {
- var computedMatch = _ref.computedMatch,
- to = _ref.to;
-
- if (computedMatch) {
- if (typeof to === "string") {
- return generatePath(to, computedMatch.params);
- } else {
- return _extends$7({}, to, {
- pathname: generatePath(to.pathname, computedMatch.params)
- });
- }
- }
-
- return to;
- };
-
- Redirect.prototype.perform = function perform() {
- var history = this.context.router.history;
- var push = this.props.push;
-
- var to = this.computeTo(this.props);
-
- if (push) {
- history.push(to);
- } else {
- history.replace(to);
- }
- };
-
- Redirect.prototype.render = function render() {
- return null;
- };
-
- return Redirect;
- }(React.Component);
-
- Redirect.propTypes = {
- computedMatch: propTypes.object, // private, from <Switch>
- push: propTypes.bool,
- from: propTypes.string,
- to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
- };
- Redirect.defaultProps = {
- push: false
- };
- Redirect.contextTypes = {
- router: propTypes.shape({
- history: propTypes.shape({
- push: propTypes.func.isRequired,
- replace: propTypes.func.isRequired
- }).isRequired,
- staticContext: propTypes.object
- }).isRequired
- };
-
- // Written in this round about way for babel-transform-imports
-
- var _extends$8 = 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;
- };
-
- function _objectWithoutProperties(obj, keys) {
- var target = {};for (var i in obj) {
- if (keys.indexOf(i) >= 0) continue;if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;target[i] = obj[i];
- }return target;
- }
-
- function _classCallCheck$5(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$5(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$5(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- var addLeadingSlash$1 = function addLeadingSlash(path) {
- return path.charAt(0) === "/" ? path : "/" + path;
- };
-
- var addBasename = function addBasename(basename, location) {
- if (!basename) return location;
-
- return _extends$8({}, location, {
- pathname: addLeadingSlash$1(basename) + location.pathname
- });
- };
-
- var stripBasename$1 = function stripBasename(basename, location) {
- if (!basename) return location;
-
- var base = addLeadingSlash$1(basename);
-
- if (location.pathname.indexOf(base) !== 0) return location;
-
- return _extends$8({}, location, {
- pathname: location.pathname.substr(base.length)
- });
- };
-
- var createURL = function createURL(location) {
- return typeof location === "string" ? location : createPath(location);
- };
-
- var staticHandler = function staticHandler(methodName) {
- return function () {
- invariant_1$1(false, "You cannot %s with <StaticRouter>", methodName);
- };
- };
-
- var noop = function noop() {};
-
- /**
- * The public top-level API for a "static" <Router>, so-called because it
- * can't actually change the current location. Instead, it just records
- * location changes in a context object. Useful mainly in testing and
- * server-rendering scenarios.
- */
-
- var StaticRouter = function (_React$Component) {
- _inherits$5(StaticRouter, _React$Component);
-
- function StaticRouter() {
- var _temp, _this, _ret;
-
- _classCallCheck$5(this, StaticRouter);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = _possibleConstructorReturn$5(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.createHref = function (path) {
- return addLeadingSlash$1(_this.props.basename + createURL(path));
- }, _this.handlePush = function (location) {
- var _this$props = _this.props,
- basename = _this$props.basename,
- context = _this$props.context;
-
- context.action = "PUSH";
- context.location = addBasename(basename, createLocation(location));
- context.url = createURL(context.location);
- }, _this.handleReplace = function (location) {
- var _this$props2 = _this.props,
- basename = _this$props2.basename,
- context = _this$props2.context;
-
- context.action = "REPLACE";
- context.location = addBasename(basename, createLocation(location));
- context.url = createURL(context.location);
- }, _this.handleListen = function () {
- return noop;
- }, _this.handleBlock = function () {
- return noop;
- }, _temp), _possibleConstructorReturn$5(_this, _ret);
- }
-
- StaticRouter.prototype.getChildContext = function getChildContext() {
- return {
- router: {
- staticContext: this.props.context
- }
- };
- };
-
- StaticRouter.prototype.componentWillMount = function componentWillMount() {
- warning_1(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.");
- };
-
- StaticRouter.prototype.render = function render() {
- var _props = this.props,
- basename = _props.basename,
- context = _props.context,
- location = _props.location,
- props = _objectWithoutProperties(_props, ["basename", "context", "location"]);
-
- var history = {
- createHref: this.createHref,
- action: "POP",
- location: stripBasename$1(basename, createLocation(location)),
- push: this.handlePush,
- replace: this.handleReplace,
- go: staticHandler("go"),
- goBack: staticHandler("goBack"),
- goForward: staticHandler("goForward"),
- listen: this.handleListen,
- block: this.handleBlock
- };
-
- return React.createElement(Router, _extends$8({}, props, { history: history }));
- };
-
- return StaticRouter;
- }(React.Component);
-
- StaticRouter.propTypes = {
- basename: propTypes.string,
- context: propTypes.object.isRequired,
- location: propTypes.oneOfType([propTypes.string, propTypes.object])
- };
- StaticRouter.defaultProps = {
- basename: "",
- location: "/"
- };
- StaticRouter.childContextTypes = {
- router: propTypes.object.isRequired
- };
-
- // Written in this round about way for babel-transform-imports
-
- function _classCallCheck$6(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- function _possibleConstructorReturn$6(self, call) {
- if (!self) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }return call && (typeof call === "object" || typeof call === "function") ? call : self;
- }
-
- function _inherits$6(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
- /**
- * The public API for rendering the first <Route> that matches.
- */
-
- var Switch = function (_React$Component) {
- _inherits$6(Switch, _React$Component);
-
- function Switch() {
- _classCallCheck$6(this, Switch);
-
- return _possibleConstructorReturn$6(this, _React$Component.apply(this, arguments));
- }
-
- Switch.prototype.componentWillMount = function componentWillMount() {
- invariant_1$1(this.context.router, "You should not use <Switch> outside a <Router>");
- };
-
- Switch.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- warning_1(!(nextProps.location && !this.props.location), '<Switch> 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_1(!(!nextProps.location && this.props.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.');
- };
-
- Switch.prototype.render = function render() {
- var route = this.context.router.route;
- var children = this.props.children;
-
- var location = this.props.location || route.location;
-
- var match = void 0,
- child = void 0;
- React.Children.forEach(children, function (element) {
- if (match == null && React.isValidElement(element)) {
- var _element$props = element.props,
- pathProp = _element$props.path,
- exact = _element$props.exact,
- strict = _element$props.strict,
- sensitive = _element$props.sensitive,
- from = _element$props.from;
-
- var path = pathProp || from;
-
- child = element;
- match = matchPath(location.pathname, { path: path, exact: exact, strict: strict, sensitive: sensitive }, route.match);
- }
- });
-
- return match ? React.cloneElement(child, { location: location, computedMatch: match }) : null;
- };
-
- return Switch;
- }(React.Component);
-
- Switch.contextTypes = {
- router: propTypes.shape({
- route: propTypes.object.isRequired
- }).isRequired
- };
- Switch.propTypes = {
- children: propTypes.node,
- location: propTypes.object
- };
-
- // Written in this round about way for babel-transform-imports
-
- // Written in this round about way for babel-transform-imports
-
- // Written in this round about way for babel-transform-imports
-
- var hoistNonReactStatics = createCommonjsModule(function (module, exports) {
- /**
- * Copyright 2015, Yahoo! Inc.
- * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
- */
- (function (global, factory) {
- module.exports = factory();
- })(commonjsGlobal, function () {
-
- var REACT_STATICS = {
- childContextTypes: true,
- contextTypes: true,
- defaultProps: true,
- displayName: true,
- getDefaultProps: true,
- getDerivedStateFromProps: true,
- mixins: true,
- propTypes: true,
- type: true
- };
-
- var KNOWN_STATICS = {
- name: true,
- length: true,
- prototype: true,
- caller: true,
- callee: true,
- arguments: true,
- arity: true
- };
-
- var defineProperty = Object.defineProperty;
- var getOwnPropertyNames = Object.getOwnPropertyNames;
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- var getPrototypeOf = Object.getPrototypeOf;
- var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
-
- return function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
- if (typeof sourceComponent !== 'string') {
- // don't hoist over string (html) components
-
- if (objectPrototype) {
- var inheritedComponent = getPrototypeOf(sourceComponent);
- if (inheritedComponent && inheritedComponent !== objectPrototype) {
- hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
- }
- }
-
- var keys = getOwnPropertyNames(sourceComponent);
-
- if (getOwnPropertySymbols) {
- keys = keys.concat(getOwnPropertySymbols(sourceComponent));
- }
-
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) {
- var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
- try {
- // Avoid failures from read-only properties
- defineProperty(targetComponent, key, descriptor);
- } catch (e) {}
- }
- }
-
- return targetComponent;
- }
-
- return targetComponent;
- };
- });
- });
-
- var _extends$9 = 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;
- };
-
- function _objectWithoutProperties$1(obj, keys) {
- var target = {};for (var i in obj) {
- if (keys.indexOf(i) >= 0) continue;if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;target[i] = obj[i];
- }return target;
- }
-
- /**
- * A public higher-order component to access the imperative API
- */
- var withRouter = function withRouter(Component) {
- var C = function C(props) {
- var wrappedComponentRef = props.wrappedComponentRef,
- remainingProps = _objectWithoutProperties$1(props, ["wrappedComponentRef"]);
-
- return React.createElement(Route, {
- children: function children(routeComponentProps) {
- return React.createElement(Component, _extends$9({}, remainingProps, routeComponentProps, {
- ref: wrappedComponentRef
- }));
- }
- });
- };
-
- C.displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
- C.WrappedComponent = Component;
- C.propTypes = {
- wrappedComponentRef: propTypes.func
- };
-
- return hoistNonReactStatics(C, Component);
- };
-
- // Written in this round about way for babel-transform-imports
-
- exports.BrowserRouter = BrowserRouter;
- exports.HashRouter = HashRouter;
- exports.Link = Link;
- exports.MemoryRouter = MemoryRouter;
- exports.NavLink = NavLink;
- exports.Prompt = Prompt;
- exports.Redirect = Redirect;
- exports.Route = Route;
- exports.Router = Router;
- exports.StaticRouter = StaticRouter;
- exports.Switch = Switch;
- exports.generatePath = generatePath;
- exports.matchPath = matchPath;
- exports.withRouter = withRouter;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
|