mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
Merge 1.x-stable
This commit is contained in:
commit
bb68245b7f
@ -32,13 +32,15 @@ export default class Row extends React.Component {
|
||||
if (!col) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return cloneElement(col, {
|
||||
style: gutter > 0 ? assign({}, {
|
||||
paddingLeft: gutter / 2,
|
||||
paddingRight: gutter / 2,
|
||||
}, col.props.style) : col.props.style,
|
||||
});
|
||||
if (col.props) {
|
||||
return cloneElement(col, {
|
||||
style: gutter > 0 ? assign({}, {
|
||||
paddingLeft: gutter / 2,
|
||||
paddingRight: gutter / 2,
|
||||
}, col.props.style) : col.props.style,
|
||||
});
|
||||
}
|
||||
return col;
|
||||
});
|
||||
return <div {...others} className={classes} style={rowStyle}>{cols}</div>;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ export default class Table extends React.Component {
|
||||
if (!rowSelection.getCheckboxProps) {
|
||||
return [];
|
||||
}
|
||||
return this.getFlatCurrentPageData()
|
||||
return this.getFlatData()
|
||||
.filter(item => this.getCheckboxPropsByItem(item).defaultChecked)
|
||||
.map((record, rowIndex) => this.getRecordKey(record, rowIndex));
|
||||
}
|
||||
@ -165,17 +165,28 @@ export default class Table extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
setSelectedRowKeys(selectedRowKeys) {
|
||||
if (this.props.rowSelection &&
|
||||
!('selectedRowKeys' in this.props.rowSelection)) {
|
||||
setSelectedRowKeys(selectedRowKeys, { selectWay, record, checked, changeRowKeys }) {
|
||||
const { rowSelection = {} } = this.props;
|
||||
if (rowSelection && !('selectedRowKeys' in rowSelection)) {
|
||||
this.setState({ selectedRowKeys });
|
||||
}
|
||||
if (this.props.rowSelection && this.props.rowSelection.onChange) {
|
||||
const data = this.getFlatCurrentPageData();
|
||||
const selectedRows = data.filter(
|
||||
(row, i) => selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0
|
||||
const data = this.getFlatData();
|
||||
if (!rowSelection.onChange && !rowSelection[selectWay]) {
|
||||
return;
|
||||
}
|
||||
const selectedRows = data.filter(
|
||||
(row, i) => selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0
|
||||
);
|
||||
if (rowSelection.onChange) {
|
||||
rowSelection.onChange(selectedRowKeys, selectedRows);
|
||||
}
|
||||
if (selectWay === 'onSelect' && rowSelection.onSelect) {
|
||||
rowSelection.onSelect(record, checked, selectedRows);
|
||||
} else if (selectWay === 'onSelectAll' && rowSelection.onSelectAll) {
|
||||
const changeRows = data.filter(
|
||||
(row, i) => changeRowKeys.indexOf(this.getRecordKey(row, i)) >= 0
|
||||
);
|
||||
this.props.rowSelection.onChange(selectedRowKeys, selectedRows);
|
||||
rowSelection.onSelectAll(checked, selectedRows, changeRows);
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,14 +348,11 @@ export default class Table extends React.Component {
|
||||
this.setState({
|
||||
selectionDirty: true,
|
||||
});
|
||||
this.setSelectedRowKeys(selectedRowKeys);
|
||||
if (this.props.rowSelection.onSelect) {
|
||||
let data = this.getFlatCurrentPageData();
|
||||
let selectedRows = data.filter((row, i) => {
|
||||
return selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelect(record, checked, selectedRows);
|
||||
}
|
||||
this.setSelectedRowKeys(selectedRowKeys, {
|
||||
selectWay: 'onSelect',
|
||||
record,
|
||||
checked,
|
||||
});
|
||||
}
|
||||
|
||||
handleRadioSelect = (record, rowIndex, e) => {
|
||||
@ -356,14 +364,11 @@ export default class Table extends React.Component {
|
||||
this.setState({
|
||||
selectionDirty: true,
|
||||
});
|
||||
this.setSelectedRowKeys(selectedRowKeys);
|
||||
if (this.props.rowSelection.onSelect) {
|
||||
let data = this.getFlatCurrentPageData();
|
||||
let selectedRows = data.filter((row, i) => {
|
||||
return selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelect(record, checked, selectedRows);
|
||||
}
|
||||
this.setSelectedRowKeys(selectedRowKeys, {
|
||||
selectWay: 'onSelect',
|
||||
record,
|
||||
checked,
|
||||
});
|
||||
}
|
||||
|
||||
handleSelectAllRow = (e) => {
|
||||
@ -395,14 +400,11 @@ export default class Table extends React.Component {
|
||||
this.setState({
|
||||
selectionDirty: true,
|
||||
});
|
||||
this.setSelectedRowKeys(selectedRowKeys);
|
||||
if (this.props.rowSelection.onSelectAll) {
|
||||
const selectedRows = data.filter((row, i) =>
|
||||
selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0);
|
||||
const changeRows = data.filter((row, i) =>
|
||||
changeRowKeys.indexOf(this.getRecordKey(row, i)) >= 0);
|
||||
this.props.rowSelection.onSelectAll(checked, selectedRows, changeRows);
|
||||
}
|
||||
this.setSelectedRowKeys(selectedRowKeys, {
|
||||
selectWay: 'onSelectAll',
|
||||
checked,
|
||||
changeRowKeys,
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange = (current) => {
|
||||
@ -694,6 +696,10 @@ export default class Table extends React.Component {
|
||||
return data;
|
||||
}
|
||||
|
||||
getFlatData() {
|
||||
return flatArray(this.getLocalData());
|
||||
}
|
||||
|
||||
getFlatCurrentPageData() {
|
||||
return flatArray(this.getCurrentPageData());
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ english: Download
|
||||
<span class="resource-card-description">一套页面逻辑原型库,帮你梳理页面逻辑</span>
|
||||
</span>
|
||||
</a>
|
||||
<a target="_blank" href="https://github.com/ant-design/ant-design/releases/download/resource/iconfont-0.12.11.zip" class="resource-card">
|
||||
<a target="_blank" href="https://github.com/ant-design/ant-design/releases/download/resource/iconfont-1.x.zip" class="resource-card">
|
||||
<img src="https://os.alipayobjects.com/rmsportal/UEpOFKUQTZaUfnW.png">
|
||||
<span class="resource-card-content">
|
||||
<span class="resource-card-title">Web Font</span>
|
||||
|
@ -1,5 +1,17 @@
|
||||
const path = require('path');
|
||||
|
||||
function pickerGenerator(module) {
|
||||
const tester = new RegExp(`^docs/${module}`);
|
||||
return (markdownData) => {
|
||||
const filename = markdownData.meta.filename;
|
||||
if (tester.test(filename) && !/\.en-US\.md/.test(filename)) {
|
||||
return {
|
||||
meta: markdownData.meta,
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
port: 8001,
|
||||
source: [
|
||||
@ -24,6 +36,18 @@ module.exports = {
|
||||
meta: markdownData.meta,
|
||||
};
|
||||
},
|
||||
changelog(markdownData) {
|
||||
if (markdownData.meta.filename === 'CHANGELOG.md') {
|
||||
return {
|
||||
meta: markdownData.meta,
|
||||
};
|
||||
}
|
||||
},
|
||||
'docs/pattern': pickerGenerator('pattern'),
|
||||
'docs/practice': pickerGenerator('practice'),
|
||||
'docs/react': pickerGenerator('react'),
|
||||
'docs/resource': pickerGenerator('resource'),
|
||||
'docs/spec': pickerGenerator('spec'),
|
||||
},
|
||||
theme: './site/theme',
|
||||
htmlTemplate: './site/theme/static/template.html',
|
||||
|
@ -95,9 +95,19 @@ export default class MainContent extends React.Component {
|
||||
return [...topLevel, ...itemGroups];
|
||||
}
|
||||
|
||||
getModuleData() {
|
||||
const props = this.props;
|
||||
const pathname = props.location.pathname;
|
||||
const moduleName = /^components/.test(pathname) ?
|
||||
'components' : pathname.split('/').slice(0, 2).join('/');
|
||||
return moduleName === 'components' || moduleName === 'changelog' || moduleName === 'docs/react' ?
|
||||
[...props.picked.components, ...props.picked['docs/react'], ...props.picked.changelog] :
|
||||
props.picked[moduleName];
|
||||
}
|
||||
|
||||
getMenuItems() {
|
||||
const moduleData = this.props.moduleData;
|
||||
const menuItems = utils.getMenuItems(moduleData, this.context.intl.locale);
|
||||
const moduleData = this.getModuleData();
|
||||
const menuItems = utils.getMenuItems(moduleData);
|
||||
const topLevel = this.generateSubMenuItems(menuItems.topLevel);
|
||||
const subMenu = Object.keys(menuItems).filter(this.isNotTopLevel)
|
||||
.sort((a, b) => config.categoryOrder[a] - config.categoryOrder[b])
|
||||
@ -143,18 +153,14 @@ export default class MainContent extends React.Component {
|
||||
const menuItems = this.getMenuItems();
|
||||
const { prev, next } = this.getFooterNav(menuItems, activeMenuItem);
|
||||
|
||||
const locale = this.context.intl.locale;
|
||||
const moduleData = this.props.moduleData;
|
||||
const localizedPageData = moduleData.filter(
|
||||
page => page.meta.filename.toLowerCase().startsWith(props.location.pathname)
|
||||
)[0];
|
||||
|
||||
const moduleData = this.getModuleData();
|
||||
const localizedPageData = props.localizedPageData;
|
||||
return (
|
||||
<div className="main-wrapper">
|
||||
<Row>
|
||||
<Col lg={4} md={6} sm={24} xs={24}>
|
||||
<Menu className="aside-container" mode="inline"
|
||||
openKeys={Object.keys(utils.getMenuItems(moduleData, locale))}
|
||||
openKeys={Object.keys(utils.getMenuItems(moduleData))}
|
||||
selectedKeys={[activeMenuItem]}
|
||||
>
|
||||
{menuItems}
|
||||
|
@ -1,39 +1,32 @@
|
||||
import React from 'react';
|
||||
import MainContent from './MainContent';
|
||||
import Promise from 'bluebird';
|
||||
import * as utils from '../utils';
|
||||
|
||||
// locale copy from layout
|
||||
const locale = (
|
||||
window.localStorage &&
|
||||
localStorage.getItem('locale') !== 'en-US'
|
||||
) ? 'zh-CN' : 'en-US';
|
||||
|
||||
export function collect(nextProps, callback) {
|
||||
const componentsList = utils.collectDocs(nextProps.data.components);
|
||||
const pageData = nextProps.location.pathname === 'changelog' ?
|
||||
nextProps.data.CHANGELOG : nextProps.pageData;
|
||||
const pageDataPromise = typeof pageData === 'function' ?
|
||||
pageData() : (pageData[locale] || pageData.index[locale] || pageData.index)();
|
||||
const promises = [pageDataPromise];
|
||||
|
||||
const pathname = nextProps.location.pathname;
|
||||
let moduleDocs;
|
||||
if (/(docs\/react\/)|(components\/)|(changelog)/i.test(pathname)) {
|
||||
moduleDocs = [
|
||||
...utils.collectDocs(nextProps.data.docs.react),
|
||||
...componentsList,
|
||||
/* eslint-disable new-cap */
|
||||
nextProps.data.CHANGELOG(),
|
||||
/* eslint-enable new-cap */
|
||||
];
|
||||
} else {
|
||||
moduleDocs = utils.collectDocs(
|
||||
nextProps.utils.get(nextProps.data, pathname.split('/').slice(0, 2))
|
||||
);
|
||||
}
|
||||
|
||||
const demos = nextProps.utils.get(nextProps.data, [...pathname.split('/'), 'demo']);
|
||||
|
||||
const promises = [Promise.all(componentsList), Promise.all(moduleDocs)];
|
||||
const demos = nextProps.utils.get(
|
||||
nextProps.data, [...pathname.split('/'), 'demo']
|
||||
);
|
||||
if (demos) {
|
||||
promises.push(demos());
|
||||
}
|
||||
Promise.all(promises)
|
||||
.then((list) => callback(null, {
|
||||
...nextProps,
|
||||
components: list[0],
|
||||
moduleData: list[1],
|
||||
demos: list[2],
|
||||
localizedPageData: list[0],
|
||||
demos: list[1],
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,5 @@
|
||||
export function collectDocs(docs) {
|
||||
// locale copy from layout
|
||||
const locale = (typeof localStorage !== 'undefined' && localStorage.getItem('locale') !== 'en-US') ?
|
||||
'zh-CN' : 'en-US';
|
||||
const docsList = Object.keys(docs)
|
||||
.map(key => docs[key])
|
||||
.map((value) => {
|
||||
if (typeof value !== 'function') {
|
||||
return value[locale] || value.index[locale] || value.index;
|
||||
}
|
||||
return value;
|
||||
})
|
||||
.map(fn => fn());
|
||||
return docsList;
|
||||
}
|
||||
|
||||
export function getMenuItems(data) {
|
||||
const menuMeta = data.map((item) => item.meta);
|
||||
export function getMenuItems(moduleData) {
|
||||
const menuMeta = moduleData.map(item => item.meta);
|
||||
const menuItems = {};
|
||||
menuMeta.sort(
|
||||
(a, b) => (a.order || 0) - (b.order || 0)
|
||||
@ -32,7 +16,6 @@ export function getMenuItems(data) {
|
||||
|
||||
menuItems[category][type].push(meta);
|
||||
});
|
||||
|
||||
return menuItems;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user