This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,59 @@
import { matchPath, Router, Switch, Route } from 'react-router';
import _extends from '@babel/runtime/helpers/esm/extends';
import React from 'react';
function matchRoutes(routes, pathname,
/*not public API*/
branch) {
if (branch === void 0) {
branch = [];
}
routes.some(function (route) {
var match = route.path ? matchPath(pathname, route) : branch.length ? branch[branch.length - 1].match // use parent match
: Router.computeRootMatch(pathname); // use default "root" match
if (match) {
branch.push({
route: route,
match: match
});
if (route.routes) {
matchRoutes(route.routes, pathname, branch);
}
}
return match;
});
return branch;
}
function renderRoutes(routes, extraProps, switchProps) {
if (extraProps === void 0) {
extraProps = {};
}
if (switchProps === void 0) {
switchProps = {};
}
return routes ? React.createElement(Switch, switchProps, routes.map(function (route, i) {
return React.createElement(Route, {
key: route.key || i,
path: route.path,
exact: route.exact,
strict: route.strict,
render: function render(props) {
return route.render ? route.render(_extends({}, props, {}, extraProps, {
route: route
})) : React.createElement(route.component, _extends({}, props, extraProps, {
route: route
}));
}
});
})) : null;
}
export { matchRoutes, renderRoutes };
//# sourceMappingURL=react-router-config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react-router-config.js","sources":["../modules/matchRoutes.js","../modules/renderRoutes.js"],"sourcesContent":["import { matchPath, Router } from \"react-router\";\n\nfunction matchRoutes(routes, pathname, /*not public API*/ branch = []) {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? branch[branch.length - 1].match // use parent match\n : Router.computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, branch);\n }\n }\n\n return match;\n });\n\n return branch;\n}\n\nexport default matchRoutes;\n","import React from \"react\";\nimport { Switch, Route } from \"react-router\";\n\nfunction renderRoutes(routes, extraProps = {}, switchProps = {}) {\n return routes ? (\n <Switch {...switchProps}>\n {routes.map((route, i) => (\n <Route\n key={route.key || i}\n path={route.path}\n exact={route.exact}\n strict={route.strict}\n render={props =>\n route.render ? (\n route.render({ ...props, ...extraProps, route: route })\n ) : (\n <route.component {...props} {...extraProps} route={route} />\n )\n }\n />\n ))}\n </Switch>\n ) : null;\n}\n\nexport default renderRoutes;\n"],"names":["matchRoutes","routes","pathname","branch","some","route","match","path","matchPath","length","Router","computeRootMatch","push","renderRoutes","extraProps","switchProps","map","i","key","exact","strict","props","render"],"mappings":";;;;AAEA,SAASA,WAAT,CAAqBC,MAArB,EAA6BC,QAA7B;;AAA0DC,MAA1D,EAAuE;MAAbA,MAAa;IAAbA,MAAa,GAAJ,EAAI;;;EACrEF,MAAM,CAACG,IAAP,CAAY,UAAAC,KAAK,EAAI;QACbC,KAAK,GAAGD,KAAK,CAACE,IAAN,GACVC,SAAS,CAACN,QAAD,EAAWG,KAAX,CADC,GAEVF,MAAM,CAACM,MAAP,GACEN,MAAM,CAACA,MAAM,CAACM,MAAP,GAAgB,CAAjB,CAAN,CAA0BH,KAD5B;MAEEI,MAAM,CAACC,gBAAP,CAAwBT,QAAxB,CAJN,CADmB;;QAOfI,KAAJ,EAAW;MACTH,MAAM,CAACS,IAAP,CAAY;QAAEP,KAAK,EAALA,KAAF;QAASC,KAAK,EAALA;OAArB;;UAEID,KAAK,CAACJ,MAAV,EAAkB;QAChBD,WAAW,CAACK,KAAK,CAACJ,MAAP,EAAeC,QAAf,EAAyBC,MAAzB,CAAX;;;;WAIGG,KAAP;GAfF;SAkBOH,MAAP;;;AClBF,SAASU,YAAT,CAAsBZ,MAAtB,EAA8Ba,UAA9B,EAA+CC,WAA/C,EAAiE;MAAnCD,UAAmC;IAAnCA,UAAmC,GAAtB,EAAsB;;;MAAlBC,WAAkB;IAAlBA,WAAkB,GAAJ,EAAI;;;SACxDd,MAAM,GACX,oBAAC,MAAD,EAAYc,WAAZ,EACGd,MAAM,CAACe,GAAP,CAAW,UAACX,KAAD,EAAQY,CAAR;WACV,oBAA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