1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
- typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
- (global = global || self, factory(global.ReactRouterDOM = {}, global.React));
- }(this, function (exports, React) { 'use strict';
- var React__default = 'default' in React ? React['default'] : React;
- function _setPrototypeOf(o, p) {
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- };
- return _setPrototypeOf(o, p);
- }
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- _setPrototypeOf(subClass, superClass);
- }
- function unwrapExports (x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
- var reactIs_production_min = createCommonjsModule(function (module, exports) {
- Object.defineProperty(exports,"__esModule",{value:!0});
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
- 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118;function x(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
- exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
- exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
- exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
- });
- unwrapExports(reactIs_production_min);
- var reactIs_production_min_1 = reactIs_production_min.typeOf;
- var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
- var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
- var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
- var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
- var reactIs_production_min_6 = reactIs_production_min.Element;
- var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
- var reactIs_production_min_8 = reactIs_production_min.Fragment;
- var reactIs_production_min_9 = reactIs_production_min.Lazy;
- var reactIs_production_min_10 = reactIs_production_min.Memo;
- var reactIs_production_min_11 = reactIs_production_min.Portal;
- var reactIs_production_min_12 = reactIs_production_min.Profiler;
- var reactIs_production_min_13 = reactIs_production_min.StrictMode;
- var reactIs_production_min_14 = reactIs_production_min.Suspense;
- var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
- var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
- var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
- var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
- var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
- var reactIs_production_min_20 = reactIs_production_min.isElement;
- var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
- var reactIs_production_min_22 = reactIs_production_min.isFragment;
- var reactIs_production_min_23 = reactIs_production_min.isLazy;
- var reactIs_production_min_24 = reactIs_production_min.isMemo;
- var reactIs_production_min_25 = reactIs_production_min.isPortal;
- var reactIs_production_min_26 = reactIs_production_min.isProfiler;
- var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
- var reactIs_production_min_28 = reactIs_production_min.isSuspense;
- var reactIs_development = createCommonjsModule(function (module, exports) {
- {
- (function() {
- Object.defineProperty(exports, '__esModule', { value: true });
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
- // nor polyfill, then a plain number is used for performance.
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
- // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
- // (unstable) APIs that have been removed. Can we remove the symbols?
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
- var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
- var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
- function isValidElementType(type) {
- return typeof type === 'string' || typeof type === 'function' ||
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
- }
- /**
- * Forked from fbjs/warning:
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
- *
- * Only change is we use console.warn instead of console.error,
- * and do nothing when 'console' is not supported.
- * This really simplifies the code.
- * ---
- * 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 lowPriorityWarning = function () {};
- {
- var printWarning = function (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.warn(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) {}
- };
- lowPriorityWarning = function (condition, format) {
- if (format === undefined) {
- throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
- 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.apply(undefined, [format].concat(args));
- }
- };
- }
- var lowPriorityWarning$1 = lowPriorityWarning;
- function typeOf(object) {
- if (typeof object === 'object' && object !== null) {
- var $$typeof = object.$$typeof;
- switch ($$typeof) {
- case REACT_ELEMENT_TYPE:
- var type = object.type;
- switch (type) {
- case REACT_ASYNC_MODE_TYPE:
- case REACT_CONCURRENT_MODE_TYPE:
- case REACT_FRAGMENT_TYPE:
- case REACT_PROFILER_TYPE:
- case REACT_STRICT_MODE_TYPE:
- case REACT_SUSPENSE_TYPE:
- return type;
- default:
- var $$typeofType = type && type.$$typeof;
- switch ($$typeofType) {
- case REACT_CONTEXT_TYPE:
- case REACT_FORWARD_REF_TYPE:
- case REACT_PROVIDER_TYPE:
- return $$typeofType;
- default:
- return $$typeof;
- }
- }
- case REACT_LAZY_TYPE:
- case REACT_MEMO_TYPE:
- case REACT_PORTAL_TYPE:
- return $$typeof;
- }
- }
- return undefined;
- }
- // AsyncMode is deprecated along with isAsyncMode
- var AsyncMode = REACT_ASYNC_MODE_TYPE;
- var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
- var ContextConsumer = REACT_CONTEXT_TYPE;
- var ContextProvider = REACT_PROVIDER_TYPE;
- var Element = REACT_ELEMENT_TYPE;
- var ForwardRef = REACT_FORWARD_REF_TYPE;
- var Fragment = REACT_FRAGMENT_TYPE;
- var Lazy = REACT_LAZY_TYPE;
- var Memo = REACT_MEMO_TYPE;
- var Portal = REACT_PORTAL_TYPE;
- var Profiler = REACT_PROFILER_TYPE;
- var StrictMode = REACT_STRICT_MODE_TYPE;
- var Suspense = REACT_SUSPENSE_TYPE;
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
- // AsyncMode should be deprecated
- function isAsyncMode(object) {
- {
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
- hasWarnedAboutDeprecatedIsAsyncMode = true;
- lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
- }
- }
- return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
- }
- function isConcurrentMode(object) {
- return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
- }
- function isContextConsumer(object) {
- return typeOf(object) === REACT_CONTEXT_TYPE;
- }
- function isContextProvider(object) {
- return typeOf(object) === REACT_PROVIDER_TYPE;
- }
- function isElement(object) {
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
- }
- function isForwardRef(object) {
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
- }
- function isFragment(object) {
- return typeOf(object) === REACT_FRAGMENT_TYPE;
- }
- function isLazy(object) {
- return typeOf(object) === REACT_LAZY_TYPE;
- }
- function isMemo(object) {
- return typeOf(object) === REACT_MEMO_TYPE;
- }
- function isPortal(object) {
- return typeOf(object) === REACT_PORTAL_TYPE;
- }
- function isProfiler(object) {
- return typeOf(object) === REACT_PROFILER_TYPE;
- }
- function isStrictMode(object) {
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
- }
- function isSuspense(object) {
- return typeOf(object) === REACT_SUSPENSE_TYPE;
- }
- exports.typeOf = typeOf;
- exports.AsyncMode = AsyncMode;
- exports.ConcurrentMode = ConcurrentMode;
- exports.ContextConsumer = ContextConsumer;
- exports.ContextProvider = ContextProvider;
- exports.Element = Element;
- exports.ForwardRef = ForwardRef;
- exports.Fragment = Fragment;
- exports.Lazy = Lazy;
- exports.Memo = Memo;
- exports.Portal = Portal;
- exports.Profiler = Profiler;
- exports.StrictMode = StrictMode;
- exports.Suspense = Suspense;
- exports.isValidElementType = isValidElementType;
- exports.isAsyncMode = isAsyncMode;
- exports.isConcurrentMode = isConcurrentMode;
- exports.isContextConsumer = isContextConsumer;
- exports.isContextProvider = isContextProvider;
- exports.isElement = isElement;
- exports.isForwardRef = isForwardRef;
- exports.isFragment = isFragment;
- exports.isLazy = isLazy;
- exports.isMemo = isMemo;
- exports.isPortal = isPortal;
- exports.isProfiler = isProfiler;
- exports.isStrictMode = isStrictMode;
- exports.isSuspense = isSuspense;
- })();
- }
- });
- unwrapExports(reactIs_development);
- var reactIs_development_1 = reactIs_development.typeOf;
- var reactIs_development_2 = reactIs_development.AsyncMode;
- var reactIs_development_3 = reactIs_development.ConcurrentMode;
- var reactIs_development_4 = reactIs_development.ContextConsumer;
- var reactIs_development_5 = reactIs_development.ContextProvider;
- var reactIs_development_6 = reactIs_development.Element;
- var reactIs_development_7 = reactIs_development.ForwardRef;
- var reactIs_development_8 = reactIs_development.Fragment;
- var reactIs_development_9 = reactIs_development.Lazy;
- var reactIs_development_10 = reactIs_development.Memo;
- var reactIs_development_11 = reactIs_development.Portal;
- var reactIs_development_12 = reactIs_development.Profiler;
- var reactIs_development_13 = reactIs_development.StrictMode;
- var reactIs_development_14 = reactIs_development.Suspense;
- var reactIs_development_15 = reactIs_development.isValidElementType;
- var reactIs_development_16 = reactIs_development.isAsyncMode;
- var reactIs_development_17 = reactIs_development.isConcurrentMode;
- var reactIs_development_18 = reactIs_development.isContextConsumer;
- var reactIs_development_19 = reactIs_development.isContextProvider;
- var reactIs_development_20 = reactIs_development.isElement;
- var reactIs_development_21 = reactIs_development.isForwardRef;
- var reactIs_development_22 = reactIs_development.isFragment;
- var reactIs_development_23 = reactIs_development.isLazy;
- var reactIs_development_24 = reactIs_development.isMemo;
- var reactIs_development_25 = reactIs_development.isPortal;
- var reactIs_development_26 = reactIs_development.isProfiler;
- var reactIs_development_27 = reactIs_development.isStrictMode;
- var reactIs_development_28 = reactIs_development.isSuspense;
- var reactIs = createCommonjsModule(function (module) {
- {
- module.exports = reactIs_development;
- }
- });
- var reactIs_1 = reactIs.isValidElementType;
- /*
- 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 printWarning = function() {};
- {
- var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
- var loggedTypeFailures = {};
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
- printWarning = function(text) {
- var message = 'Warning: ' + text;
- 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) {}
- };
- }
- /**
- * 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 (has(typeSpecs, 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.
- if (typeof typeSpecs[typeSpecName] !== 'function') {
- var err = Error(
- (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
- );
- err.name = 'Invariant Violation';
- throw err;
- }
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
- } catch (ex) {
- error = ex;
- }
- if (error && !(error instanceof Error)) {
- printWarning(
- (componentName || 'React class') + ': type specification of ' +
- location + ' `' + typeSpecName + '` is invalid; the type checker ' +
- 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
- 'You may have forgotten to pass an argument to the type checker ' +
- 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
- 'shape all require an argument).'
- );
- }
- 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() : '';
- printWarning(
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
- );
- }
- }
- }
- }
- }
- /**
- * Resets warning cache when testing.
- *
- * @private
- */
- checkPropTypes.resetWarningCache = function() {
- {
- loggedTypeFailures = {};
- }
- };
- var checkPropTypes_1 = checkPropTypes;
- var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
- var printWarning$1 = function() {};
- {
- printWarning$1 = function(text) {
- var message = 'Warning: ' + text;
- 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) {}
- };
- }
- function emptyFunctionThatReturnsNull() {
- return null;
- }
- 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(),
- elementType: createElementTypeTypeChecker(),
- 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
- var err = new Error(
- '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'
- );
- err.name = 'Invariant Violation';
- throw err;
- } 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
- ) {
- printWarning$1(
- 'You are manually calling a React.PropTypes validation ' +
- 'function for the `' + propFullName + '` prop on `' + componentName + '`. 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.'
- );
- 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(emptyFunctionThatReturnsNull);
- }
- 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 createElementTypeTypeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- if (!reactIs.isValidElementType(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
- }
- 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)) {
- {
- if (arguments.length > 1) {
- printWarning$1(
- 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
- 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
- );
- } else {
- printWarning$1('Invalid argument supplied to oneOf, expected an array.');
- }
- }
- return emptyFunctionThatReturnsNull;
- }
- 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, function replacer(key, value) {
- var type = getPreciseType(value);
- if (type === 'symbol') {
- return String(value);
- }
- return value;
- });
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(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 (has$1(propValue, 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)) {
- printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
- return emptyFunctionThatReturnsNull;
- }
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (typeof checker !== 'function') {
- printWarning$1(
- 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
- 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
- );
- return emptyFunctionThatReturnsNull;
- }
- }
- 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;
- }
- // falsy value can't be a Symbol
- if (!propValue) {
- return false;
- }
- // 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.resetWarningCache = checkPropTypes_1.resetWarningCache;
- 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 ReactIs = reactIs;
- // 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(ReactIs.isElement, throwOnDirectAccess);
- }
- });
- function _extends() {
- _extends = Object.assign || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
- };
- return _extends.apply(this, arguments);
- }
- 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;
- }
- function warning(condition, message) {
- {
- if (condition) {
- return;
- }
- var text = "Warning: " + message;
- if (typeof console !== 'undefined') {
- console.warn(text);
- }
- try {
- throw Error(text);
- } catch (x) {}
- }
- }
- var prefix = 'Invariant failed';
- function invariant(condition, message) {
- if (condition) {
- return;
- }
- {
- throw new Error(prefix + ": " + (message || ''));
- }
- }
- function addLeadingSlash(path) {
- return path.charAt(0) === '/' ? path : '/' + path;
- }
- function stripLeadingSlash(path) {
- return path.charAt(0) === '/' ? path.substr(1) : path;
- }
- function hasBasename(path, prefix) {
- return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
- }
- function stripBasename(path, prefix) {
- return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
- }
- function stripTrailingSlash(path) {
- return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
- }
- 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
- };
- }
- 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;
- }
- function createLocation(path, state, key, currentLocation) {
- var location;
- 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;
- }
- 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);
- }
- function createTransitionManager() {
- var prompt = null;
- function setPrompt(nextPrompt) {
- warning(prompt == null, 'A history supports only one prompt at a time') ;
- prompt = nextPrompt;
- return function () {
- if (prompt === nextPrompt) prompt = null;
- };
- }
- 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(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 = [];
- function appendListener(fn) {
- var isActive = true;
- function listener() {
- if (isActive) fn.apply(void 0, arguments);
- }
- listeners.push(listener);
- return function () {
- isActive = false;
- listeners = listeners.filter(function (item) {
- return item !== listener;
- });
- };
- }
- function notifyListeners() {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- listeners.forEach(function (listener) {
- return listener.apply(void 0, args);
- });
- }
- return {
- setPrompt: setPrompt,
- confirmTransitionTo: confirmTransitionTo,
- appendListener: appendListener,
- notifyListeners: notifyListeners
- };
- }
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
- function getConfirmation(message, callback) {
- 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
- */
- 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.
- */
- function supportsPopStateOnHashChange() {
- return window.navigator.userAgent.indexOf('Trident') === -1;
- }
- /**
- * Returns false if using go(n) with hash history causes a full page reload.
- */
- 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.
- */
- function isExtraneousPopstateEvent(event) {
- event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
- }
- var PopStateEvent = 'popstate';
- var HashChangeEvent = 'hashchange';
- 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.
- */
- function createBrowserHistory(props) {
- if (props === void 0) {
- props = {};
- }
- !canUseDOM ? invariant(false, 'Browser history needs a DOM') : void 0;
- var globalHistory = window.history;
- var canUseHistory = supportsHistory();
- var needsHashChangeListener = !supportsPopStateOnHashChange();
- var _props = props,
- _props$forceRefresh = _props.forceRefresh,
- forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
- _props$getUserConfirm = _props.getUserConfirmation,
- getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
- _props$keyLength = _props.keyLength,
- keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
- 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(!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);
- }
- function createKey() {
- return Math.random().toString(36).substr(2, keyLength);
- }
- var transitionManager = createTransitionManager();
- function setState(nextState) {
- _extends(history, nextState);
- history.length = globalHistory.length;
- transitionManager.notifyListeners(history.location, history.action);
- }
- function handlePopState(event) {
- // Ignore extraneous popstate events in WebKit.
- if (isExtraneousPopstateEvent(event)) return;
- handlePop(getDOMLocation(event.state));
- }
- function handleHashChange() {
- handlePop(getDOMLocation(getHistoryState()));
- }
- var forceNextPop = false;
- 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);
- }
- });
- }
- }
- 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
- function createHref(location) {
- return basename + createPath(location);
- }
- function push(path, state) {
- warning(!(typeof 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(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') ;
- window.location.href = href;
- }
- });
- }
- function replace(path, state) {
- warning(!(typeof 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(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') ;
- window.location.replace(href);
- }
- });
- }
- function go(n) {
- globalHistory.go(n);
- }
- function goBack() {
- go(-1);
- }
- function goForward() {
- go(1);
- }
- var listenerCount = 0;
- function checkDOMListeners(delta) {
- listenerCount += delta;
- if (listenerCount === 1 && delta === 1) {
- window.addEventListener(PopStateEvent, handlePopState);
- if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
- } else if (listenerCount === 0) {
- window.removeEventListener(PopStateEvent, handlePopState);
- if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
- }
- }
- var isBlocked = false;
- function block(prompt) {
- if (prompt === void 0) {
- prompt = false;
- }
- var unblock = transitionManager.setPrompt(prompt);
- if (!isBlocked) {
- checkDOMListeners(1);
- isBlocked = true;
- }
- return function () {
- if (isBlocked) {
- isBlocked = false;
- checkDOMListeners(-1);
- }
- return unblock();
- };
- }
- 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 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
- }
- };
- 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);
- }
- function pushHashPath(path) {
- window.location.hash = path;
- }
- function replaceHashPath(path) {
- var hashIndex = window.location.href.indexOf('#');
- window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
- }
- function createHashHistory(props) {
- if (props === void 0) {
- props = {};
- }
- !canUseDOM ? invariant(false, 'Hash history needs a DOM') : void 0;
- var globalHistory = window.history;
- var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
- var _props = props,
- _props$getUserConfirm = _props.getUserConfirmation,
- getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
- _props$hashType = _props.hashType,
- hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
- var _HashPathCoders$hashT = HashPathCoders[hashType],
- encodePath = _HashPathCoders$hashT.encodePath,
- decodePath = _HashPathCoders$hashT.decodePath;
- function getDOMLocation() {
- var path = decodePath(getHashPath());
- warning(!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();
- function setState(nextState) {
- _extends(history, nextState);
- history.length = globalHistory.length;
- transitionManager.notifyListeners(history.location, history.action);
- }
- var forceNextPop = false;
- var ignorePath = null;
- 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);
- }
- }
- 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);
- }
- });
- }
- }
- 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
- function createHref(location) {
- return '#' + encodePath(basename + createPath(location));
- }
- function push(path, state) {
- warning(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(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack') ;
- setState();
- }
- });
- }
- function replace(path, state) {
- warning(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
- });
- });
- }
- function go(n) {
- warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser') ;
- globalHistory.go(n);
- }
- function goBack() {
- go(-1);
- }
- function goForward() {
- go(1);
- }
- var listenerCount = 0;
- function checkDOMListeners(delta) {
- listenerCount += delta;
- if (listenerCount === 1 && delta === 1) {
- window.addEventListener(HashChangeEvent$1, handleHashChange);
- } else if (listenerCount === 0) {
- window.removeEventListener(HashChangeEvent$1, handleHashChange);
- }
- }
- var isBlocked = false;
- function block(prompt) {
- if (prompt === void 0) {
- prompt = false;
- }
- var unblock = transitionManager.setPrompt(prompt);
- if (!isBlocked) {
- checkDOMListeners(1);
- isBlocked = true;
- }
- return function () {
- if (isBlocked) {
- isBlocked = false;
- checkDOMListeners(-1);
- }
- return unblock();
- };
- }
- 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;
- }
- function clamp(n, lowerBound, upperBound) {
- return Math.min(Math.max(n, lowerBound), upperBound);
- }
- /**
- * Creates a history object that stores locations in memory.
- */
- function createMemoryHistory(props) {
- if (props === void 0) {
- props = {};
- }
- var _props = props,
- getUserConfirmation = _props.getUserConfirmation,
- _props$initialEntries = _props.initialEntries,
- initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
- _props$initialIndex = _props.initialIndex,
- initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
- _props$keyLength = _props.keyLength,
- keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
- var transitionManager = createTransitionManager();
- function setState(nextState) {
- _extends(history, nextState);
- history.length = history.entries.length;
- transitionManager.notifyListeners(history.location, history.action);
- }
- 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;
- function push(path, state) {
- warning(!(typeof 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
- });
- });
- }
- function replace(path, state) {
- warning(!(typeof 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
- });
- });
- }
- 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();
- }
- });
- }
- function goBack() {
- go(-1);
- }
- function goForward() {
- go(1);
- }
- function canGo(n) {
- var nextIndex = history.index + n;
- return nextIndex >= 0 && nextIndex < history.entries.length;
- }
- function block(prompt) {
- if (prompt === void 0) {
- prompt = false;
- }
- return transitionManager.setPrompt(prompt);
- }
- 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 MAX_SIGNED_31_BIT_INT = 1073741823;
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
- function getUniqueId() {
- var key = '__global_unique_id__';
- return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
- }
- function objectIs(x, y) {
- if (x === y) {
- return x !== 0 || 1 / x === 1 / y;
- } else {
- return x !== x && y !== y;
- }
- }
- function createEventEmitter(value) {
- var handlers = [];
- return {
- on: function on(handler) {
- handlers.push(handler);
- },
- off: function off(handler) {
- handlers = handlers.filter(function (h) {
- return h !== handler;
- });
- },
- get: function get() {
- return value;
- },
- set: function set(newValue, changedBits) {
- value = newValue;
- handlers.forEach(function (handler) {
- return handler(value, changedBits);
- });
- }
- };
- }
- function onlyChild(children) {
- return Array.isArray(children) ? children[0] : children;
- }
- function createReactContext(defaultValue, calculateChangedBits) {
- var _Provider$childContex, _Consumer$contextType;
- var contextProp = '__create-react-context-' + getUniqueId() + '__';
- var Provider = /*#__PURE__*/function (_Component) {
- _inheritsLoose(Provider, _Component);
- function Provider() {
- var _this;
- _this = _Component.apply(this, arguments) || this;
- _this.emitter = createEventEmitter(_this.props.value);
- return _this;
- }
- var _proto = Provider.prototype;
- _proto.getChildContext = function getChildContext() {
- var _ref;
- return _ref = {}, _ref[contextProp] = this.emitter, _ref;
- };
- _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- if (this.props.value !== nextProps.value) {
- var oldValue = this.props.value;
- var newValue = nextProps.value;
- var changedBits;
- if (objectIs(oldValue, newValue)) {
- changedBits = 0;
- } else {
- changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
- {
- warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
- }
- changedBits |= 0;
- if (changedBits !== 0) {
- this.emitter.set(nextProps.value, changedBits);
- }
- }
- }
- };
- _proto.render = function render() {
- return this.props.children;
- };
- return Provider;
- }(React.Component);
- Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
- var Consumer = /*#__PURE__*/function (_Component2) {
- _inheritsLoose(Consumer, _Component2);
- function Consumer() {
- var _this2;
- _this2 = _Component2.apply(this, arguments) || this;
- _this2.state = {
- value: _this2.getValue()
- };
- _this2.onUpdate = function (newValue, changedBits) {
- var observedBits = _this2.observedBits | 0;
- if ((observedBits & changedBits) !== 0) {
- _this2.setState({
- value: _this2.getValue()
- });
- }
- };
- return _this2;
- }
- var _proto2 = Consumer.prototype;
- _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- var observedBits = nextProps.observedBits;
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
- };
- _proto2.componentDidMount = function componentDidMount() {
- if (this.context[contextProp]) {
- this.context[contextProp].on(this.onUpdate);
- }
- var observedBits = this.props.observedBits;
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
- };
- _proto2.componentWillUnmount = function componentWillUnmount() {
- if (this.context[contextProp]) {
- this.context[contextProp].off(this.onUpdate);
- }
- };
- _proto2.getValue = function getValue() {
- if (this.context[contextProp]) {
- return this.context[contextProp].get();
- } else {
- return defaultValue;
- }
- };
- _proto2.render = function render() {
- return onlyChild(this.props.children)(this.state.value);
- };
- return Consumer;
- }(React.Component);
- Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = propTypes.object, _Consumer$contextType);
- return {
- Provider: Provider,
- Consumer: Consumer
- };
- }
- var index = React__default.createContext || createReactContext;
- var isarray = Array.isArray || function (arr) {
- return Object.prototype.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;
- function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
- return target;
- }
- /**
- * Copyright 2015, Yahoo! Inc.
- * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
- */
- var REACT_STATICS = {
- childContextTypes: true,
- contextType: true,
- contextTypes: true,
- defaultProps: true,
- displayName: true,
- getDefaultProps: true,
- getDerivedStateFromError: 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 FORWARD_REF_STATICS = {
- '$$typeof': true,
- render: true,
- defaultProps: true,
- displayName: true,
- propTypes: true
- };
- var MEMO_STATICS = {
- '$$typeof': true,
- compare: true,
- defaultProps: true,
- displayName: true,
- propTypes: true,
- type: true
- };
- var TYPE_STATICS = {};
- TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
- function getStatics(component) {
- if (reactIs.isMemo(component)) {
- return MEMO_STATICS;
- }
- return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
- }
- var defineProperty = Object.defineProperty;
- var getOwnPropertyNames = Object.getOwnPropertyNames;
- var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- var getPrototypeOf = Object.getPrototypeOf;
- var objectPrototype = Object.prototype;
- 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$1) {
- keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
- }
- var targetStatics = getStatics(targetComponent);
- var sourceStatics = getStatics(sourceComponent);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
- var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
- try {
- // Avoid failures from read-only properties
- defineProperty(targetComponent, key, descriptor);
- } catch (e) {}
- }
- }
- return targetComponent;
- }
- return targetComponent;
- }
- var hoistNonReactStatics_cjs = hoistNonReactStatics;
- var createNamedContext = function createNamedContext(name) {
- var context = index();
- context.displayName = name;
- return context;
- };
- var historyContext = /*#__PURE__*/createNamedContext("Router-History");
- var context = /*#__PURE__*/createNamedContext("Router");
- /**
- * The public API for putting history on context.
- */
- var Router = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(Router, _React$Component);
- Router.computeRootMatch = function computeRootMatch(pathname) {
- return {
- path: "/",
- url: "/",
- params: {},
- isExact: pathname === "/"
- };
- };
- function Router(props) {
- var _this;
- _this = _React$Component.call(this, props) || this;
- _this.state = {
- location: props.history.location
- }; // This is a bit of a hack. We have to start listening for location
- // changes here in the constructor in case there are any <Redirect>s
- // on the initial render. If there are, they will replace/push when
- // they mount and since cDM fires in children before parents, we may
- // get a new location before the <Router> is mounted.
- _this._isMounted = false;
- _this._pendingLocation = null;
- if (!props.staticContext) {
- _this.unlisten = props.history.listen(function (location) {
- if (_this._isMounted) {
- _this.setState({
- location: location
- });
- } else {
- _this._pendingLocation = location;
- }
- });
- }
- return _this;
- }
- var _proto = Router.prototype;
- _proto.componentDidMount = function componentDidMount() {
- this._isMounted = true;
- if (this._pendingLocation) {
- this.setState({
- location: this._pendingLocation
- });
- }
- };
- _proto.componentWillUnmount = function componentWillUnmount() {
- if (this.unlisten) {
- this.unlisten();
- this._isMounted = false;
- this._pendingLocation = null;
- }
- };
- _proto.render = function render() {
- return /*#__PURE__*/React__default.createElement(context.Provider, {
- value: {
- history: this.props.history,
- location: this.state.location,
- match: Router.computeRootMatch(this.state.location.pathname),
- staticContext: this.props.staticContext
- }
- }, /*#__PURE__*/React__default.createElement(historyContext.Provider, {
- children: this.props.children || null,
- value: this.props.history
- }));
- };
- return Router;
- }(React__default.Component);
- {
- Router.propTypes = {
- children: propTypes.node,
- history: propTypes.object.isRequired,
- staticContext: propTypes.object
- };
- Router.prototype.componentDidUpdate = function (prevProps) {
- warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
- };
- }
- /**
- * The public API for a <Router> that stores location in memory.
- */
- var MemoryRouter = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(MemoryRouter, _React$Component);
- function MemoryRouter() {
- var _this;
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
- _this.history = createMemoryHistory(_this.props);
- return _this;
- }
- var _proto = MemoryRouter.prototype;
- _proto.render = function render() {
- return /*#__PURE__*/React__default.createElement(Router, {
- history: this.history,
- children: this.props.children
- });
- };
- return MemoryRouter;
- }(React__default.Component);
- {
- MemoryRouter.propTypes = {
- initialEntries: propTypes.array,
- initialIndex: propTypes.number,
- getUserConfirmation: propTypes.func,
- keyLength: propTypes.number,
- children: propTypes.node
- };
- MemoryRouter.prototype.componentDidMount = function () {
- warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
- };
- }
- var Lifecycle = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(Lifecycle, _React$Component);
- function Lifecycle() {
- return _React$Component.apply(this, arguments) || this;
- }
- var _proto = Lifecycle.prototype;
- _proto.componentDidMount = function componentDidMount() {
- if (this.props.onMount) this.props.onMount.call(this, this);
- };
- _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
- if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
- };
- _proto.componentWillUnmount = function componentWillUnmount() {
- if (this.props.onUnmount) this.props.onUnmount.call(this, this);
- };
- _proto.render = function render() {
- return null;
- };
- return Lifecycle;
- }(React__default.Component);
- /**
- * The public API for prompting the user before navigating away from a screen.
- */
- function Prompt(_ref) {
- var message = _ref.message,
- _ref$when = _ref.when,
- when = _ref$when === void 0 ? true : _ref$when;
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
- if (!when || context.staticContext) return null;
- var method = context.history.block;
- return /*#__PURE__*/React__default.createElement(Lifecycle, {
- onMount: function onMount(self) {
- self.release = method(message);
- },
- onUpdate: function onUpdate(self, prevProps) {
- if (prevProps.message !== message) {
- self.release();
- self.release = method(message);
- }
- },
- onUnmount: function onUnmount(self) {
- self.release();
- },
- message: message
- });
- });
- }
- {
- var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
- Prompt.propTypes = {
- when: propTypes.bool,
- message: messageType.isRequired
- };
- }
- var cache = {};
- var cacheLimit = 10000;
- var cacheCount = 0;
- function compilePath(path) {
- if (cache[path]) return cache[path];
- var generator = pathToRegexp_1.compile(path);
- if (cacheCount < cacheLimit) {
- cache[path] = generator;
- cacheCount++;
- }
- return generator;
- }
- /**
- * Public API for generating a URL pathname from a path and parameters.
- */
- function generatePath(path, params) {
- if (path === void 0) {
- path = "/";
- }
- if (params === void 0) {
- params = {};
- }
- return path === "/" ? path : compilePath(path)(params, {
- pretty: true
- });
- }
- /**
- * The public API for navigating programmatically with a component.
- */
- function Redirect(_ref) {
- var computedMatch = _ref.computedMatch,
- to = _ref.to,
- _ref$push = _ref.push,
- push = _ref$push === void 0 ? false : _ref$push;
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
- var history = context.history,
- staticContext = context.staticContext;
- var method = push ? history.push : history.replace;
- var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
- pathname: generatePath(to.pathname, computedMatch.params)
- }) : to); // When rendering in a static context,
- // set the new location immediately.
- if (staticContext) {
- method(location);
- return null;
- }
- return /*#__PURE__*/React__default.createElement(Lifecycle, {
- onMount: function onMount() {
- method(location);
- },
- onUpdate: function onUpdate(self, prevProps) {
- var prevLocation = createLocation(prevProps.to);
- if (!locationsAreEqual(prevLocation, _extends({}, location, {
- key: prevLocation.key
- }))) {
- method(location);
- }
- },
- to: to
- });
- });
- }
- {
- Redirect.propTypes = {
- push: propTypes.bool,
- from: propTypes.string,
- to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
- };
- }
- var cache$1 = {};
- var cacheLimit$1 = 10000;
- var cacheCount$1 = 0;
- function compilePath$1(path, options) {
- var cacheKey = "" + options.end + options.strict + options.sensitive;
- var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
- if (pathCache[path]) return pathCache[path];
- var keys = [];
- var regexp = pathToRegexp_1(path, keys, options);
- var result = {
- regexp: regexp,
- keys: keys
- };
- if (cacheCount$1 < cacheLimit$1) {
- pathCache[path] = result;
- cacheCount$1++;
- }
- return result;
- }
- /**
- * Public API for matching a URL pathname to a path.
- */
- function matchPath(pathname, options) {
- if (options === void 0) {
- options = {};
- }
- if (typeof options === "string" || Array.isArray(options)) {
- options = {
- path: options
- };
- }
- var _options = options,
- path = _options.path,
- _options$exact = _options.exact,
- exact = _options$exact === void 0 ? false : _options$exact,
- _options$strict = _options.strict,
- strict = _options$strict === void 0 ? false : _options$strict,
- _options$sensitive = _options.sensitive,
- sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
- var paths = [].concat(path);
- return paths.reduce(function (matched, path) {
- if (!path && path !== "") return null;
- if (matched) return matched;
- var _compilePath = compilePath$1(path, {
- end: exact,
- strict: strict,
- sensitive: sensitive
- }),
- regexp = _compilePath.regexp,
- keys = _compilePath.keys;
- var match = regexp.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 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;
- }, {})
- };
- }, null);
- }
- function isEmptyChildren(children) {
- return React__default.Children.count(children) === 0;
- }
- function evalChildrenDev(children, props, path) {
- var value = children(props);
- warning(value !== undefined, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") ;
- return value || null;
- }
- /**
- * The public API for matching a single path and rendering.
- */
- var Route = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(Route, _React$Component);
- function Route() {
- return _React$Component.apply(this, arguments) || this;
- }
- var _proto = Route.prototype;
- _proto.render = function render() {
- var _this = this;
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context$1) {
- !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
- var location = _this.props.location || context$1.location;
- var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
- : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
- var props = _extends({}, context$1, {
- location: location,
- match: match
- });
- var _this$props = _this.props,
- children = _this$props.children,
- component = _this$props.component,
- render = _this$props.render; // Preact uses an empty array as children by
- // default, so use null if that's the case.
- if (Array.isArray(children) && isEmptyChildren(children)) {
- children = null;
- }
- return /*#__PURE__*/React__default.createElement(context.Provider, {
- value: props
- }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? /*#__PURE__*/React__default.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
- });
- };
- return Route;
- }(React__default.Component);
- {
- Route.propTypes = {
- children: propTypes.oneOfType([propTypes.func, propTypes.node]),
- component: function component(props, propName) {
- if (props[propName] && !reactIs_1(props[propName])) {
- return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
- }
- },
- exact: propTypes.bool,
- location: propTypes.object,
- path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
- render: propTypes.func,
- sensitive: propTypes.bool,
- strict: propTypes.bool
- };
- Route.prototype.componentDidMount = function () {
- warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.component), "You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored") ;
- warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.render), "You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored") ;
- warning(!(this.props.component && this.props.render), "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored") ;
- };
- Route.prototype.componentDidUpdate = function (prevProps) {
- warning(!(this.props.location && !prevProps.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(!(!this.props.location && prevProps.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.') ;
- };
- }
- function addLeadingSlash$1(path) {
- return path.charAt(0) === "/" ? path : "/" + path;
- }
- function addBasename(basename, location) {
- if (!basename) return location;
- return _extends({}, location, {
- pathname: addLeadingSlash$1(basename) + location.pathname
- });
- }
- function stripBasename$1(basename, location) {
- if (!basename) return location;
- var base = addLeadingSlash$1(basename);
- if (location.pathname.indexOf(base) !== 0) return location;
- return _extends({}, location, {
- pathname: location.pathname.substr(base.length)
- });
- }
- function createURL(location) {
- return typeof location === "string" ? location : createPath(location);
- }
- function staticHandler(methodName) {
- return function () {
- invariant(false, "You cannot %s with <StaticRouter>") ;
- };
- }
- 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 = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(StaticRouter, _React$Component);
- function StaticRouter() {
- var _this;
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
- _this.handlePush = function (location) {
- return _this.navigateTo(location, "PUSH");
- };
- _this.handleReplace = function (location) {
- return _this.navigateTo(location, "REPLACE");
- };
- _this.handleListen = function () {
- return noop;
- };
- _this.handleBlock = function () {
- return noop;
- };
- return _this;
- }
- var _proto = StaticRouter.prototype;
- _proto.navigateTo = function navigateTo(location, action) {
- var _this$props = this.props,
- _this$props$basename = _this$props.basename,
- basename = _this$props$basename === void 0 ? "" : _this$props$basename,
- _this$props$context = _this$props.context,
- context = _this$props$context === void 0 ? {} : _this$props$context;
- context.action = action;
- context.location = addBasename(basename, createLocation(location));
- context.url = createURL(context.location);
- };
- _proto.render = function render() {
- var _this$props2 = this.props,
- _this$props2$basename = _this$props2.basename,
- basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
- _this$props2$context = _this$props2.context,
- context = _this$props2$context === void 0 ? {} : _this$props2$context,
- _this$props2$location = _this$props2.location,
- location = _this$props2$location === void 0 ? "/" : _this$props2$location,
- rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
- var history = {
- createHref: function createHref(path) {
- return addLeadingSlash$1(basename + createURL(path));
- },
- action: "POP",
- location: stripBasename$1(basename, createLocation(location)),
- push: this.handlePush,
- replace: this.handleReplace,
- go: staticHandler(),
- goBack: staticHandler(),
- goForward: staticHandler(),
- listen: this.handleListen,
- block: this.handleBlock
- };
- return /*#__PURE__*/React__default.createElement(Router, _extends({}, rest, {
- history: history,
- staticContext: context
- }));
- };
- return StaticRouter;
- }(React__default.Component);
- {
- StaticRouter.propTypes = {
- basename: propTypes.string,
- context: propTypes.object,
- location: propTypes.oneOfType([propTypes.string, propTypes.object])
- };
- StaticRouter.prototype.componentDidMount = function () {
- warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
- };
- }
- /**
- * The public API for rendering the first <Route> that matches.
- */
- var Switch = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(Switch, _React$Component);
- function Switch() {
- return _React$Component.apply(this, arguments) || this;
- }
- var _proto = Switch.prototype;
- _proto.render = function render() {
- var _this = this;
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
- var location = _this.props.location || context.location;
- var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
- // here because toArray adds keys to all child elements and we do not want
- // to trigger an unmount/remount for two <Route>s that render the same
- // component at different URLs.
- React__default.Children.forEach(_this.props.children, function (child) {
- if (match == null && /*#__PURE__*/React__default.isValidElement(child)) {
- element = child;
- var path = child.props.path || child.props.from;
- match = path ? matchPath(location.pathname, _extends({}, child.props, {
- path: path
- })) : context.match;
- }
- });
- return match ? /*#__PURE__*/React__default.cloneElement(element, {
- location: location,
- computedMatch: match
- }) : null;
- });
- };
- return Switch;
- }(React__default.Component);
- {
- Switch.propTypes = {
- children: propTypes.node,
- location: propTypes.object
- };
- Switch.prototype.componentDidUpdate = function (prevProps) {
- warning(!(this.props.location && !prevProps.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(!(!this.props.location && prevProps.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.') ;
- };
- }
- /**
- * A public higher-order component to access the imperative API
- */
- function withRouter(Component) {
- var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
- var C = function C(props) {
- var wrappedComponentRef = props.wrappedComponentRef,
- remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
- return /*#__PURE__*/React__default.createElement(Component, _extends({}, remainingProps, context, {
- ref: wrappedComponentRef
- }));
- });
- };
- C.displayName = displayName;
- C.WrappedComponent = Component;
- {
- C.propTypes = {
- wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
- };
- }
- return hoistNonReactStatics_cjs(C, Component);
- }
- var useContext = React__default.useContext;
- function useHistory() {
- {
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
- }
- return useContext(historyContext);
- }
- function useLocation() {
- {
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
- }
- return useContext(context).location;
- }
- function useParams() {
- {
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
- }
- var match = useContext(context).match;
- return match ? match.params : {};
- }
- function useRouteMatch(path) {
- {
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
- }
- var location = useLocation();
- var match = useContext(context).match;
- return path ? matchPath(location.pathname, path) : match;
- }
- {
- if (typeof window !== "undefined") {
- var global$1 = window;
- var key = "__react_router_build__";
- var buildNames = {
- cjs: "CommonJS",
- esm: "ES modules",
- umd: "UMD"
- };
- if (global$1[key] && global$1[key] !== "esm") {
- var initialBuildName = buildNames[global$1[key]];
- var secondaryBuildName = buildNames["esm"]; // TODO: Add link to article that explains in detail how to avoid
- // loading 2 different builds.
- throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
- }
- global$1[key] = "esm";
- }
- }
- /**
- * The public API for a <Router> that uses HTML5 history.
- */
- var BrowserRouter = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(BrowserRouter, _React$Component);
- function BrowserRouter() {
- var _this;
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
- _this.history = createBrowserHistory(_this.props);
- return _this;
- }
- var _proto = BrowserRouter.prototype;
- _proto.render = function render() {
- return /*#__PURE__*/React__default.createElement(Router, {
- history: this.history,
- children: this.props.children
- });
- };
- return BrowserRouter;
- }(React__default.Component);
- {
- BrowserRouter.propTypes = {
- basename: propTypes.string,
- children: propTypes.node,
- forceRefresh: propTypes.bool,
- getUserConfirmation: propTypes.func,
- keyLength: propTypes.number
- };
- BrowserRouter.prototype.componentDidMount = function () {
- warning(!this.props.history, "<BrowserRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { BrowserRouter as Router }`.") ;
- };
- }
- /**
- * The public API for a <Router> that uses window.location.hash.
- */
- var HashRouter = /*#__PURE__*/function (_React$Component) {
- _inheritsLoose(HashRouter, _React$Component);
- function HashRouter() {
- var _this;
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
- _this.history = createHashHistory(_this.props);
- return _this;
- }
- var _proto = HashRouter.prototype;
- _proto.render = function render() {
- return /*#__PURE__*/React__default.createElement(Router, {
- history: this.history,
- children: this.props.children
- });
- };
- return HashRouter;
- }(React__default.Component);
- {
- HashRouter.propTypes = {
- basename: propTypes.string,
- children: propTypes.node,
- getUserConfirmation: propTypes.func,
- hashType: propTypes.oneOf(["hashbang", "noslash", "slash"])
- };
- HashRouter.prototype.componentDidMount = function () {
- warning(!this.props.history, "<HashRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { HashRouter as Router }`.") ;
- };
- }
- var resolveToLocation = function resolveToLocation(to, currentLocation) {
- return typeof to === "function" ? to(currentLocation) : to;
- };
- var normalizeToLocation = function normalizeToLocation(to, currentLocation) {
- return typeof to === "string" ? createLocation(to, null, null, currentLocation) : to;
- };
- var forwardRefShim = function forwardRefShim(C) {
- return C;
- };
- var forwardRef = React__default.forwardRef;
- if (typeof forwardRef === "undefined") {
- forwardRef = forwardRefShim;
- }
- function isModifiedEvent(event) {
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
- }
- var LinkAnchor = forwardRef(function (_ref, forwardedRef) {
- var innerRef = _ref.innerRef,
- navigate = _ref.navigate,
- _onClick = _ref.onClick,
- rest = _objectWithoutPropertiesLoose(_ref, ["innerRef", "navigate", "onClick"]);
- var target = rest.target;
- var props = _extends({}, rest, {
- onClick: function onClick(event) {
- try {
- if (_onClick) _onClick(event);
- } catch (ex) {
- event.preventDefault();
- throw ex;
- }
- if (!event.defaultPrevented && // onClick prevented default
- event.button === 0 && ( // ignore everything but left clicks
- !target || target === "_self") && // let browser handle "target=_blank" etc.
- !isModifiedEvent(event) // ignore clicks with modifier keys
- ) {
- event.preventDefault();
- navigate();
- }
- }
- }); // React 15 compat
- if (forwardRefShim !== forwardRef) {
- props.ref = forwardedRef || innerRef;
- } else {
- props.ref = innerRef;
- }
- /* eslint-disable-next-line jsx-a11y/anchor-has-content */
- return /*#__PURE__*/React__default.createElement("a", props);
- });
- {
- LinkAnchor.displayName = "LinkAnchor";
- }
- /**
- * The public API for rendering a history-aware <a>.
- */
- var Link = forwardRef(function (_ref2, forwardedRef) {
- var _ref2$component = _ref2.component,
- component = _ref2$component === void 0 ? LinkAnchor : _ref2$component,
- replace = _ref2.replace,
- to = _ref2.to,
- innerRef = _ref2.innerRef,
- rest = _objectWithoutPropertiesLoose(_ref2, ["component", "replace", "to", "innerRef"]);
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <Link> outside a <Router>") : void 0;
- var history = context.history;
- var location = normalizeToLocation(resolveToLocation(to, context.location), context.location);
- var href = location ? history.createHref(location) : "";
- var props = _extends({}, rest, {
- href: href,
- navigate: function navigate() {
- var location = resolveToLocation(to, context.location);
- var isDuplicateNavigation = createPath(context.location) === createPath(normalizeToLocation(location));
- var method = replace || isDuplicateNavigation ? history.replace : history.push;
- method(location);
- }
- }); // React 15 compat
- if (forwardRefShim !== forwardRef) {
- props.ref = forwardedRef || innerRef;
- } else {
- props.innerRef = innerRef;
- }
- return /*#__PURE__*/React__default.createElement(component, props);
- });
- });
- {
- var toType = propTypes.oneOfType([propTypes.string, propTypes.object, propTypes.func]);
- var refType = propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.shape({
- current: propTypes.any
- })]);
- Link.displayName = "Link";
- Link.propTypes = {
- innerRef: refType,
- onClick: propTypes.func,
- replace: propTypes.bool,
- target: propTypes.string,
- to: toType.isRequired
- };
- }
- var forwardRefShim$1 = function forwardRefShim(C) {
- return C;
- };
- var forwardRef$1 = React__default.forwardRef;
- if (typeof forwardRef$1 === "undefined") {
- forwardRef$1 = forwardRefShim$1;
- }
- function joinClassnames() {
- for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
- classnames[_key] = arguments[_key];
- }
- return classnames.filter(function (i) {
- return i;
- }).join(" ");
- }
- /**
- * A <Link> wrapper that knows if it's "active" or not.
- */
- var NavLink = forwardRef$1(function (_ref, forwardedRef) {
- var _ref$ariaCurrent = _ref["aria-current"],
- ariaCurrent = _ref$ariaCurrent === void 0 ? "page" : _ref$ariaCurrent,
- _ref$activeClassName = _ref.activeClassName,
- activeClassName = _ref$activeClassName === void 0 ? "active" : _ref$activeClassName,
- activeStyle = _ref.activeStyle,
- classNameProp = _ref.className,
- exact = _ref.exact,
- isActiveProp = _ref.isActive,
- locationProp = _ref.location,
- sensitive = _ref.sensitive,
- strict = _ref.strict,
- styleProp = _ref.style,
- to = _ref.to,
- innerRef = _ref.innerRef,
- rest = _objectWithoutPropertiesLoose(_ref, ["aria-current", "activeClassName", "activeStyle", "className", "exact", "isActive", "location", "sensitive", "strict", "style", "to", "innerRef"]);
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
- !context ? invariant(false, "You should not use <NavLink> outside a <Router>") : void 0;
- var currentLocation = locationProp || context.location;
- var toLocation = normalizeToLocation(resolveToLocation(to, currentLocation), currentLocation);
- var path = toLocation.pathname; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
- var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
- var match = escapedPath ? matchPath(currentLocation.pathname, {
- path: escapedPath,
- exact: exact,
- sensitive: sensitive,
- strict: strict
- }) : null;
- var isActive = !!(isActiveProp ? isActiveProp(match, currentLocation) : match);
- var className = typeof classNameProp === "function" ? classNameProp(isActive) : classNameProp;
- var style = typeof styleProp === "function" ? styleProp(isActive) : styleProp;
- if (isActive) {
- className = joinClassnames(className, activeClassName);
- style = _extends({}, style, activeStyle);
- }
- var props = _extends({
- "aria-current": isActive && ariaCurrent || null,
- className: className,
- style: style,
- to: toLocation
- }, rest); // React 15 compat
- if (forwardRefShim$1 !== forwardRef$1) {
- props.ref = forwardedRef || innerRef;
- } else {
- props.innerRef = innerRef;
- }
- return /*#__PURE__*/React__default.createElement(Link, props);
- });
- });
- {
- NavLink.displayName = "NavLink";
- var ariaCurrentType = propTypes.oneOf(["page", "step", "location", "date", "time", "true", "false"]);
- NavLink.propTypes = _extends({}, Link.propTypes, {
- "aria-current": ariaCurrentType,
- activeClassName: propTypes.string,
- activeStyle: propTypes.object,
- className: propTypes.oneOfType([propTypes.string, propTypes.func]),
- exact: propTypes.bool,
- isActive: propTypes.func,
- location: propTypes.object,
- sensitive: propTypes.bool,
- strict: propTypes.bool,
- style: propTypes.oneOfType([propTypes.object, propTypes.func])
- });
- }
- 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.useHistory = useHistory;
- exports.useLocation = useLocation;
- exports.useParams = useParams;
- exports.useRouteMatch = useRouteMatch;
- exports.withRouter = withRouter;
- Object.defineProperty(exports, '__esModule', { value: true });
- }));
- //# sourceMappingURL=react-router-dom.js.map
|