chore: 升级 react-router 到 v5 (#3552)

* chore: 升级 react-router 到 v5

* 更新 snapshot
This commit is contained in:
liaoxuezhi 2022-02-10 13:50:12 +08:00 committed by GitHub
parent 799bdfacd4
commit 75119817fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1005 additions and 1147 deletions

View File

@ -2,7 +2,7 @@
exports[`Components:404 Custom code & messages 1`] = ` exports[`Components:404 Custom code & messages 1`] = `
<div <div
className="container w-xxl w-auto-xs" className="container w-xxl w-auto-xs m-auto"
> >
<div <div
className="text-center m-b-lg" className="text-center m-b-lg"
@ -23,7 +23,7 @@ exports[`Components:404 Custom code & messages 1`] = `
exports[`Components:404 default View 1`] = ` exports[`Components:404 default View 1`] = `
<div <div
className="container w-xxl w-auto-xs" className="container w-xxl w-auto-xs m-auto"
> >
<div <div
className="text-center m-b-lg" className="text-center m-b-lg"

View File

@ -6,21 +6,13 @@ import {
AlertComponent, AlertComponent,
Button, Button,
Drawer, Drawer,
Spinner,
ToastComponent ToastComponent
} from '../../src/components/index'; } from '../../src/components/index';
import {eachTree, mapTree} from '../../src/utils/helper'; import {eachTree, mapTree} from '../../src/utils/helper';
import {Icon} from '../../src/components/icons'; import {Icon} from '../../src/components/icons';
import '../../src/locale/en-US'; import '../../src/locale/en-US';
import { import {withRouter} from 'react-router';
Router,
Route,
IndexRoute,
browserHistory,
hashHistory,
Link,
Redirect,
withRouter
} from 'react-router';
import Select from '../../src/components/Select'; import Select from '../../src/components/Select';
import InputBox from '../../src/components/InputBox'; import InputBox from '../../src/components/InputBox';
import DocSearch from './DocSearch'; import DocSearch from './DocSearch';
@ -29,7 +21,14 @@ import DocNavCN from './DocNavCN';
import Example, {examples} from './Example'; import Example, {examples} from './Example';
import CSSDocs, {cssDocs} from './CssDocs'; import CSSDocs, {cssDocs} from './CssDocs';
import Components, {components} from './Components'; import Components, {components} from './Components';
import {
BrowserRouter as Router,
Route,
Redirect,
Switch,
Link,
NavLink
} from 'react-router-dom';
declare const _hmt: any; declare const _hmt: any;
let ContextPath = ''; let ContextPath = '';
@ -102,7 +101,7 @@ const docVersions = [
} }
]; ];
function getPath(path) { function getPath(path: string) {
return path return path
? path[0] === '/' ? path[0] === '/'
? ContextPath + path ? ContextPath + path
@ -155,20 +154,20 @@ export class App extends React.PureComponent<{
themes.find(item => item?.value === localStorage.getItem('amis-theme')) || themes.find(item => item?.value === localStorage.getItem('amis-theme')) ||
themes[0], themes[0],
locale: localStorage.getItem('amis-locale') locale: localStorage.getItem('amis-locale')
? localStorage.getItem('amis-locale').replace('zh-cn', 'zh-CN') ? localStorage.getItem('amis-locale')?.replace('zh-cn', 'zh-CN')
: '', : '',
navigations: [], navigations: [],
filter: '' // 导航过滤,方便找组件 filter: '' // 导航过滤,方便找组件
}; };
constructor(props) { constructor(props: any) {
super(props); super(props);
this.setNavigations = this.setNavigations.bind(this); this.setNavigations = this.setNavigations.bind(this);
this.setNavigationFilter = this.setNavigationFilter.bind(this); this.setNavigationFilter = this.setNavigationFilter.bind(this);
document.querySelector('body').classList.add(this.state.theme.value); document.querySelector('body')?.classList.add(this.state.theme.value);
} }
componentDidUpdate(preProps, preState) { componentDidUpdate(preProps: any, preState: any) {
const props = this.props; const props = this.props;
if (preState.theme.value !== this.state.theme.value) { if (preState.theme.value !== this.state.theme.value) {
@ -178,7 +177,7 @@ export class App extends React.PureComponent<{
const theme = item.getAttribute('title'); const theme = item.getAttribute('title');
item.disabled = theme !== this.state.theme.value; item.disabled = theme !== this.state.theme.value;
}); });
const body = document.querySelector('body'); const body = document.body;
body.classList.remove(preState.theme.value); body.classList.remove(preState.theme.value);
body.classList.add(this.state.theme.value); body.classList.add(this.state.theme.value);
} }
@ -269,25 +268,31 @@ export class App extends React.PureComponent<{
)} )}
<ul className={`HeaderLinks`}> <ul className={`HeaderLinks`}>
<Link to={`${ContextPath}/zh-CN/docs`} activeClassName="is-active"> <NavLink
to={`${ContextPath}/zh-CN/docs`}
activeClassName="is-active"
>
</Link> </NavLink>
<Link <NavLink
to={`${ContextPath}/zh-CN/components`} to={`${ContextPath}/zh-CN/components`}
activeClassName="is-active" activeClassName="is-active"
> >
</Link> </NavLink>
<Link to={`${ContextPath}/zh-CN/style`} activeClassName="is-active"> <NavLink
to={`${ContextPath}/zh-CN/style`}
activeClassName="is-active"
>
</Link> </NavLink>
<Link <NavLink
to={`${ContextPath}/examples/index`} to={`${ContextPath}/examples/index`}
activeClassName="is-active" activeClassName="is-active"
> >
</Link> </NavLink>
<a <a
href="https://github.com/fex-team/amis-editor-demo" href="https://github.com/fex-team/amis-editor-demo"
target="_blank" target="_blank"
@ -307,8 +312,8 @@ export class App extends React.PureComponent<{
value={this.state.locale || 'zh-CN'} value={this.state.locale || 'zh-CN'}
options={locales} options={locales}
onChange={locale => { onChange={locale => {
this.setState({locale: locale.value}); this.setState({locale: (locale as any).value});
localStorage.setItem('amis-locale', locale.value); localStorage.setItem('amis-locale', (locale as any).value);
window.location.reload(); window.location.reload();
}} }}
/> />
@ -323,10 +328,12 @@ export class App extends React.PureComponent<{
options={this.state.themes} options={this.state.themes}
onChange={theme => { onChange={theme => {
this.setState({theme}); this.setState({theme});
localStorage.setItem('amis-theme', `${theme.value}`); localStorage.setItem('amis-theme', `${(theme as any).value}`);
document document
.querySelector('body') .querySelector('body')
.classList[theme.value === 'dark' ? 'add' : 'remove']('dark'); ?.classList[
(theme as any).value === 'dark' ? 'add' : 'remove'
]('dark');
}} }}
/> />
</div> </div>
@ -339,8 +346,8 @@ export class App extends React.PureComponent<{
value={this.state.viewMode || 'pc'} value={this.state.viewMode || 'pc'}
options={viewModes} options={viewModes}
onChange={viewMode => { onChange={viewMode => {
this.setState({viewMode: viewMode.value}); this.setState({viewMode: (viewMode as any).value});
localStorage.setItem('amis-viewMode', viewMode.value); localStorage.setItem('amis-viewMode', (viewMode as any).value);
window.location.reload(); window.location.reload();
}} }}
/> />
@ -353,7 +360,7 @@ export class App extends React.PureComponent<{
theme={this.state.theme.value} theme={this.state.theme.value}
value={docVersions[0].value} value={docVersions[0].value}
options={docVersions} options={docVersions}
onChange={doc => { onChange={(doc: any) => {
if (doc.url && /^https?\:\/\//.test(doc.url)) { if (doc.url && /^https?\:\/\//.test(doc.url)) {
window.open(doc.url); window.open(doc.url);
} else { } else {
@ -418,17 +425,17 @@ export class App extends React.PureComponent<{
return ( return (
<AsideNav <AsideNav
navigations={this.state.navigations.map(item => ({ navigations={this.state.navigations.map((item: any) => ({
...item, ...item,
children: item.children children: item.children
? item.children ? item.children
.filter(item => { .filter((item: any) => {
if (item.label) { if (item.label) {
return filterReg.exec(item.label); return filterReg.exec(item.label);
} }
return true; return true;
}) })
.map(item => ({ .map((item: any) => ({
...item, ...item,
className: 'is-top' className: 'is-top'
})) }))
@ -528,7 +535,7 @@ export class App extends React.PureComponent<{
<ToastComponent theme={theme.value} locale={this.state.locale} /> <ToastComponent theme={theme.value} locale={this.state.locale} />
<AlertComponent theme={theme.value} locale={this.state.locale} /> <AlertComponent theme={theme.value} locale={this.state.locale} />
{React.cloneElement(this.props.children as any, { {/* {React.cloneElement(this.props.children as any, {
key: theme.value, key: theme.value,
...(this.props.children as any).props, ...(this.props.children as any).props,
setNavigations: this.setNavigations, setNavigations: this.setNavigations,
@ -538,11 +545,165 @@ export class App extends React.PureComponent<{
locale: this.state.locale, locale: this.state.locale,
offScreen: this.state.offScreen, offScreen: this.state.offScreen,
ContextPath ContextPath
})} })} */}
{this.renderContent()}
</Layout> </Layout>
); );
} }
renderContent() {
const locale = 'zh-CN'; // 暂时不支持切换,因为目前只有中文文档
const theme = this.state.theme;
return (
<React.Suspense
fallback={<Spinner overlay spinnerClassName="m-t-lg" size="lg" />}
>
<Switch>
<Redirect
from={`${ContextPath}/`}
to={`${ContextPath}/${locale}/docs/index`}
exact
/>
{/* docs */}
<Redirect
from={`${ContextPath}/docs`}
to={`${ContextPath}/${locale}/docs/index`}
exact
/>
<Redirect
from={`${ContextPath}/docs/index`}
to={`${ContextPath}/${locale}/docs/index`}
exact
/>
<Redirect
from={`${ContextPath}/docs/*`}
to={`${ContextPath}/${locale}/docs/*`}
/>
<Redirect
from={`${ContextPath}/${locale}/docs`}
to={`${ContextPath}/${locale}/docs/index`}
exact
/>
{/* components */}
<Redirect
from={`${ContextPath}/components`}
to={`${ContextPath}/${locale}/components/page`}
exact
/>
<Redirect
from={`${ContextPath}/components/page`}
to={`${ContextPath}/${locale}/components/page`}
exact
/>
<Redirect
from={`${ContextPath}/components/*`}
to={`${ContextPath}/${locale}/components/*`}
exact
/>
<Redirect
from={`${ContextPath}/${locale}/components`}
to={`${ContextPath}/${locale}/components/page`}
exact
/>
{/* expamles */}
<Redirect
from={`${ContextPath}/examples`}
to={`${ContextPath}/examples/index`}
exact
/>
<Redirect
from={`${ContextPath}/${locale}/style`}
to={`${ContextPath}/${locale}/style/index`}
exact
/>
<Route
path={`${ContextPath}/${locale}/docs`}
render={(props: any) => (
<Doc
{...{
setNavigations: this.setNavigations,
theme: theme.value,
classPrefix: theme.ns,
viewMode: this.state.viewMode,
locale: this.state.locale,
offScreen: this.state.offScreen,
ContextPath,
showCode: false
}}
{...props}
/>
)}
/>
<Route
path={`${ContextPath}/${locale}/components`}
render={(props: any) => (
<Components
{...{
setNavigations: this.setNavigations,
theme: theme.value,
classPrefix: theme.ns,
viewMode: this.state.viewMode,
locale: this.state.locale,
offScreen: this.state.offScreen,
ContextPath,
showCode: false
}}
{...props}
/>
)}
/>
<Route
path={`${ContextPath}/examples`}
render={(props: any) => (
<Example
{...{
setNavigations: this.setNavigations,
theme: theme.value,
classPrefix: theme.ns,
viewMode: this.state.viewMode,
locale: this.state.locale,
offScreen: this.state.offScreen,
ContextPath,
showCode: false
}}
{...props}
/>
)}
/>
<Route
path={`${ContextPath}/${locale}/style`}
render={(props: any) => (
<CSSDocs
{...{
setNavigations: this.setNavigations,
theme: theme.value,
classPrefix: theme.ns,
viewMode: this.state.viewMode,
locale: this.state.locale,
offScreen: this.state.offScreen,
ContextPath,
showCode: false
}}
{...props}
/>
)}
/>
<Route
render={() => (
<div className="Doc-content">
<NotFound />
</div>
)}
/>
</Switch>
</React.Suspense>
);
}
render() { render() {
const theme = this.state.theme; const theme = this.state.theme;
const location = this.props.location; const location = this.props.location;
@ -552,7 +713,7 @@ export class App extends React.PureComponent<{
<> <>
<ToastComponent theme={theme.value} locale={this.state.locale} /> <ToastComponent theme={theme.value} locale={this.state.locale} />
<AlertComponent theme={theme.value} locale={this.state.locale} /> <AlertComponent theme={theme.value} locale={this.state.locale} />
{React.cloneElement(this.props.children as any, { {/* {React.cloneElement(this.props.children as any, {
key: theme.value, key: theme.value,
...(this.props.children as any).props, ...(this.props.children as any).props,
setNavigations: this.setNavigations, setNavigations: this.setNavigations,
@ -563,7 +724,8 @@ export class App extends React.PureComponent<{
offScreen: this.state.offScreen, offScreen: this.state.offScreen,
ContextPath, ContextPath,
showCode: false showCode: false
})} })} */}
{this.renderContent()}
</> </>
); );
} else if (/examples/.test(location.pathname)) { } else if (/examples/.test(location.pathname)) {
@ -597,32 +759,32 @@ export class App extends React.PureComponent<{
position="left" position="left"
> >
<ul className={`HeaderLinks`}> <ul className={`HeaderLinks`}>
<Link <NavLink
to={`${ContextPath}/zh-CN/docs`} to={`${ContextPath}/zh-CN/docs`}
activeClassName="is-active" activeClassName="is-active"
> >
</Link> </NavLink>
<Link <NavLink
to={`${ContextPath}/zh-CN/components`} to={`${ContextPath}/zh-CN/components`}
activeClassName="is-active" activeClassName="is-active"
> >
</Link> </NavLink>
<Link <NavLink
to={`${ContextPath}/zh-CN/style`} to={`${ContextPath}/zh-CN/style`}
activeClassName="is-active" activeClassName="is-active"
> >
</Link> </NavLink>
</ul> </ul>
{this.renderNavigation()} {this.renderNavigation()}
</Drawer> </Drawer>
<BackTop /> <BackTop />
{React.cloneElement(this.props.children as any, { {/* {React.cloneElement(this.props.children as any, {
key: theme.value, key: theme.value,
...(this.props.children as any).props, ...(this.props.children as any).props,
setNavigations: this.setNavigations, setNavigations: this.setNavigations,
@ -632,7 +794,8 @@ export class App extends React.PureComponent<{
locale: this.state.locale, locale: this.state.locale,
offScreen: this.state.offScreen, offScreen: this.state.offScreen,
ContextPath ContextPath
})} })} */}
{this.renderContent()}
</div> </div>
</Layout> </Layout>
); );
@ -643,14 +806,30 @@ function isActive(link: any, location: any) {
return !!(link.path && getPath(link.path) === location.pathname); return !!(link.path && getPath(link.path) === location.pathname);
} }
function navigations2route(navigations) { export function navigations2route(
let routes = []; navigations: any,
additionalProperties?: any
) {
let routes: any = [];
navigations.forEach(root => { navigations.forEach((root: any) => {
root.children && root.children &&
eachTree(root.children, (item: any) => { eachTree(root.children, (item: any) => {
if (item.path && item.component) { if (item.path && item.component) {
routes.push( routes.push(
additionalProperties ? (
<Route
key={routes.length + 1}
path={
item.path[0] === '/'
? ContextPath + item.path
: `${ContextPath}/${item.path}`
}
render={(props: any) => (
<item.component {...additionalProperties} {...props} />
)}
/>
) : (
<Route <Route
key={routes.length + 1} key={routes.length + 1}
path={ path={
@ -660,18 +839,7 @@ function navigations2route(navigations) {
} }
component={item.component} component={item.component}
/> />
); )
} else if (item.path && item.getComponent) {
routes.push(
<Route
key={routes.length + 1}
path={
item.path[0] === '/'
? ContextPath + item.path
: `${ContextPath}/${item.path}`
}
getComponent={item.getComponent}
/>
); );
} }
}); });
@ -680,80 +848,15 @@ function navigations2route(navigations) {
return routes; return routes;
} }
export default function entry({pathPrefix}) { export default function entry() {
// PathPrefix = pathPrefix || DocPathPrefix; // PathPrefix = pathPrefix || DocPathPrefix;
const locate = 'zh-CN'; // 暂时不支持切换,因为目前只有中文文档
return ( return (
<Router history={browserHistory}> <Router>
<Route component={App}> <Switch>
<Redirect <Route component={App}></Route>
from={`${ContextPath}/`} <Route component={NotFound} />
to={`${ContextPath}/${locate}/docs/index`} </Switch>
/>
{/* docs */}
<Redirect
from={`${ContextPath}/docs`}
to={`${ContextPath}/${locate}/docs/index`}
/>
<Redirect
from={`${ContextPath}/docs/index`}
to={`${ContextPath}/${locate}/docs/index`}
/>
<Redirect
from={`${ContextPath}/docs/*`}
to={`${ContextPath}/${locate}/docs/*`}
/>
<Redirect
from={`${ContextPath}/${locate}/docs`}
to={`${ContextPath}/${locate}/docs/index`}
/>
{/* components */}
<Redirect
from={`${ContextPath}/components`}
to={`${ContextPath}/${locate}/components/page`}
/>
<Redirect
from={`${ContextPath}/components/page`}
to={`${ContextPath}/${locate}/components/page`}
/>
<Redirect
from={`${ContextPath}/components/*`}
to={`${ContextPath}/${locate}/components/*`}
/>
<Redirect
from={`${ContextPath}/${locate}/components`}
to={`${ContextPath}/${locate}/components/page`}
/>
{/* expamles */}
<Redirect
from={`${ContextPath}/examples`}
to={`${ContextPath}/examples/index`}
/>
<Redirect
from={`${ContextPath}/${locate}/style`}
to={`${ContextPath}/${locate}/style/index`}
/>
<Route path={`${ContextPath}/${locate}/docs`} component={Doc}>
{navigations2route(DocNavCN)}
</Route>
<Route
path={`${ContextPath}/${locate}/components`}
component={Components}
>
{navigations2route(components)}
</Route>
<Route path={`${ContextPath}/examples`} component={Example}>
{navigations2route(examples)}
</Route>
<Route path={`${ContextPath}/${locate}/style`} component={CSSDocs}>
{navigations2route(cssDocs)}
</Route>
</Route>
<Route path="*" component={NotFound} />
</Router> </Router>
); );
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,12 @@
import React from 'react'; import React from 'react';
import {Switch} from 'react-router-dom';
import {navigations2route} from './App';
import makeMarkdownRenderer from './MdRenderer'; import makeMarkdownRenderer from './MdRenderer';
function wrapDoc(doc: any) {
return {
default: makeMarkdownRenderer(doc)
};
}
export const cssDocs = [ export const cssDocs = [
{ {
@ -8,40 +15,30 @@ export const cssDocs = [
{ {
label: '快速开始', label: '快速开始',
path: '/zh-CN/style/index', path: '/zh-CN/style/index',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)(['../../docs/zh-CN/style/index.md'], (doc: any) => { import('../../docs/zh-CN/style/index.md').then(wrapDoc)
cb(null, makeMarkdownRenderer(doc)); )
})
}, },
{ {
label: 'CSS 变量', label: 'CSS 变量',
path: '/zh-CN/style/css-vars', path: '/zh-CN/style/css-vars',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../docs/zh-CN/style/css-vars.md').then(wrapDoc)
['../../docs/zh-CN/style/css-vars.md'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: '辅助类 - 响应式设计', label: '辅助类 - 响应式设计',
path: '/zh-CN/style/responsive-design', path: '/zh-CN/style/responsive-design',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../docs/zh-CN/style/responsive-design.md').then(wrapDoc)
['../../docs/zh-CN/style/responsive-design.md'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: '辅助类 - 状态样式', label: '辅助类 - 状态样式',
path: '/zh-CN/style/state', path: '/zh-CN/style/state',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)(['../../docs/zh-CN/style/state.md'], (doc: any) => { import('../../docs/zh-CN/style/state.md').then(wrapDoc)
cb(null, makeMarkdownRenderer(doc)); )
})
} }
] ]
}, },
@ -53,108 +50,74 @@ export const cssDocs = [
{ {
label: 'Box Sizing', label: 'Box Sizing',
path: '/zh-CN/style/layout/box-sizing', path: '/zh-CN/style/layout/box-sizing',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_box-sizing.scss').then(wrapDoc)
['../../scss/helper/layout/_box-sizing.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Display', label: 'Display',
path: '/zh-CN/style/layout/display', path: '/zh-CN/style/layout/display',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_display.scss').then(wrapDoc)
['../../scss/helper/layout/_display.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Floats', label: 'Floats',
path: '/zh-CN/style/layout/floats', path: '/zh-CN/style/layout/floats',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_float.scss').then(wrapDoc)
['../../scss/helper/layout/_float.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Clear', label: 'Clear',
path: '/zh-CN/style/layout/clear', path: '/zh-CN/style/layout/clear',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_clear.scss').then(wrapDoc)
['../../scss/helper/layout/_clear.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Overflow', label: 'Overflow',
path: '/zh-CN/style/layout/overflow', path: '/zh-CN/style/layout/overflow',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_overflow.scss').then(wrapDoc)
['../../scss/helper/layout/_overflow.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Position', label: 'Position',
path: '/zh-CN/style/layout/position', path: '/zh-CN/style/layout/position',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_position.scss').then(wrapDoc)
['../../scss/helper/layout/_position.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Top / Right / Bottom / Left', label: 'Top / Right / Bottom / Left',
path: '/zh-CN/style/layout/top-right-bottom-left', path: '/zh-CN/style/layout/top-right-bottom-left',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_top-right-bottom-left.scss').then(
['../../scss/helper/layout/_top-right-bottom-left.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Visibility', label: 'Visibility',
path: '/zh-CN/style/layout/visibility', path: '/zh-CN/style/layout/visibility',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_visibility.scss').then(wrapDoc)
['../../scss/helper/layout/_visibility.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Z-Index', label: 'Z-Index',
path: '/zh-CN/style/layout/z-index', path: '/zh-CN/style/layout/z-index',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/layout/_z-index.scss').then(wrapDoc)
['../../scss/helper/layout/_z-index.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -166,72 +129,48 @@ export const cssDocs = [
{ {
label: 'Flex Direction', label: 'Flex Direction',
path: '/zh-CN/style/flexbox/direction', path: '/zh-CN/style/flexbox/direction',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_direction.scss').then(wrapDoc)
['../../scss/helper/flex/_direction.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Flex Wrap', label: 'Flex Wrap',
path: '/zh-CN/style/flexbox/wrap', path: '/zh-CN/style/flexbox/wrap',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_wrap.scss').then(wrapDoc)
['../../scss/helper/flex/_wrap.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Flex', label: 'Flex',
path: '/zh-CN/style/flexbox/flex', path: '/zh-CN/style/flexbox/flex',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_flex.scss').then(wrapDoc)
['../../scss/helper/flex/_flex.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Flex Grow', label: 'Flex Grow',
path: '/zh-CN/style/flexbox/grow', path: '/zh-CN/style/flexbox/grow',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_grow.scss').then(wrapDoc)
['../../scss/helper/flex/_grow.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Flex Shrink', label: 'Flex Shrink',
path: '/zh-CN/style/flexbox/shrink', path: '/zh-CN/style/flexbox/shrink',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_shrink.scss').then(wrapDoc)
['../../scss/helper/flex/_shrink.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Flex Order', label: 'Flex Order',
path: '/zh-CN/style/flexbox/order', path: '/zh-CN/style/flexbox/order',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/flex/_order.scss').then(wrapDoc)
['../../scss/helper/flex/_order.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -243,87 +182,58 @@ export const cssDocs = [
{ {
label: 'Grid Template Columns', label: 'Grid Template Columns',
path: '/zh-CN/style/grid/columns', path: '/zh-CN/style/grid/columns',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_columns.scss').then(wrapDoc)
['../../scss/helper/grid/_columns.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Column Start / End', label: 'Grid Column Start / End',
path: '/zh-CN/style/grid/column-start-end', path: '/zh-CN/style/grid/column-start-end',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_column-start-end.scss').then(wrapDoc)
['../../scss/helper/grid/_column-start-end.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Template Rows', label: 'Grid Template Rows',
path: '/zh-CN/style/grid/rows', path: '/zh-CN/style/grid/rows',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_rows.scss').then(wrapDoc)
['../../scss/helper/grid/_rows.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Row Start / End', label: 'Grid Row Start / End',
path: '/zh-CN/style/grid/row-start-end', path: '/zh-CN/style/grid/row-start-end',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_row-start-end.scss').then(wrapDoc)
['../../scss/helper/grid/_row-start-end.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Auto Flow', label: 'Grid Auto Flow',
path: '/zh-CN/style/grid/auto-flow', path: '/zh-CN/style/grid/auto-flow',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_auto-flow.scss').then(wrapDoc)
['../../scss/helper/grid/_auto-flow.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Auto Columns', label: 'Grid Auto Columns',
path: '/zh-CN/style/grid/auto-columns', path: '/zh-CN/style/grid/auto-columns',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_auto-columns.scss').then(wrapDoc)
['../../scss/helper/grid/_auto-columns.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Grid Auto Rows', label: 'Grid Auto Rows',
path: '/zh-CN/style/grid/auto-rows', path: '/zh-CN/style/grid/auto-rows',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/grid/_auto-rows.scss').then(wrapDoc)
['../../scss/helper/grid/_auto-rows.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Gap', label: 'Gap',
path: '/zh-CN/style/grid/gap', path: '/zh-CN/style/grid/gap',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)(['../../scss/helper/grid/_gap.scss'], (doc: any) => { import('../../scss/helper/grid/_gap.scss').then(wrapDoc)
cb(null, makeMarkdownRenderer(doc)); )
})
} }
] ]
}, },
@ -333,108 +243,90 @@ export const cssDocs = [
{ {
label: 'Justify Content', label: 'Justify Content',
path: '/zh-CN/style/box-alignment/justify-content', path: '/zh-CN/style/box-alignment/justify-content',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_justify-content.scss').then(
['../../scss/helper/box-alignment/_justify-content.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Justify Items', label: 'Justify Items',
path: '/zh-CN/style/box-alignment/justify-items', path: '/zh-CN/style/box-alignment/justify-items',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_justify-items.scss').then(
['../../scss/helper/box-alignment/_justify-items.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Justify Self', label: 'Justify Self',
path: '/zh-CN/style/box-alignment/justify-self', path: '/zh-CN/style/box-alignment/justify-self',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_justify-self.scss').then(
['../../scss/helper/box-alignment/_justify-self.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Align Content', label: 'Align Content',
path: '/zh-CN/style/box-alignment/align-content', path: '/zh-CN/style/box-alignment/align-content',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_align-content.scss').then(
['../../scss/helper/box-alignment/_align-content.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Align Items', label: 'Align Items',
path: '/zh-CN/style/box-alignment/align-items', path: '/zh-CN/style/box-alignment/align-items',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_align-items.scss').then(
['../../scss/helper/box-alignment/_align-items.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Align Self', label: 'Align Self',
path: '/zh-CN/style/box-alignment/align-self', path: '/zh-CN/style/box-alignment/align-self',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_align-self.scss').then(
['../../scss/helper/box-alignment/_align-self.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Place Content', label: 'Place Content',
path: '/zh-CN/style/box-alignment/place-content', path: '/zh-CN/style/box-alignment/place-content',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_place-content.scss').then(
['../../scss/helper/box-alignment/_place-content.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Place Items', label: 'Place Items',
path: '/zh-CN/style/box-alignment/place-items', path: '/zh-CN/style/box-alignment/place-items',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_place-items.scss').then(
['../../scss/helper/box-alignment/_place-items.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Place Self', label: 'Place Self',
path: '/zh-CN/style/box-alignment/place-self', path: '/zh-CN/style/box-alignment/place-self',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/box-alignment/_place-self.scss').then(
['../../scss/helper/box-alignment/_place-self.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -446,36 +338,24 @@ export const cssDocs = [
{ {
label: 'Padding', label: 'Padding',
path: '/zh-CN/style/spacing/padding', path: '/zh-CN/style/spacing/padding',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/spacing/_padding.scss').then(wrapDoc)
['../../scss/helper/spacing/_padding.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Margin', label: 'Margin',
path: '/zh-CN/style/spacing/margin', path: '/zh-CN/style/spacing/margin',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/spacing/_margin.scss').then(wrapDoc)
['../../scss/helper/spacing/_margin.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Space Between', label: 'Space Between',
path: '/zh-CN/style/spacing/space-between', path: '/zh-CN/style/spacing/space-between',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/spacing/_space-between.scss').then(wrapDoc)
['../../scss/helper/spacing/_space-between.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -487,23 +367,15 @@ export const cssDocs = [
{ {
label: 'Width', label: 'Width',
path: '/zh-CN/style/sizing/width', path: '/zh-CN/style/sizing/width',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/sizing/_width.scss').then(wrapDoc)
['../../scss/helper/sizing/_width.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Height', label: 'Height',
path: '/zh-CN/style/sizing/height', path: '/zh-CN/style/sizing/height',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/sizing/_height.scss').then(wrapDoc)
['../../scss/helper/sizing/_height.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -515,168 +387,122 @@ export const cssDocs = [
{ {
label: 'Font Family', label: 'Font Family',
path: '/zh-CN/style/typography/font-family', path: '/zh-CN/style/typography/font-family',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_font-family.scss').then(wrapDoc)
['../../scss/helper/typography/_font-family.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Font Size', label: 'Font Size',
path: '/zh-CN/style/typography/font-size', path: '/zh-CN/style/typography/font-size',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_font-size.scss').then(wrapDoc)
['../../scss/helper/typography/_font-size.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Font style', label: 'Font style',
path: '/zh-CN/style/typography/font-style', path: '/zh-CN/style/typography/font-style',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_font-style.scss').then(wrapDoc)
['../../scss/helper/typography/_font-style.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Font Weight', label: 'Font Weight',
path: '/zh-CN/style/typography/font-weight', path: '/zh-CN/style/typography/font-weight',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_font-weight.scss').then(wrapDoc)
['../../scss/helper/typography/_font-weight.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Letter Spacing', label: 'Letter Spacing',
path: '/zh-CN/style/typography/letter-spacing', path: '/zh-CN/style/typography/letter-spacing',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_letter-spacing.scss').then(
['../../scss/helper/typography/_letter-spacing.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Line Height', label: 'Line Height',
path: '/zh-CN/style/typography/line-height', path: '/zh-CN/style/typography/line-height',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_line-height.scss').then(wrapDoc)
['../../scss/helper/typography/_line-height.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'List Style Type', label: 'List Style Type',
path: '/zh-CN/style/typography/list-style-type', path: '/zh-CN/style/typography/list-style-type',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_list-style-type.scss').then(
['../../scss/helper/typography/_list-style-type.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Text Alignment', label: 'Text Alignment',
path: '/zh-CN/style/typography/text-align', path: '/zh-CN/style/typography/text-align',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_text-align.scss').then(wrapDoc)
['../../scss/helper/typography/_text-align.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Text Color', label: 'Text Color',
path: '/zh-CN/style/typography/text-color', path: '/zh-CN/style/typography/text-color',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_text-color.scss').then(wrapDoc)
['../../scss/helper/typography/_text-color.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Text Decoration', label: 'Text Decoration',
path: '/zh-CN/style/typography/text-decoration', path: '/zh-CN/style/typography/text-decoration',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_text-decoration.scss').then(
['../../scss/helper/typography/_text-decoration.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Text Transform', label: 'Text Transform',
path: '/zh-CN/style/typography/text-transform', path: '/zh-CN/style/typography/text-transform',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_text-transform.scss').then(
['../../scss/helper/typography/_text-transform.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Vertical Alignment', label: 'Vertical Alignment',
path: '/zh-CN/style/typography/vertical-align', path: '/zh-CN/style/typography/vertical-align',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_vertical-align.scss').then(
['../../scss/helper/typography/_vertical-align.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Whitespace', label: 'Whitespace',
path: '/zh-CN/style/typography/whitespace', path: '/zh-CN/style/typography/whitespace',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_whitespace.scss').then(wrapDoc)
['../../scss/helper/typography/_whitespace.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Word Break', label: 'Word Break',
path: '/zh-CN/style/typography/word-break', path: '/zh-CN/style/typography/word-break',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/typography/_word-break.scss').then(wrapDoc)
['../../scss/helper/typography/_word-break.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -688,12 +514,10 @@ export const cssDocs = [
{ {
label: 'Background Color', label: 'Background Color',
path: '/zh-CN/style/background/background-color', path: '/zh-CN/style/background/background-color',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/background/_background-color.scss').then(
['../../scss/helper/background/_background-color.scss'], wrapDoc
(doc: any) => { )
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -705,48 +529,32 @@ export const cssDocs = [
{ {
label: 'Border Radius', label: 'Border Radius',
path: '/zh-CN/style/border/border-radius', path: '/zh-CN/style/border/border-radius',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/border/_border-radius.scss').then(wrapDoc)
['../../scss/helper/border/_border-radius.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Border Width', label: 'Border Width',
path: '/zh-CN/style/border/border-width', path: '/zh-CN/style/border/border-width',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/border/_border-width.scss').then(wrapDoc)
['../../scss/helper/border/_border-width.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Border Color', label: 'Border Color',
path: '/zh-CN/style/border/border-color', path: '/zh-CN/style/border/border-color',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/border/_border-color.scss').then(wrapDoc)
['../../scss/helper/border/_border-color.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Border Style', label: 'Border Style',
path: '/zh-CN/style/border/border-style', path: '/zh-CN/style/border/border-style',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/border/_border-style.scss').then(wrapDoc)
['../../scss/helper/border/_border-style.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -758,24 +566,16 @@ export const cssDocs = [
{ {
label: 'Box Shadow', label: 'Box Shadow',
path: '/zh-CN/style/effect/box-shadow', path: '/zh-CN/style/effect/box-shadow',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/effect/_box-shadow.scss').then(wrapDoc)
['../../scss/helper/effect/_box-shadow.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
}, },
{ {
label: 'Opacity', label: 'Opacity',
path: '/zh-CN/style/effect/opacity', path: '/zh-CN/style/effect/opacity',
getComponent: (location: any, cb: any) => component: React.lazy(() =>
(require as any)( import('../../scss/helper/effect/_opacity.scss').then(wrapDoc)
['../../scss/helper/effect/_opacity.scss'],
(doc: any) => {
cb(null, makeMarkdownRenderer(doc));
}
) )
} }
] ]
@ -793,16 +593,23 @@ export default class CSSDocs extends React.PureComponent<any> {
render() { render() {
return ( return (
<> <Switch>
{React.cloneElement(this.props.children as any, { {navigations2route(cssDocs, {
...(this.props.children as any).props,
theme: this.props.theme, theme: this.props.theme,
classPrefix: this.props.classPrefix, classPrefix: this.props.classPrefix,
locale: this.props.locale, locale: this.props.locale,
viewMode: this.props.viewMode, viewMode: this.props.viewMode,
offScreen: this.props.offScreen offScreen: this.props.offScreen
})} })}
</> {/* {React.cloneElement(this.props.children as any, {
...(this.props.children as any).props,
theme: this.props.theme,
classPrefix: this.props.classPrefix,
locale: this.props.locale,
viewMode: this.props.viewMode,
offScreen: this.props.offScreen
})} */}
</Switch>
); );
} }
} }

View File

@ -1,10 +1,12 @@
import React from 'react'; import React from 'react';
import {Switch} from 'react-router-dom';
import {flattenTree, filterTree, mapTree} from '../../src/utils/helper'; import {flattenTree, filterTree, mapTree} from '../../src/utils/helper';
import {navigations2route} from './App';
import DocNavCN from './DocNavCN'; import DocNavCN from './DocNavCN';
export default class Doc extends React.PureComponent { export default class Doc extends React.PureComponent<any> {
state = { state = {
prevDoc: null, prevDoc: null,
nextDoc: null nextDoc: null
@ -29,7 +31,7 @@ export default class Doc extends React.PureComponent {
this.setDocFooter(); this.setDocFooter();
} }
componentDidUpdate(preProps) { componentDidUpdate(preProps: any) {
if (this.props.location.pathname !== preProps.location.pathname) { if (this.props.location.pathname !== preProps.location.pathname) {
this.props.setNavigations(DocNavCN, false); this.props.setNavigations(DocNavCN, false);
this.setDocFooter(); this.setDocFooter();
@ -37,11 +39,11 @@ export default class Doc extends React.PureComponent {
} }
setDocFooter() { setDocFooter() {
const newDocs = mapTree(DocNavCN, doc => ({ const newDocs = mapTree(DocNavCN, (doc: any) => ({
...doc, ...doc,
children: children:
Array.isArray(doc.children) && doc.children.length Array.isArray(doc.children) && doc.children.length
? doc.children.map(item => ({ ? doc.children.map((item: any) => ({
...item, ...item,
group: doc.group || doc.label group: doc.group || doc.label
})) }))
@ -59,9 +61,8 @@ export default class Doc extends React.PureComponent {
render() { render() {
return ( return (
<> <Switch>
{React.cloneElement(this.props.children, { {navigations2route(DocNavCN, {
...this.props.children.props,
theme: this.props.theme, theme: this.props.theme,
classPrefix: this.props.classPrefix, classPrefix: this.props.classPrefix,
locale: this.props.locale, locale: this.props.locale,
@ -71,7 +72,19 @@ export default class Doc extends React.PureComponent {
prevDoc: this.state.prevDoc, prevDoc: this.state.prevDoc,
nextDoc: this.state.nextDoc nextDoc: this.state.nextDoc
})} })}
</>
{/* {React.cloneElement(this.props.children, {
...this.props.children.props,
theme: this.props.theme,
classPrefix: this.props.classPrefix,
locale: this.props.locale,
viewMode: this.props.viewMode,
offScreen: this.props.offScreen,
ContextPath: this.props.ContextPath,
prevDoc: this.state.prevDoc,
nextDoc: this.state.nextDoc
})} */}
</Switch>
); );
} }
} }

View File

@ -1,4 +1,10 @@
import React from 'react';
import makeMarkdownRenderer from './MdRenderer'; import makeMarkdownRenderer from './MdRenderer';
function wrapDoc(doc: any) {
return {
default: makeMarkdownRenderer(doc)
};
}
export default [ export default [
{ {
@ -8,35 +14,33 @@ export default [
{ {
label: '介绍', label: '介绍',
path: '/zh-CN/docs/index', path: '/zh-CN/docs/index',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/index.md').then(wrapDoc)
import('../../docs/zh-CN/index.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '快速开始', label: '快速开始',
path: '/zh-CN/docs/start/getting-started', path: '/zh-CN/docs/start/getting-started',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/start/getting-started.md').then(wrapDoc)
import('../../docs/zh-CN/start/getting-started.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '1.2.0 版本变更', label: '1.2.0 版本变更',
path: '/zh-CN/docs/start/1-2-0', path: '/zh-CN/docs/start/1-2-0',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/start/1-2-0.md').then(wrapDoc)
import('../../docs/zh-CN/start/1-2-0.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '常见问题', label: '常见问题',
path: '/zh-CN/docs/start/faq', path: '/zh-CN/docs/start/faq',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/start/faq.md').then(wrapDoc)
import('../../docs/zh-CN/start/faq.md').then(makeMarkdownRenderer) )
} }
] ]
}, },
@ -47,73 +51,59 @@ export default [
{ {
label: '配置与组件', label: '配置与组件',
path: '/zh-CN/docs/concepts/schema', path: '/zh-CN/docs/concepts/schema',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/schema.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/schema.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '数据域与数据链', label: '数据域与数据链',
path: '/zh-CN/docs/concepts/datascope-and-datachain', path: '/zh-CN/docs/concepts/datascope-and-datachain',
getComponent: () => component: React.lazy(() =>
// @ts-ignore
import('../../docs/zh-CN/concepts/datascope-and-datachain.md').then( import('../../docs/zh-CN/concepts/datascope-and-datachain.md').then(
makeMarkdownRenderer wrapDoc
)
) )
}, },
{ {
label: '模板', label: '模板',
path: '/zh-CN/docs/concepts/template', path: '/zh-CN/docs/concepts/template',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/template.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/template.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '数据映射', label: '数据映射',
path: '/zh-CN/docs/concepts/data-mapping', path: '/zh-CN/docs/concepts/data-mapping',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/data-mapping.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/data-mapping.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '表达式', label: '表达式',
path: '/zh-CN/docs/concepts/expression', path: '/zh-CN/docs/concepts/expression',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/expression.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/expression.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '联动', label: '联动',
path: '/zh-CN/docs/concepts/linkage', path: '/zh-CN/docs/concepts/linkage',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/linkage.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/linkage.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '行为', label: '行为',
path: '/zh-CN/docs/concepts/action', path: '/zh-CN/docs/concepts/action',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/action.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/action.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '样式', label: '样式',
path: '/zh-CN/docs/concepts/style', path: '/zh-CN/docs/concepts/style',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/concepts/style.md').then(wrapDoc)
import('../../docs/zh-CN/concepts/style.md').then(
makeMarkdownRenderer
) )
} }
] ]
@ -125,35 +115,29 @@ export default [
{ {
label: 'SchemaNode', label: 'SchemaNode',
path: '/zh-CN/docs/types/schemanode', path: '/zh-CN/docs/types/schemanode',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/types/schemanode.md').then(wrapDoc)
import('../../docs/zh-CN/types/schemanode.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: 'ClassName', label: 'ClassName',
path: '/zh-CN/docs/types/classname', path: '/zh-CN/docs/types/classname',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/types/classname.md').then(wrapDoc)
import('../../docs/zh-CN/types/classname.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: 'API', label: 'API',
path: '/zh-CN/docs/types/api', path: '/zh-CN/docs/types/api',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/types/api.md').then(wrapDoc)
import('../../docs/zh-CN/types/api.md').then(makeMarkdownRenderer) )
}, },
{ {
label: 'Definitions', label: 'Definitions',
path: '/zh-CN/docs/types/definitions', path: '/zh-CN/docs/types/definitions',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/types/definitions.md').then(wrapDoc)
import('../../docs/zh-CN/types/definitions.md').then(
makeMarkdownRenderer
) )
} }
] ]
@ -165,83 +149,71 @@ export default [
{ {
label: '工作原理', label: '工作原理',
path: '/zh-CN/docs/extend/internal', path: '/zh-CN/docs/extend/internal',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/internal.md').then(wrapDoc)
import('../../docs/zh-CN/extend/internal.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '自定义组件 - SDK', label: '自定义组件 - SDK',
path: '/zh-CN/docs/extend/custom-sdk', path: '/zh-CN/docs/extend/custom-sdk',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/custom-sdk.md').then(wrapDoc)
import('../../docs/zh-CN/extend/custom-sdk.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '自定义组件 - React', label: '自定义组件 - React',
path: '/zh-CN/docs/extend/custom-react', path: '/zh-CN/docs/extend/custom-react',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/custom-react.md').then(wrapDoc)
import('../../docs/zh-CN/extend/custom-react.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '将 amis 当成 UI 库用', label: '将 amis 当成 UI 库用',
path: '/zh-CN/docs/extend/ui-library', path: '/zh-CN/docs/extend/ui-library',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/ui-library.md').then(wrapDoc)
import('../../docs/zh-CN/extend/ui-library.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '扩展现有组件', label: '扩展现有组件',
path: '/zh-CN/docs/extend/addon', path: '/zh-CN/docs/extend/addon',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/addon.md').then(wrapDoc)
import('../../docs/zh-CN/extend/addon.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '页面交互行为跟踪', label: '页面交互行为跟踪',
path: '/zh-CN/docs/extend/tracker', path: '/zh-CN/docs/extend/tracker',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/tracker.md').then(wrapDoc)
import('../../docs/zh-CN/extend/tracker.md').then(
makeMarkdownRenderer
) )
}, },
{ {
label: '调试工具', label: '调试工具',
path: '/zh-CN/docs/extend/debug', path: '/zh-CN/docs/extend/debug',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/debug.md').then(wrapDoc)
import('../../docs/zh-CN/extend/debug.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '移动端定制', label: '移动端定制',
path: '/zh-CN/docs/extend/mobile', path: '/zh-CN/docs/extend/mobile',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/mobile.md').then(wrapDoc)
import('../../docs/zh-CN/extend/mobile.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '多语言', label: '多语言',
path: '/zh-CN/docs/extend/i18n', path: '/zh-CN/docs/extend/i18n',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/i18n.md').then(wrapDoc)
import('../../docs/zh-CN/extend/i18n.md').then(makeMarkdownRenderer) )
}, },
{ {
label: '如何贡献代码', label: '如何贡献代码',
path: '/zh-CN/docs/extend/contribute', path: '/zh-CN/docs/extend/contribute',
getComponent: () => component: React.lazy(() =>
// @ts-ignore import('../../docs/zh-CN/extend/contribute.md').then(wrapDoc)
import('../../docs/zh-CN/extend/contribute.md').then(
makeMarkdownRenderer
) )
} }
] ]

View File

@ -99,6 +99,8 @@ import Tab3Schema from './Tabs/Tab3';
import TestComponent from './Test'; import TestComponent from './Test';
import {normalizeLink} from '../../src/utils/normalizeLink'; import {normalizeLink} from '../../src/utils/normalizeLink';
import {Switch} from 'react-router-dom';
import {navigations2route} from './App';
export const examples = [ export const examples = [
{ {
@ -698,16 +700,23 @@ export default class Example extends React.PureComponent {
render() { render() {
return ( return (
<> <Switch>
{React.cloneElement(this.props.children, { {/* {React.cloneElement(this.props.children, {
...this.props.children.props, ...this.props.children.props,
theme: this.props.theme, theme: this.props.theme,
classPrefix: this.props.classPrefix, classPrefix: this.props.classPrefix,
locale: this.props.locale, locale: this.props.locale,
viewMode: this.props.viewMode, viewMode: this.props.viewMode,
offScreen: this.props.offScreen offScreen: this.props.offScreen
})} */}
{navigations2route(examples, {
theme: this.props.theme,
classPrefix: this.props.classPrefix,
locale: this.props.locale,
viewMode: this.props.viewMode,
offScreen: this.props.offScreen
})} })}
</> </Switch>
); );
} }
} }

View File

@ -9,7 +9,7 @@ import Overlay from '../../src/components/Overlay';
import PopOver from '../../src/components/PopOver'; import PopOver from '../../src/components/PopOver';
import NestedLinks from '../../src/components/AsideNav'; import NestedLinks from '../../src/components/AsideNav';
import classnames from 'classnames'; import classnames from 'classnames';
import {Link} from 'react-router'; import {Link} from 'react-router-dom';
import Play from './Play'; import Play from './Play';
class CodePreview extends React.Component<any> { class CodePreview extends React.Component<any> {
@ -157,7 +157,7 @@ class Preview extends React.Component {
} }
} }
export default function (doc) { export default function (doc: any) {
return class extends React.Component { return class extends React.Component {
popoverDom = null; popoverDom = null;

View File

@ -280,7 +280,7 @@ export default class PlayGround extends React.Component {
const query = props.location.query; const query = props.location.query;
try { try {
const scope = query.scope || props.scope; const scope = props.scope;
if (scope && scopes[scope]) { if (scope && scopes[scope]) {
schemaContent = scopes[scope].replace( schemaContent = scopes[scope].replace(

View File

@ -119,7 +119,7 @@
"@types/react-dom": "^16.0.7", "@types/react-dom": "^16.0.7",
"@types/react-dropzone": "^5.1.0", "@types/react-dropzone": "^5.1.0",
"@types/react-onclickoutside": "^6.0.2", "@types/react-onclickoutside": "^6.0.2",
"@types/react-router": "^3.0.24", "@types/react-router-dom": "^5.3.3",
"@types/react-test-renderer": "^16.8.1", "@types/react-test-renderer": "^16.8.1",
"@types/react-transition-group": "4.4.3", "@types/react-transition-group": "4.4.3",
"@types/sortablejs": "^1.3.32", "@types/sortablejs": "^1.3.32",
@ -163,7 +163,8 @@
"prettier": "^2.4.1", "prettier": "^2.4.1",
"pretty-quick": "^3.1.1", "pretty-quick": "^3.1.1",
"prismjs": "^1.25.0", "prismjs": "^1.25.0",
"react-router": "3.2.0", "react-router": "^5.2.1",
"react-router-dom": "5.3.0",
"react-test-renderer": "^16.8.6", "react-test-renderer": "^16.8.6",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"ts-json-schema-generator": "0.96.0", "ts-json-schema-generator": "0.96.0",

View File

@ -20,7 +20,7 @@ export class NotFound extends React.Component<NotFoundProps, any> {
const {links, footerText, description, children, code} = this.props; const {links, footerText, description, children, code} = this.props;
return ( return (
<div className="container w-xxl w-auto-xs"> <div className="container w-xxl w-auto-xs m-auto">
<div className="text-center m-b-lg"> <div className="text-center m-b-lg">
<h1 className="text-shadow text-white">{code || '404'}</h1> <h1 className="text-shadow text-white">{code || '404'}</h1>
{description ? ( {description ? (

View File

@ -7,3 +7,8 @@ declare module '*.md' {
const content: any; const content: any;
export default content; export default content;
} }
declare module '*.scss' {
const content: any;
export default content;
}