mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-18 15:22:28 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb5b6543c4 | ||
|
|
6a7c74fce9 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,7 +23,6 @@ nohup.out
|
||||
_site
|
||||
_data
|
||||
dist
|
||||
/lib
|
||||
lib
|
||||
elasticsearch-*
|
||||
config/base.yaml
|
||||
typings
|
||||
|
||||
9
404.html
Normal file
9
404.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<script>
|
||||
var prefix = /^\/components/.test(location.pathname) ? location.pathname.replace(/^\//, '').split('/').join('-') : '';
|
||||
var scrollToString = location.hash ? '?scrollTo=' + prefix + location.hash : '';
|
||||
if (location.pathname === '/changelog') {
|
||||
location.href = '/#/docs/react/changelog' + scrollToString;
|
||||
} else {
|
||||
location.href = '/#' + location.pathname.replace(/\/$/, '') + scrollToString;
|
||||
}
|
||||
</script>
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@@ -8,34 +8,6 @@ timeline: true
|
||||
你也可以查看 GitHub 上的 [发布日志](https://github.com/ant-design/ant-design/releases)。
|
||||
|
||||
---
|
||||
|
||||
## 1.3.0
|
||||
|
||||
`2016-06-02`
|
||||
|
||||
- Transfer 组件增加 `rowKey` 属性,可自定义数据源主键。 [#1900](https://github.com/ant-design/ant-design/issues/1900)
|
||||
- Tag 组件 `default` 类型的样式增加边框,防止淹没在背景中。 [#1910](https://github.com/ant-design/ant-design/issues/1910)
|
||||
- Table
|
||||
- 修复筛选为单选时仍旧展示多选框的问题。 [#1880](https://github.com/ant-design/ant-design/issues/1880)
|
||||
- 修复 fixed left 的固定列会覆盖 rowSelection 的 check box 的问题。 [#1829](https://github.com/ant-design/ant-design/issues/1829)
|
||||
- 其他 demo 及样式优化。
|
||||
- 修复 Button 组件中添加 `<a>` 标签会导致按钮组效果失效的问题。 [#1882](https://github.com/ant-design/ant-design/issues/1882)
|
||||
- Slider 文档样式问题修复。 [#1924](https://github.com/ant-design/ant-design/issues/1924)
|
||||
- 修复了 v1.2.0 新增加的组件属性的 Typescript 定义。 [#1933](https://github.com/ant-design/ant-design/issues/1933)
|
||||
- Form
|
||||
- 修复了一些细节对齐问题。
|
||||
- 修复国际化 label 的冒号样式问题,采用样式实现冒号。 [#1877](https://github.com/ant-design/ant-design/issues/1877)
|
||||
- 修复 DatePicker 组件点击『此刻』失效的问题,并进行了一些代码优化。 [#1902](https://github.com/ant-design/ant-design/issues/1902)
|
||||
- 升级 rc-upload 依赖,修复了 IE10 中第二次上传同一文件不触发 `onChange` 的问题。 [058af3c](https://github.com/ant-design/ant-design/commit/b15a4e3165be5e4db995d3fe75d4d557c7f21c61)
|
||||
- 升级 rc-table 依赖,修复了 fixed 列中数据重复展示以及一些错位问题。 [#1898](https://github.com/ant-design/ant-design/issues/1898)
|
||||
- 文档使用 [bisheng](https://github.com/benjycui/bisheng) 重构。
|
||||
|
||||
## 1.2.1
|
||||
|
||||
`2016-05-27`
|
||||
|
||||
- 修复一个 Select 组件的文字重复问题。
|
||||
|
||||
## 1.2.0
|
||||
|
||||
`2016-05-26`
|
||||
@@ -136,6 +108,7 @@ timeline: true
|
||||
- Progress.Circle 使用方式改为 `<Progress type="circle" />`。
|
||||
- Spin 的 `spining` 属性更正为 `spinning`。
|
||||
- Alert 的 type `warn` 重命名为 `warning`。[#1225](https://github.com/ant-design/ant-design/issues/1225)
|
||||
- `notification.warn`、`message.warn` 修改为 `notification.warning` 和 `message.warning`。[#1225](https://github.com/ant-design/ant-design/issues/1225)
|
||||
- Tree 的 `onExpand` 参数从 `function(node, expanded, expandedKeys)` 调整为 `function(expandedKeys, {expanded, node})`。
|
||||
|
||||
### Bug 修复
|
||||
|
||||
18
README.md
18
README.md
@@ -8,10 +8,6 @@
|
||||
|
||||
An enterprise-class UI design language and React-based implementation.
|
||||
|
||||
## :loudspeaker: Document Translation Recruitment
|
||||
|
||||
We are now working on translate components document to English, and we need some translator and reviewer. https://github.com/ant-design/ant-design/issues/1471
|
||||
|
||||
## Features
|
||||
|
||||
- An enterprise-class design language and high quality UI style.
|
||||
@@ -72,15 +68,9 @@ Normal browsers and Internet Explorer 8+.
|
||||
|
||||
## TypeScript
|
||||
|
||||
tsconfig.json
|
||||
|
||||
```
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"jsx": "preserve"
|
||||
}
|
||||
}
|
||||
```js
|
||||
///<reference path='./node_modules/antd/type-definitions/antd.d.ts'/>
|
||||
...
|
||||
```
|
||||
|
||||
## Links
|
||||
@@ -96,7 +86,7 @@ tsconfig.json
|
||||
- [Developer Instruction](https://github.com/ant-design/ant-design/wiki/Development)
|
||||
- [Versioning Release Note](https://github.com/ant-design/ant-design/wiki/%E7%89%88%E6%9C%AC%E5%8F%91%E5%B8%83%E6%B5%81%E7%A8%8B)
|
||||
- [FAQ](https://github.com/ant-design/ant-design/wiki/FAQ)
|
||||
- [CodePen boilerplate](http://codepen.io/anon/pen/wGOWGW?editors=001) for bug reports
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { createElement } from 'react';
|
||||
import { findDOMNode } from 'react-dom';
|
||||
import isCssAnimationSupported from '../_util/isCssAnimationSupported';
|
||||
import isCssAnimationSupported from '../util/isCssAnimationSupported';
|
||||
|
||||
function getNumberArray(num) {
|
||||
return num ?
|
||||
|
||||
@@ -42,15 +42,6 @@ export default class Button extends React.Component {
|
||||
icon: React.PropTypes.string,
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.clickedTimeout) {
|
||||
clearTimeout(this.clickedTimeout);
|
||||
}
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
}
|
||||
|
||||
clearButton = (button) => {
|
||||
button.className = button.className.replace(` ${this.props.prefixCls}-clicked`, '');
|
||||
}
|
||||
@@ -59,7 +50,7 @@ export default class Button extends React.Component {
|
||||
// Add click effect
|
||||
const buttonNode = findDOMNode(this);
|
||||
this.clearButton(buttonNode);
|
||||
this.clickedTimeout = setTimeout(() => buttonNode.className += ` ${this.props.prefixCls}-clicked`, 10);
|
||||
setTimeout(() => buttonNode.className += ` ${this.props.prefixCls}-clicked`, 10);
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(() => this.clearButton(buttonNode), 500);
|
||||
|
||||
|
||||
@@ -35,20 +35,6 @@
|
||||
color: @color;
|
||||
background-color: @background;
|
||||
border-color: @border;
|
||||
// a inside Button which only work in Chrome
|
||||
// http://stackoverflow.com/a/17253457
|
||||
> a:only-child {
|
||||
color: currentColor;
|
||||
&:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button-group-base(@btnClassName) {
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
---
|
||||
order: 0
|
||||
title:
|
||||
zh-CN: 典型卡片
|
||||
en-US: Basic card
|
||||
title: 典型卡片
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
包含标题、内容、操作区域。
|
||||
|
||||
## en-US
|
||||
|
||||
A basic card containing a title, content and an extra corner content.
|
||||
|
||||
````jsx
|
||||
import { Card } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<Card title="Card title" extra={<a href="#">More</a>} style={{ width: 300 }}>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<Card title="卡片标题" extra={<a href="#">更多</a>} style={{ width: 300 }}>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
</Card>
|
||||
, mountNode);
|
||||
````
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
---
|
||||
order: 1
|
||||
title:
|
||||
zh-CN: 无边框
|
||||
en-US: No border
|
||||
title: 无边框
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
在灰色背景上使用无边框的卡片。
|
||||
|
||||
## en-US
|
||||
|
||||
A borderless card on a gray background.
|
||||
|
||||
````jsx
|
||||
import { Card } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div style={{ background: '#ECECEC', padding: '30px' }}>
|
||||
<Card title="Card title" bordered={false} style={{ width: 300 }}>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<Card title="卡片标题" bordered={false} style={{ width: 300 }}>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
</Card>
|
||||
</div>
|
||||
, mountNode);
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
---
|
||||
order: 4
|
||||
title:
|
||||
zh-CN: 栅格卡片
|
||||
en-US: Grid card
|
||||
title: 栅格卡片
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
在系统概览页面常常和栅格进行配合。
|
||||
|
||||
## en-US
|
||||
|
||||
Cards usually cooperate with grid layout in overview page.
|
||||
|
||||
````jsx
|
||||
import { Card, Col, Row } from 'antd';
|
||||
|
||||
@@ -20,13 +12,13 @@ ReactDOM.render(
|
||||
<div style={{ background: '#ECECEC', padding: '30px' }}>
|
||||
<Row>
|
||||
<Col span="8">
|
||||
<Card title="Card title" bordered={false}>Card content</Card>
|
||||
<Card title="卡片标题" bordered={false}>卡片的内容</Card>
|
||||
</Col>
|
||||
<Col span="8">
|
||||
<Card title="Card title" bordered={false}>Card content</Card>
|
||||
<Card title="卡片标题" bordered={false}>卡片的内容</Card>
|
||||
</Col>
|
||||
<Col span="8">
|
||||
<Card title="Card title" bordered={false}>Card content</Card>
|
||||
<Card title="卡片标题" bordered={false}>卡片的内容</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
@@ -34,7 +26,7 @@ ReactDOM.render(
|
||||
````
|
||||
|
||||
````css
|
||||
/* Increase grid spacing of 16px */
|
||||
/* 增加 16px 栅格间距 */
|
||||
.code-box-demo .row {
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
---
|
||||
order: 5
|
||||
title:
|
||||
zh-CN: 预加载的卡片
|
||||
en-US: Loading card
|
||||
title: 预加载的卡片
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
数据读入前会有文本块样式。
|
||||
|
||||
## en-US
|
||||
|
||||
Shows a loading indicator while the contents of the card are being fetched.
|
||||
|
||||
````jsx
|
||||
import { Card } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<Card loading title="Card title" style={{ width: '34%' }}>
|
||||
<Card loading title="卡片标题" style={{ width: '34%' }}>
|
||||
Whatever content
|
||||
</Card>
|
||||
, mountNode);
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
---
|
||||
order: 3
|
||||
title:
|
||||
zh-CN: 更灵活的内容展示
|
||||
en-US: Customized content
|
||||
title: 更灵活的内容展示
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
可以调整默认边距,设定宽度。
|
||||
|
||||
## en-US
|
||||
|
||||
Customizing default width and margin.
|
||||
|
||||
|
||||
````jsx
|
||||
import { Card } from 'antd';
|
||||
|
||||
@@ -23,7 +14,7 @@ ReactDOM.render(
|
||||
<img alt="example" width="100%" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />
|
||||
</div>
|
||||
<div className="custom-card">
|
||||
<h3>Europe Street beat</h3>
|
||||
<h3>欧美街拍</h3>
|
||||
<p>www.instagram.com</p>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
---
|
||||
order: 2
|
||||
title:
|
||||
zh-CN: 简洁卡片
|
||||
en-US: Simple card
|
||||
title: 简洁卡片
|
||||
---
|
||||
|
||||
## zh-CN
|
||||
|
||||
只包含内容区域。
|
||||
|
||||
## en-US
|
||||
|
||||
A simple card only containing a content area.
|
||||
|
||||
````jsx
|
||||
import { Card } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<Card style={{ width: 300 }}>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<p>Card content</p>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
<p>卡片的内容</p>
|
||||
</Card>
|
||||
, mountNode);
|
||||
````
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
category: Components
|
||||
type: Presentation
|
||||
title: Card
|
||||
---
|
||||
|
||||
Common card container.
|
||||
|
||||
## When to use
|
||||
|
||||
The most basic card container. You can use it to contain text, lists, pictures and paragraphs.
|
||||
|
||||
## API
|
||||
|
||||
```html
|
||||
<Card title="Card title">Card content</Card>
|
||||
```
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
|----------|----------------|----------|--------------|
|
||||
| title | Card title | React.Element | - |
|
||||
| extra | Corner content of card | React.Element | - |
|
||||
| bordered | Whether a border is set | Boolean | true |
|
||||
| bodyStyle | Custom style for content area | Object | - |
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
category: Components
|
||||
chinese: 卡片
|
||||
type: Presentation
|
||||
title: Card
|
||||
subtitle: 卡片
|
||||
cols: 1
|
||||
english: Card
|
||||
---
|
||||
|
||||
通用卡片容器。
|
||||
@@ -50,6 +50,25 @@ export default function createPicker(TheCalendar) {
|
||||
'ant-calendar-month': MonthCalendar === TheCalendar,
|
||||
});
|
||||
|
||||
let pickerChangeHandler = {
|
||||
onChange: this.handleChange,
|
||||
};
|
||||
|
||||
let calendarHandler = {
|
||||
onOk: this.handleChange,
|
||||
};
|
||||
|
||||
if (props.showTime) {
|
||||
pickerChangeHandler.onChange = (value) => {
|
||||
// Click clear button
|
||||
if (value === null) {
|
||||
this.handleChange(value);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
calendarHandler = {};
|
||||
}
|
||||
|
||||
const calendar = (
|
||||
<TheCalendar
|
||||
formatter={props.getFormatter()}
|
||||
@@ -61,7 +80,7 @@ export default function createPicker(TheCalendar) {
|
||||
dateInputPlaceholder={placeholder}
|
||||
prefixCls="ant-calendar"
|
||||
className={calendarClassName}
|
||||
/>
|
||||
{...calendarHandler} />
|
||||
);
|
||||
|
||||
// default width for showTime
|
||||
@@ -83,7 +102,7 @@ export default function createPicker(TheCalendar) {
|
||||
getCalendarContainer={props.getCalendarContainer}
|
||||
onOpen={props.toggleOpen}
|
||||
onClose={props.toggleOpen}
|
||||
onChange={this.handleChange}
|
||||
{...pickerChangeHandler}
|
||||
>
|
||||
{
|
||||
({ value }) => {
|
||||
|
||||
@@ -128,6 +128,5 @@
|
||||
.@{calendar-prefix-cls}-today-btn {
|
||||
margin: 8px 12px;
|
||||
height: 22px;
|
||||
line-height: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,15 +162,9 @@ export default class FormItem extends React.Component {
|
||||
[`${props.prefixCls}-item-required`]: required,
|
||||
});
|
||||
|
||||
// remove user input colon
|
||||
let label = props.label;
|
||||
if (typeof props.label === 'string') {
|
||||
label = props.label.replace(/:|:$/, '');
|
||||
}
|
||||
|
||||
return props.label ? (
|
||||
<label htmlFor={props.id || this.getId()} className={className} key="label">
|
||||
{label}
|
||||
{props.label}
|
||||
</label>
|
||||
) : null;
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ ReactDOM.render(
|
||||
<Row gutter={16}>
|
||||
<Col sm={8}>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="较长搜索名称"
|
||||
label="较长搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<DatePicker size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
@@ -36,19 +36,19 @@ ReactDOM.render(
|
||||
</Col>
|
||||
<Col sm={8}>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="较长搜索名称"
|
||||
label="较长搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<DatePicker size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
@@ -56,19 +56,19 @@ ReactDOM.render(
|
||||
</Col>
|
||||
<Col sm={8}>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="较长搜索名称"
|
||||
label="较长搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<DatePicker size="default" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="搜索名称"
|
||||
label="搜索名称:"
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input placeholder="请输入搜索名称" size="default" />
|
||||
|
||||
@@ -21,7 +21,7 @@ ReactDOM.render(
|
||||
<Form horizontal>
|
||||
<FormItem
|
||||
id="control-input"
|
||||
label="输入框"
|
||||
label="输入框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input id="control-input" placeholder="Please enter..." />
|
||||
@@ -29,7 +29,7 @@ ReactDOM.render(
|
||||
|
||||
<FormItem
|
||||
id="control-textarea"
|
||||
label="文本域"
|
||||
label="文本域:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Input type="textarea" id="control-textarea" rows="3" />
|
||||
@@ -37,7 +37,7 @@ ReactDOM.render(
|
||||
|
||||
<FormItem
|
||||
id="select"
|
||||
label="Select 选择器"
|
||||
label="Select 选择器:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 14 }}>
|
||||
<Select id="select" size="large" defaultValue="lucy" style={{ width: 200 }} onChange={handleSelectChange}>
|
||||
@@ -49,7 +49,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Checkbox 多选框"
|
||||
label="Checkbox 多选框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 18 }} >
|
||||
<Checkbox className="ant-checkbox-vertical">选项一</Checkbox>
|
||||
@@ -58,7 +58,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Checkbox 多选框"
|
||||
label="Checkbox 多选框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 18 }} >
|
||||
<Checkbox className="ant-checkbox-inline">选项一</Checkbox>
|
||||
@@ -67,7 +67,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Radio 单选框"
|
||||
label="Radio 单选框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 18 }} >
|
||||
<RadioGroup defaultValue="b">
|
||||
|
||||
@@ -42,12 +42,12 @@ let Demo = React.createClass({
|
||||
<Form horizontal form={this.props.form}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="用户名">
|
||||
label="用户名:">
|
||||
<Input {...getFieldProps('username', {})} type="text" autoComplete="off" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="密码">
|
||||
label="密码:">
|
||||
<Input {...getFieldProps('password', {})} type="password" autoComplete="off" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
|
||||
@@ -26,17 +26,17 @@ let Demo = React.createClass({
|
||||
<Form horizontal onSubmit={this.handleSubmit}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="用户名">
|
||||
label="用户名:">
|
||||
<p className="ant-form-text" id="userName" name="userName">大眼萌 minion</p>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="密码">
|
||||
label="密码:">
|
||||
<Input type="password" {...getFieldProps('pass')} placeholder="请输入密码" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="您的性别">
|
||||
label="您的性别:">
|
||||
<RadioGroup {...getFieldProps('gender', { initialValue: 'female' })}>
|
||||
<Radio value="male">男的</Radio>
|
||||
<Radio value="female">女的</Radio>
|
||||
@@ -44,13 +44,13 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="备注"
|
||||
label="备注:"
|
||||
help="随便写点什么">
|
||||
<Input type="textarea" placeholder="随便写" {...getFieldProps('remark')} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={<span>卖身华府 <Tooltip title="我为秋香"><Icon type="question-circle-o" /></Tooltip></span>}>
|
||||
label={<span>卖身华府 <Tooltip title="我为秋香"><Icon type="question-circle-o" /></Tooltip> :</span>}>
|
||||
<Checkbox {...getFieldProps('agreement')}>同意</Checkbox>
|
||||
</FormItem>
|
||||
<FormItem wrapperCol={{ span: 16, offset: 6 }} style={{ marginTop: 24 }}>
|
||||
|
||||
@@ -20,12 +20,12 @@ let Demo = React.createClass({
|
||||
return (
|
||||
<Form inline onSubmit={this.handleSubmit}>
|
||||
<FormItem
|
||||
label="账户">
|
||||
label="账户:">
|
||||
<Input placeholder="请输入账户名"
|
||||
{...getFieldProps('userName')} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="密码">
|
||||
label="密码:">
|
||||
<Input type="password" placeholder="请输入密码"
|
||||
{...getFieldProps('password')} />
|
||||
</FormItem>
|
||||
|
||||
@@ -14,14 +14,14 @@ const Option = Select.Option;
|
||||
ReactDOM.render(
|
||||
<Form horizontal>
|
||||
<FormItem
|
||||
label="标签输入框"
|
||||
label="标签输入框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 16 }}>
|
||||
<Input addonBefore="Http://" defaultValue="mysite.com" id="site1" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="标签输入框"
|
||||
label="标签输入框:"
|
||||
labelCol={{ span: 6 }}
|
||||
validateStatus="success"
|
||||
wrapperCol={{ span: 16 }}>
|
||||
@@ -29,7 +29,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="select 标签输入框"
|
||||
label="select 标签输入框:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 16 }}>
|
||||
<InputGroup>
|
||||
@@ -46,7 +46,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="输入身份证"
|
||||
label="输入身份证:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 16 }}>
|
||||
<InputGroup>
|
||||
@@ -66,7 +66,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="电话号码"
|
||||
label="电话号码:"
|
||||
labelCol={{ span: 6 }}
|
||||
wrapperCol={{ span: 16 }}>
|
||||
<InputGroup>
|
||||
|
||||
@@ -44,7 +44,7 @@ let Demo = React.createClass({
|
||||
return (
|
||||
<Form horizontal onSubmit={this.handleSubmit} >
|
||||
<FormItem
|
||||
label="InputNumber 数字输入框"
|
||||
label="InputNumber 数字输入框:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 10 }}>
|
||||
<InputNumber min={1} max={10} style={{ width: 100 }}
|
||||
@@ -53,7 +53,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="我是标题"
|
||||
label="我是标题:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 10 }}>
|
||||
<p className="ant-form-text" id="static" name="static">唧唧复唧唧木兰当户织呀</p>
|
||||
@@ -63,7 +63,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Switch 开关"
|
||||
label="Switch 开关:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 10 }}
|
||||
required>
|
||||
@@ -71,7 +71,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Slider 滑动输入条"
|
||||
label="Slider 滑动输入条:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 10 }}
|
||||
required>
|
||||
@@ -79,7 +79,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="Select 选择器"
|
||||
label="Select 选择器:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 16 }}
|
||||
required>
|
||||
@@ -93,7 +93,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="级联选择"
|
||||
label="级联选择:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 16 }}
|
||||
required
|
||||
@@ -102,7 +102,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="DatePicker 日期选择框"
|
||||
label="DatePicker 日期选择框:"
|
||||
labelCol={{ span: 8 }}
|
||||
required>
|
||||
<Col span="6">
|
||||
@@ -122,7 +122,7 @@ let Demo = React.createClass({
|
||||
|
||||
|
||||
<FormItem
|
||||
label="TimePicker 时间选择器"
|
||||
label="TimePicker 时间选择器:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 16 }}
|
||||
required>
|
||||
@@ -130,7 +130,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="选项"
|
||||
label="选项:"
|
||||
labelCol={{ span: 8 }}>
|
||||
<RadioGroup {...getFieldProps('rg')}>
|
||||
<RadioButton value="a">选项一</RadioButton>
|
||||
@@ -140,7 +140,7 @@ let Demo = React.createClass({
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="logo图"
|
||||
label="logo图:"
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 16 }}
|
||||
help="提示信息要长长长长长长长长长长长长长长">
|
||||
|
||||
@@ -112,7 +112,7 @@ let BasicDemo = React.createClass({
|
||||
<Form horizontal form={this.props.form}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="用户名"
|
||||
label="用户名:"
|
||||
hasFeedback
|
||||
help={isFieldValidating('name') ? '校验中...' : (getFieldError('name') || []).join(', ')}>
|
||||
<Input {...nameProps} placeholder="实时校验,输入 JasonWood 看看" />
|
||||
@@ -120,14 +120,14 @@ let BasicDemo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="邮箱"
|
||||
label="邮箱:"
|
||||
hasFeedback>
|
||||
<Input {...emailProps} type="email" placeholder="onBlur 与 onChange 相结合" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="密码"
|
||||
label="密码:"
|
||||
hasFeedback>
|
||||
<Input {...passwdProps} type="password" autoComplete="off"
|
||||
onContextMenu={noop} onPaste={noop} onCopy={noop} onCut={noop} />
|
||||
@@ -135,7 +135,7 @@ let BasicDemo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="确认密码"
|
||||
label="确认密码:"
|
||||
hasFeedback>
|
||||
<Input {...rePasswdProps} type="password" autoComplete="off" placeholder="两次输入密码保持一致"
|
||||
onContextMenu={noop} onPaste={noop} onCopy={noop} onCut={noop} />
|
||||
@@ -143,7 +143,7 @@ let BasicDemo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="备注">
|
||||
label="备注:">
|
||||
<Input {...textareaProps} type="textarea" placeholder="随便写" id="textarea" name="textarea" />
|
||||
</FormItem>
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ let Demo = React.createClass({
|
||||
<Col span="18">
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="密码">
|
||||
label="密码:">
|
||||
<Input {...passProps} type="password"
|
||||
onContextMenu={noop} onPaste={noop} onCopy={noop} onCut={noop}
|
||||
autoComplete="off" id="pass"
|
||||
@@ -161,7 +161,7 @@ let Demo = React.createClass({
|
||||
<Col span="18">
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="确认密码">
|
||||
label="确认密码:">
|
||||
<Input {...rePassProps} type="password"
|
||||
onContextMenu={noop} onPaste={noop} onCopy={noop} onCut={noop}
|
||||
autoComplete="off" id="rePass"
|
||||
|
||||
@@ -6,7 +6,7 @@ title: 校验其他组件
|
||||
提供以下组件表单域的校验:`Select` `Radio` `DatePicker` `InputNumber` `Cascader`。在 submit 时使用 `validateFieldsAndScroll`,进行校验,可以自动把不在可见范围内的校验不通过的菜单域滚动进可见范围。
|
||||
|
||||
````jsx
|
||||
import { Select, Radio, Checkbox, Button, DatePicker, TimePicker, InputNumber, Form, Cascader, Icon } from 'antd';
|
||||
import { Select, Radio, Checkbox, Button, DatePicker, InputNumber, Form, Cascader, Icon } from 'antd';
|
||||
const Option = Select.Option;
|
||||
const RadioGroup = Radio.Group;
|
||||
const createForm = Form.create;
|
||||
@@ -84,18 +84,12 @@ let Demo = React.createClass({
|
||||
{
|
||||
required: true,
|
||||
type: 'date',
|
||||
message: '你的生日是什么呢?',
|
||||
message: '你的生日是什么呢?',
|
||||
}, {
|
||||
validator: this.checkBirthday,
|
||||
},
|
||||
],
|
||||
});
|
||||
const timeProps = getFieldProps('time', {
|
||||
getValueFromEvent: (value, timeString) => timeString,
|
||||
rules: [
|
||||
{ required: true, message: '请选择一个时间' },
|
||||
],
|
||||
});
|
||||
const primeNumberProps = getFieldProps('primeNumber', {
|
||||
rules: [{ validator: this.checkPrime }],
|
||||
});
|
||||
@@ -110,7 +104,7 @@ let Demo = React.createClass({
|
||||
<Form horizontal form={this.props.form}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="国籍">
|
||||
label="国籍:">
|
||||
<Select {...selectProps} placeholder="请选择国家" style={{ width: '100%' }}>
|
||||
<Option value="china">中国</Option>
|
||||
<Option value="use">美国</Option>
|
||||
@@ -122,7 +116,7 @@ let Demo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="喜欢的颜色">
|
||||
label="喜欢的颜色:">
|
||||
<Select {...multiSelectProps} multiple placeholder="请选择颜色" style={{ width: '100%' }}>
|
||||
<Option value="red">红色</Option>
|
||||
<Option value="orange">橙色</Option>
|
||||
@@ -134,7 +128,7 @@ let Demo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="性别">
|
||||
label="性别:">
|
||||
<RadioGroup {...radioProps}>
|
||||
<Radio value="male">男</Radio>
|
||||
<Radio value="female">女</Radio>
|
||||
@@ -144,7 +138,7 @@ let Demo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="兴趣爱好">
|
||||
label="兴趣爱好:">
|
||||
<Checkbox {...getFieldProps('eat', {
|
||||
valuePropName: 'checked',
|
||||
})}>吃饭饭</Checkbox>
|
||||
@@ -158,25 +152,19 @@ let Demo = React.createClass({
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="生日">
|
||||
label="生日:">
|
||||
<DatePicker {...birthdayProps} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="选一个时间">
|
||||
<TimePicker {...timeProps} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="8~12间的质数">
|
||||
label="8~12间的质数:">
|
||||
<InputNumber {...primeNumberProps} min={8} max={12} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="选择地址">
|
||||
label="选择地址:">
|
||||
<Cascader {...addressProps} options={address} />
|
||||
</FormItem>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const FormItem = Form.Item;
|
||||
ReactDOM.render(
|
||||
<Form horizontal>
|
||||
<FormItem
|
||||
label="失败校验"
|
||||
label="失败校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
validateStatus="error"
|
||||
@@ -27,7 +27,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="警告校验"
|
||||
label="警告校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
validateStatus="warning">
|
||||
@@ -35,7 +35,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="校验中"
|
||||
label="校验中:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
hasFeedback
|
||||
@@ -45,7 +45,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="成功校验"
|
||||
label="成功校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
hasFeedback
|
||||
@@ -54,7 +54,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="警告校验"
|
||||
label="警告校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
hasFeedback
|
||||
@@ -63,7 +63,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="失败校验"
|
||||
label="失败校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
wrapperCol={{ span: 12 }}
|
||||
hasFeedback
|
||||
@@ -73,7 +73,7 @@ ReactDOM.render(
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label="行内校验"
|
||||
label="行内校验:"
|
||||
labelCol={{ span: 5 }}
|
||||
help>
|
||||
<Col span="6">
|
||||
|
||||
@@ -86,13 +86,12 @@ CustomizedForm = Form.create({})(CustomizedForm);
|
||||
|
||||
> 在表单中 `defaultValue` 也不应该被设置,请使用下面的 `initialValue`。
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| 参数 | 说明 | 类型 |默认值 |
|
||||
|-----------|-----------------------------------------|-----|--------|
|
||||
| options.id | 必填输入控件唯一标志 | string | |
|
||||
| options.valuePropName | 子节点的值的属性,如 Switch 的是 'checked' | string | 'value' |
|
||||
| options.initialValue | 子节点的初始值,类型、可选值均由子节点决定 | | |
|
||||
| options.trigger | 收集子节点的值的时机 | string | 'onChange' |
|
||||
| options.getValueFromEvent | 可以把 onChange 的参数转化为控件的值,例如 DatePicker 可设为:`(date, dateString) => dateString` | function(..args) | [reference](https://github.com/react-component/form#optiongetvaluefromevent) |
|
||||
| options.validateTrigger | 校验子节点值的时机 | string | 'onChange' |
|
||||
| options.rules | 校验规则,参见 [async-validator](https://github.com/yiminghe/async-validator) | array | |
|
||||
| options.onXXX | 由于 `getFieldProps` 会占用 `onChange` 等事件(即你所设置的 `trigger` `validateTrigger`),所以如果仍需绑定事件,请在 `options` 内设置 | function | 无 |
|
||||
|
||||
@@ -84,13 +84,11 @@ input[type="checkbox"] {
|
||||
color: @label-color;
|
||||
text-align: right;
|
||||
vertical-align: middle;
|
||||
padding: 7px 0;
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
|
||||
&:after {
|
||||
content: ":";
|
||||
margin: 0 8px 0 2px;
|
||||
position: relative;
|
||||
top: -0.5px;
|
||||
&:lang(en) {
|
||||
padding-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ english: Icon
|
||||
### 一. 方向性图标
|
||||
|
||||
```__react
|
||||
import IconSet from 'site/theme/template/IconSet';
|
||||
import IconSet from '../../site/component/IconSet';
|
||||
const icons1 = ['step-backward', 'step-forward', 'fast-backward', 'fast-forward', 'shrink', 'arrow-salt', 'down', 'up', 'left', 'right', 'caret-down', 'caret-up', 'caret-left', 'caret-right', 'caret-circle-right', 'caret-circle-left', 'caret-circle-o-right', 'caret-circle-o-left', 'circle-right', 'circle-left', 'circle-o-right', 'circle-o-left', 'double-right', 'double-left', 'verticle-right', 'verticle-left', 'forward', 'backward', 'rollback', 'enter', 'retweet', 'swap', 'swap-left', 'swap-right', 'arrow-right', 'arrow-up', 'arrow-down', 'arrow-left', 'play-circle', 'play-circle-o', 'circle-up', 'circle-down', 'circle-o-up', 'circle-o-down', 'caret-circle-o-up', 'caret-circle-o-down', 'caret-circle-up', 'caret-circle-down'];
|
||||
|
||||
ReactDOM.render(<IconSet className="icons" icons={icons1} key="icons1" />, mountNode);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
order: 3
|
||||
title: 小数
|
||||
- order: 3
|
||||
- title: 小数
|
||||
---
|
||||
|
||||
和原生的数字输入框一样,value 的精度由 step 的小数位数决定。
|
||||
|
||||
@@ -9,6 +9,7 @@ title: 所有组件
|
||||
import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar,
|
||||
Popconfirm, Table, Modal, Button, Select, Transfer, Radio } from 'antd';
|
||||
import enUS from 'antd/lib/locale-provider/en_US';
|
||||
import ruRU from 'antd/lib/locale-provider/ru_RU';
|
||||
const Option = Select.Option;
|
||||
const RangePicker = DatePicker.RangePicker;
|
||||
|
||||
@@ -109,6 +110,7 @@ const App = React.createClass({
|
||||
<span style={{ marginRight: 16 }}>Change locale of components: </span>
|
||||
<Radio.Group defaultValue={enUS} onChange={this.changeLocale}>
|
||||
<Radio.Button key="en" value={enUS}>English</Radio.Button>
|
||||
<Radio.Button key="ru" value={ruRU}>русский язык</Radio.Button>
|
||||
<Radio.Button key="cn">中文</Radio.Button>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import RcMenu, { Item, Divider, SubMenu, ItemGroup } from 'rc-menu';
|
||||
import animation from '../_util/openAnimation';
|
||||
import animation from '../util/openAnimation';
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import Notification from 'rc-notification';
|
||||
import Icon from '../icon';
|
||||
import warning from 'warning';
|
||||
|
||||
let defaultDuration = 1.5;
|
||||
let defaultTop;
|
||||
@@ -59,6 +60,7 @@ export default {
|
||||
},
|
||||
// Departed usage, please use warning()
|
||||
warn(content, duration, onClose) {
|
||||
warning(false, 'message.warn() is departed, please use message.warning()');
|
||||
return notice(content, duration, 'warning', onClose);
|
||||
},
|
||||
warning(content, duration, onClose) {
|
||||
|
||||
@@ -19,7 +19,6 @@ english: Message
|
||||
- `message.error(content, duration)`
|
||||
- `message.info(content, duration)`
|
||||
- `message.warning(content, duration)`
|
||||
- `message.warn(content, duration)`
|
||||
- `message.loading(content, duration)`
|
||||
|
||||
组件提供了四个静态方法,参数如下:
|
||||
|
||||
@@ -31,7 +31,7 @@ Modal.error = function (props) {
|
||||
return confirm(config);
|
||||
};
|
||||
|
||||
Modal.warning = Modal.warn = function (props) {
|
||||
Modal.warning = function (props) {
|
||||
const config = {
|
||||
type: 'warning',
|
||||
iconType: 'exclamation-circle',
|
||||
|
||||
@@ -41,7 +41,6 @@ english: Modal
|
||||
- `Modal.success`
|
||||
- `Modal.error`
|
||||
- `Modal.warning`
|
||||
- `Modal.warn`
|
||||
- `Modal.confirm`
|
||||
|
||||
以上均为一个函数,参数为 object,具体属性如下:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import Notification from 'rc-notification';
|
||||
import Icon from '../icon';
|
||||
import warning from 'warning';
|
||||
|
||||
let defaultTop = 24;
|
||||
let notificationInstance;
|
||||
@@ -94,6 +95,10 @@ const api = {
|
||||
api[type] = (args) => api.open({ ...args, icon: type });
|
||||
});
|
||||
|
||||
api.warn = api.warning;
|
||||
// warn: Departed usage, please use warning()
|
||||
api.warn = (...args) => {
|
||||
warning(false, 'notification.warn() is departed, please use notification.warning()');
|
||||
api.warning(...args);
|
||||
};
|
||||
|
||||
export default api;
|
||||
|
||||
@@ -22,7 +22,6 @@ english: Notification
|
||||
- `notification.error(config)`
|
||||
- `notification.info(config)`
|
||||
- `notification.warning(config)`
|
||||
- `notification.warn(config)`
|
||||
- `notification.close(key: String)`
|
||||
- `notification.destroy()`
|
||||
|
||||
|
||||
@@ -238,7 +238,6 @@
|
||||
top: 0;
|
||||
left: 9999px;
|
||||
white-space: pre;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
> i {
|
||||
|
||||
@@ -13,18 +13,18 @@ english: Slider
|
||||
|
||||
## API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| 参数 | 类型 | 默认值 |说明 |
|
||||
|------------|----------------|-------------|--------------|
|
||||
| range | 双滑块模式 | Boolean | false
|
||||
| min | 最小值 | Number | 0
|
||||
| max | 最大值 | Number | 100
|
||||
| step | 步长,取值必须大于 0,并且可被 (max - min) 整除。当 `marks` 不为空对象时,可以设置 `step` 为 `null`,此时 Slider 的可选值仅有 marks 标出来的部分。 | Number or null | 1
|
||||
| marks | 刻度标记,key 的类型必须为 `Number` 且取值在闭区间 [min, max] 内,每个标签可以单独设置样式 | Object{} | Object{Number: String or React.Component} or Object{Number: { style, label}}
|
||||
| dots | 是否只能拖拽到刻度上 | Boolean | false
|
||||
| value | 设置当前取值。当 `range` 为 `false` 时,使用 `Number`,否则用 `[Number, Number]` | Number or [Number, Number] |
|
||||
| defaultValue | 设置初始取值。当 `range` 为 `false` 时,使用 `Number`,否则用 `[Number, Number]` | Number or [Number, Number] | 0 or [0, 0]
|
||||
| included | `marks` 不为空对象时有效,值为 true 时表示值为包含关系,false 表示并列 | Boolean | true
|
||||
| disabled | 值为 `true` 时,滑块为禁用状态 | Boolean | false
|
||||
| onChange | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入。 | Function | NOOP
|
||||
| onAfterChange | 与 `onmouseup` 触发时机一致,把当前值作为参数传入。 | Function | NOOP
|
||||
| tipFormatter | Slider 会把当前值传给 `tipFormatter`,并在 Tooltip 中显示 `tipFormatter` 的返回值,若为 null,则隐藏 Tooltip。 | Function or null | IDENTITY
|
||||
| range | Boolean | false | 双滑块模式
|
||||
| min | Number | 0 | 最小值
|
||||
| max | Number | 100 | 最大值
|
||||
| step | Number or null | 1 | 步长,取值必须大于 0,并且可被 (max - min) 整除。当 `marks` 不为空对象时,可以设置 `step` 为 `null`,此时 Slider 的可选值仅有 marks 标出来的部分。
|
||||
| marks | Object{Number: String|React.Component} or Object{Number: { style, label}} | {} | 刻度标记,key 的类型必须为 `Number` 且取值在闭区间 [min, max] 内,每个标签可以单独设置样式
|
||||
| dots | Boolean | false | 是否只能拖拽到刻度上
|
||||
| value | Number or [Number, Number]| | 设置当前取值。当 `range` 为 `false` 时,使用 `Number`,否则用 `[Number, Number]`
|
||||
| defaultValue | Number or [Number, Number]| 0 or [0, 0] | 设置初始取值。当 `range` 为 `false` 时,使用 `Number`,否则用 `[Number, Number]`
|
||||
| included | Boolean | true | `marks` 不为空对象时有效,值为 true 时表示值为包含关系,false 表示并列
|
||||
| disabled | Boolean | false | 值为 `true` 时,滑块为禁用状态
|
||||
| onChange | Function | NOOP | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入。
|
||||
| onAfterChange | Function | NOOP | 与 `onmouseup` 触发时机一致,把当前值作为参数传入。
|
||||
| tipFormatter | Function or null | IDENTITY | Slider 会把当前值传给 `tipFormatter`,并在 Tooltip 中显示 `tipFormatter` 的返回值,若为 null,则隐藏 Tooltip。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { findDOMNode } from 'react-dom';
|
||||
import classNames from 'classnames';
|
||||
import isCssAnimationSupported from '../_util/isCssAnimationSupported';
|
||||
import isCssAnimationSupported from '../util/isCssAnimationSupported';
|
||||
import warning from 'warning';
|
||||
|
||||
export default class Spin extends React.Component {
|
||||
|
||||
@@ -48,16 +48,7 @@
|
||||
-webkit-filter: blur(1px);
|
||||
filter: blur(1px);
|
||||
filter: ~"progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false)"; /* IE6~IE9 */
|
||||
position: relative;
|
||||
&:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background: transparent;
|
||||
}
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// tip
|
||||
|
||||
@@ -9,7 +9,7 @@ title: 远程加载数据
|
||||
|
||||
另外,本例也展示了筛选排序功能如何交给服务端实现,列不需要指定具体的 `onFilter` 和 `sorter` 函数,而是在把筛选和排序的参数发到服务端来处理。
|
||||
|
||||
**注意,此示例使用 [模拟接口](https://randomuser.me),展示数据可能不准确,请打开网络面板查看请求。**
|
||||
**注意,此示例是静态数据模拟,展示数据不会变化,请打开网络面板查看请求。**
|
||||
|
||||
````jsx
|
||||
import { Table } from 'antd';
|
||||
@@ -18,20 +18,17 @@ import reqwest from 'reqwest';
|
||||
const columns = [{
|
||||
title: '姓名',
|
||||
dataIndex: 'name',
|
||||
sorter: true,
|
||||
render: name => `${name.first} ${name.last}`,
|
||||
width: '20%',
|
||||
}, {
|
||||
title: '性别',
|
||||
dataIndex: 'gender',
|
||||
filters: [
|
||||
{ text: 'Male', value: 'male' },
|
||||
{ text: 'Female', value: 'female' },
|
||||
{ text: '姓李的', value: '李' },
|
||||
{ text: '姓胡的', value: '胡' },
|
||||
],
|
||||
width: '20%',
|
||||
}, {
|
||||
title: '邮箱',
|
||||
dataIndex: 'email',
|
||||
title: '年龄',
|
||||
dataIndex: 'age',
|
||||
sorter: true,
|
||||
}, {
|
||||
title: '住址',
|
||||
dataIndex: 'address',
|
||||
}];
|
||||
|
||||
const Test = React.createClass({
|
||||
@@ -49,8 +46,8 @@ const Test = React.createClass({
|
||||
pagination: pager,
|
||||
});
|
||||
this.fetch({
|
||||
results: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
currentPage: pagination.current,
|
||||
sortField: sorter.field,
|
||||
sortOrder: sorter.order,
|
||||
...filters,
|
||||
@@ -60,23 +57,19 @@ const Test = React.createClass({
|
||||
console.log('请求参数:', params);
|
||||
this.setState({ loading: true });
|
||||
reqwest({
|
||||
url: 'http://api.randomuser.me',
|
||||
url: '/components/table/demo/data.json',
|
||||
method: 'get',
|
||||
data: {
|
||||
results: 10,
|
||||
...params,
|
||||
},
|
||||
data: params,
|
||||
type: 'json',
|
||||
}).then(data => {
|
||||
const pagination = this.state.pagination;
|
||||
// Read total count from server
|
||||
// pagination.total = data.totalCount;
|
||||
pagination.total = 200;
|
||||
this.setState({
|
||||
loading: false,
|
||||
data: data.results,
|
||||
pagination,
|
||||
});
|
||||
success: (result) => {
|
||||
const pagination = this.state.pagination;
|
||||
pagination.total = result.totalCount;
|
||||
this.setState({
|
||||
loading: false,
|
||||
data: result.data,
|
||||
pagination,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
componentDidMount() {
|
||||
@@ -85,7 +78,6 @@ const Test = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<Table columns={columns}
|
||||
rowKey={record => record.registered}
|
||||
dataSource={this.state.data}
|
||||
pagination={this.state.pagination}
|
||||
loading={this.state.loading}
|
||||
|
||||
56
components/table/demo/data.json
Normal file
56
components/table/demo/data.json
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"data": [{
|
||||
"key": "1",
|
||||
"name": "胡彦斌ajax1",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "2",
|
||||
"name": "胡彦祖ajax2",
|
||||
"age": 42,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "3",
|
||||
"name": "李大嘴ajax3",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "4",
|
||||
"name": "李大嘴ajax4",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "5",
|
||||
"name": "李大嘴ajax5",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "6",
|
||||
"name": "李大嘴ajax6",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "7",
|
||||
"name": "李大嘴ajax7",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "8",
|
||||
"name": "李大嘴ajax8",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "9",
|
||||
"name": "李大嘴ajax9",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}, {
|
||||
"key": "10",
|
||||
"name": "李大嘴ajax10",
|
||||
"age": 32,
|
||||
"address": "西湖区湖底公园1号"
|
||||
}],
|
||||
"totalCount": 35,
|
||||
"pageSize": 10,
|
||||
"currentPage": 1
|
||||
}
|
||||
@@ -5,9 +5,7 @@ title: 固定头和列
|
||||
|
||||
适合同时展示有大量数据和数据列。
|
||||
|
||||
> 若未指定每列的宽度,则建议指定 scroll.x 为固定宽度。
|
||||
|
||||
> 若列头与内容不对齐,请指定每列宽度 `width`。
|
||||
> 需要指定 scroll.x 为宽度,或者指定每列宽度 `width`,否则可能有错位问题。
|
||||
|
||||
````jsx
|
||||
import { Table } from 'antd';
|
||||
@@ -15,14 +13,14 @@ import { Table } from 'antd';
|
||||
const columns = [
|
||||
{ title: '姓名', width: 100, dataIndex: 'name', key: 'name', fixed: 'left' },
|
||||
{ title: '年龄', width: 100, dataIndex: 'age', key: 'age', fixed: 'left' },
|
||||
{ title: '列1', dataIndex: 'address', key: '1', width: 150 },
|
||||
{ title: '列2', dataIndex: 'address', key: '2', width: 150 },
|
||||
{ title: '列3', dataIndex: 'address', key: '3', width: 150 },
|
||||
{ title: '列4', dataIndex: 'address', key: '4', width: 150 },
|
||||
{ title: '列5', dataIndex: 'address', key: '5', width: 150 },
|
||||
{ title: '列6', dataIndex: 'address', key: '6', width: 150 },
|
||||
{ title: '列7', dataIndex: 'address', key: '7', width: 150 },
|
||||
{ title: '列8', dataIndex: 'address', key: '8', width: 150 },
|
||||
{ title: '列1', dataIndex: 'age', key: '1' },
|
||||
{ title: '列2', dataIndex: 'age', key: '2' },
|
||||
{ title: '列3', dataIndex: 'age', key: '3' },
|
||||
{ title: '列4', dataIndex: 'age', key: '4' },
|
||||
{ title: '列5', dataIndex: 'age', key: '5' },
|
||||
{ title: '列6', dataIndex: 'age', key: '6' },
|
||||
{ title: '列7', dataIndex: 'age', key: '7' },
|
||||
{ title: '列8', dataIndex: 'age', key: '8' },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'operation',
|
||||
@@ -43,7 +41,7 @@ for (let i = 0; i < 100; i++) {
|
||||
}
|
||||
|
||||
function App() {
|
||||
return <Table columns={columns} dataSource={data} scroll={{ x: true, y: 300 }} />;
|
||||
return <Table columns={columns} dataSource={data} scroll={{ x: 1000, y: 300 }} />;
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, mountNode);
|
||||
|
||||
@@ -5,9 +5,7 @@ title: 固定列
|
||||
|
||||
对于列数很多的数据,可以固定前后的列,横向滚动查看其它数据,需要和 `scroll.x` 配合使用。
|
||||
|
||||
> 若未指定每列的宽度,则建议指定 scroll.x 为固定宽度。
|
||||
|
||||
> 若列头与内容不对齐,请指定每列宽度 `width`。
|
||||
> 需要指定 scroll.x 为宽度,或者指定每列宽度 `width`,否则可能有错位问题。
|
||||
|
||||
````jsx
|
||||
import { Table } from 'antd';
|
||||
@@ -15,14 +13,14 @@ import { Table } from 'antd';
|
||||
const columns = [
|
||||
{ title: '姓名', width: 100, dataIndex: 'name', key: 'name', fixed: 'left' },
|
||||
{ title: '年龄', width: 100, dataIndex: 'age', key: 'age', fixed: 'left' },
|
||||
{ title: '列1', dataIndex: 'address', key: '1' },
|
||||
{ title: '列2', dataIndex: 'address', key: '2' },
|
||||
{ title: '列3', dataIndex: 'address', key: '3' },
|
||||
{ title: '列4', dataIndex: 'address', key: '4' },
|
||||
{ title: '列5', dataIndex: 'address', key: '5' },
|
||||
{ title: '列6', dataIndex: 'address', key: '6' },
|
||||
{ title: '列7', dataIndex: 'address', key: '7' },
|
||||
{ title: '列8', dataIndex: 'address', key: '8' },
|
||||
{ title: '列1', dataIndex: 'age', key: '1' },
|
||||
{ title: '列2', dataIndex: 'age', key: '2' },
|
||||
{ title: '列3', dataIndex: 'age', key: '3' },
|
||||
{ title: '列4', dataIndex: 'age', key: '4' },
|
||||
{ title: '列5', dataIndex: 'age', key: '5' },
|
||||
{ title: '列6', dataIndex: 'age', key: '6' },
|
||||
{ title: '列7', dataIndex: 'age', key: '7' },
|
||||
{ title: '列8', dataIndex: 'age', key: '8' },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'operation',
|
||||
@@ -36,16 +34,14 @@ const data = [{
|
||||
key: '1',
|
||||
name: '胡彦斌',
|
||||
age: 32,
|
||||
address: '西湖区湖底公园0号',
|
||||
}, {
|
||||
key: '2',
|
||||
name: '胡彦祖',
|
||||
age: 40,
|
||||
address: '西湖区湖底公园1号',
|
||||
age: 42,
|
||||
}];
|
||||
|
||||
function App() {
|
||||
return <Table columns={columns} dataSource={data} scroll={{ x: true }} />;
|
||||
return <Table columns={columns} dataSource={data} scroll={{ x: 1000 }} />;
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, mountNode);
|
||||
|
||||
@@ -3,7 +3,6 @@ import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
|
||||
import Dropdown from '../dropdown';
|
||||
import Icon from '../icon';
|
||||
import Checkbox from '../checkbox';
|
||||
import Radio from '../radio';
|
||||
|
||||
export default class FilterMenu extends React.Component {
|
||||
static defaultProps = {
|
||||
@@ -54,27 +53,22 @@ export default class FilterMenu extends React.Component {
|
||||
}
|
||||
|
||||
renderMenuItem(item) {
|
||||
const { column } = this.props;
|
||||
const multiple = ('filterMultiple' in column) ? column.filterMultiple : true;
|
||||
return (
|
||||
<MenuItem key={item.value}>
|
||||
{
|
||||
multiple
|
||||
? <Checkbox checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
: <Radio checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
}
|
||||
<Checkbox checked={this.state.selectedKeys.indexOf(item.value.toString()) >= 0} />
|
||||
<span>{item.text}</span>
|
||||
</MenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
renderMenus(items) {
|
||||
return items.map(item => {
|
||||
let menuItems = items.map(item => {
|
||||
if (item.children && item.children.length > 0) {
|
||||
const { keyPathOfSelectedItem } = this.state;
|
||||
const containSelected = Object.keys(keyPathOfSelectedItem).some(
|
||||
key => keyPathOfSelectedItem[key].indexOf(item.value) >= 0
|
||||
);
|
||||
const keyPathOfSelectedItem = this.state.keyPathOfSelectedItem;
|
||||
const containSelected = Object.keys(keyPathOfSelectedItem).some(key => {
|
||||
const keyPath = keyPathOfSelectedItem[key];
|
||||
return keyPath.indexOf(item.value) >= 0;
|
||||
});
|
||||
const subMenuCls = containSelected ? 'ant-dropdown-submenu-contain-selected' : '';
|
||||
return (
|
||||
<SubMenu title={item.text} className={subMenuCls} key={item.value.toString()}>
|
||||
@@ -84,6 +78,7 @@ export default class FilterMenu extends React.Component {
|
||||
}
|
||||
return this.renderMenuItem(item);
|
||||
});
|
||||
return menuItems;
|
||||
}
|
||||
|
||||
handleMenuItemClick = (info) => {
|
||||
@@ -102,11 +97,13 @@ export default class FilterMenu extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { column, locale } = this.props;
|
||||
let { column, locale } = this.props;
|
||||
// default multiple selection in filter dropdown
|
||||
const multiple = ('filterMultiple' in column) ? column.filterMultiple : true;
|
||||
|
||||
const menus = (
|
||||
let multiple = true;
|
||||
if ('filterMultiple' in column) {
|
||||
multiple = column.filterMultiple;
|
||||
}
|
||||
let menus = (
|
||||
<div className="ant-table-filter-dropdown">
|
||||
<Menu multiple={multiple}
|
||||
onClick={this.handleMenuItemClick}
|
||||
@@ -129,8 +126,10 @@ export default class FilterMenu extends React.Component {
|
||||
</div>
|
||||
);
|
||||
|
||||
const dropdownSelectedClass = (this.props.selectedKeys.length > 0)
|
||||
? 'ant-table-filter-selected' : '';
|
||||
let dropdownSelectedClass = '';
|
||||
if (this.props.selectedKeys.length > 0) {
|
||||
dropdownSelectedClass = 'ant-table-filter-selected';
|
||||
}
|
||||
|
||||
return (
|
||||
<Dropdown trigger={['click']}
|
||||
|
||||
@@ -742,7 +742,7 @@ export default class Table extends React.Component {
|
||||
table = <Spin className={spinClassName} spinning={this.props.loading}>{table}</Spin>;
|
||||
return (
|
||||
<div className={`${emptyClass} ${className} clearfix`} style={style}>
|
||||
{table}
|
||||
{<Spin className={spinClassName} spinning={this.props.loading}>{table}</Spin>}
|
||||
{this.renderPagination()}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -76,18 +76,19 @@ const columns = [{
|
||||
| footer | 表格底部自定义渲染函数 | Function(currentPageData) | |
|
||||
| scroll | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度:`{{ x: true, y: 300 }}` | Object | - |
|
||||
|
||||
|
||||
### Column
|
||||
|
||||
列描述数据对象,是 columns 中的一项。
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|-----------|----------------------------|-----------------|---------|
|
||||
| title | 列头显示文字 | String or React.Element | - |
|
||||
| key | React 需要的 key,建议设置 | String | - |
|
||||
| dataIndex | 列数据在数据项中对应的 key,支持 `a.b.c` 的嵌套写法 | String | - |
|
||||
| render | 生成复杂数据的渲染函数,参数分别为当前行的值,当前行数据,行索引,@return里面可以设置表格[行/列合并](#demo-colspan-rowspan) | Function(text, record, index) {} | - |
|
||||
| filters | 表头的筛选菜单项 | Array | - |
|
||||
| onFilter | 本地模式下,确定筛选的运行函数 | Function | - |
|
||||
| title | 列头显示文字 | String or React.Element | |
|
||||
| key | React 需要的 key,建议设置 | String | |
|
||||
| dataIndex | 列数据在数据项中对应的 key | String | |
|
||||
| render | 生成复杂数据的渲染函数,参数分别为当前行的值,当前行数据,行索引,@return里面可以设置表格[行/列合并](#demo-colspan-rowspan) | Function(text, record, index) {} | |
|
||||
| filters | 表头的筛选菜单项 | Array | |
|
||||
| onFilter | 本地模式下,确定筛选的运行函数 | Function | |
|
||||
| filterMultiple | 是否多选 | Boolean | true |
|
||||
| sorter | 排序函数,本地排序使用一个函数,需要服务端排序可设为 true | Function or Boolean | - |
|
||||
| colSpan | 表头列合并,设置为 0 时,不渲染 | Number | |
|
||||
@@ -110,6 +111,7 @@ const columns = [{
|
||||
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - |
|
||||
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, changeRows) | - |
|
||||
|
||||
|
||||
## 注意
|
||||
|
||||
按照 React 的[规范](http://facebook.github.io/react/docs/multiple-components.html#dynamic-children),所有的组件数组必须绑定 key。在 Table 中,`dataSource` 和 `columns` 里的数据值都需要指定 `key` 值。对于 `dataSource` 默认将每列数据的 `key` 属性作为唯一的标识。
|
||||
|
||||
@@ -266,10 +266,6 @@
|
||||
box-shadow: none;
|
||||
border-radius: @border-radius-base @border-radius-base 0 0;
|
||||
|
||||
&-item > label + span {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
&-sub {
|
||||
border-radius: @border-radius-base;
|
||||
border: 1px solid @border-color-base;
|
||||
@@ -317,16 +313,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-expand-icon-th {
|
||||
width: 34px;
|
||||
}
|
||||
|
||||
&-row {
|
||||
&-expand-icon {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
text-align: center;
|
||||
line-height: 15px;
|
||||
border: 1px solid @border-color-split;
|
||||
@@ -370,10 +362,6 @@
|
||||
|
||||
&-scroll {
|
||||
overflow: auto;
|
||||
table {
|
||||
width: auto;
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&-body-inner {
|
||||
@@ -399,20 +387,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-fixed-left,
|
||||
&-fixed-right,
|
||||
&-scroll {
|
||||
th,
|
||||
td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
&-fixed-left &-fixed,
|
||||
&-fixed-right &-fixed {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
&-fixed-left {
|
||||
left: 0;
|
||||
box-shadow: @shadow-1-right;
|
||||
@@ -440,12 +414,6 @@
|
||||
table {
|
||||
border-radius: 0 @border-radius-base 0 0;
|
||||
}
|
||||
// hide expand row content in right-fixed Table
|
||||
// https://github.com/ant-design/ant-design/issues/1898
|
||||
.@{table-prefix-cls}-expanded-row {
|
||||
color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&&-scroll-position-left &-fixed-left {
|
||||
|
||||
@@ -41,7 +41,7 @@ const App = React.createClass({
|
||||
{tag.name}
|
||||
</Tag>
|
||||
)}
|
||||
<Button size="small" type="dashed" onClick={this.addTag}>+ 添加标签</Button>
|
||||
<Button size="small" type="primary" onClick={this.addTag}>添加标签</Button>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: @border-radius-base;
|
||||
border: 1px solid @border-color-split;
|
||||
background: #f7f7f7;
|
||||
background: #f3f3f3;
|
||||
font-size: @font-size-base;
|
||||
transition: all 0.3s @ease-in-out-circ;
|
||||
vertical-align: middle;
|
||||
@@ -54,7 +53,6 @@
|
||||
&-green,
|
||||
&-yellow,
|
||||
&-red {
|
||||
border: 0;
|
||||
&,
|
||||
a,
|
||||
a:hover,
|
||||
|
||||
@@ -19,6 +19,3 @@ english: Tooltip
|
||||
|-----------|------------------------------------------|------------|--------|
|
||||
| placement | 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | top |
|
||||
| title | 提示文字 | string/React.Element | 无 |
|
||||
| getTooltipContainer | 浮层渲染父节点。默认渲染到 body 上 | Function(triggerNode) | () => document.body |
|
||||
|
||||
更多 API 可参考:https://github.com/react-component/tooltip
|
||||
|
||||
@@ -41,7 +41,6 @@ export default class Transfer extends React.Component {
|
||||
notFoundContent: PropTypes.node,
|
||||
body: PropTypes.func,
|
||||
footer: PropTypes.func,
|
||||
rowKey: PropTypes.func,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
@@ -62,15 +61,8 @@ export default class Transfer extends React.Component {
|
||||
});
|
||||
}
|
||||
splitDataSource(props) {
|
||||
const { targetKeys } = props;
|
||||
let { dataSource } = props;
|
||||
const { targetKeys, dataSource } = props;
|
||||
|
||||
if (props.rowKey) {
|
||||
dataSource = dataSource.map(record => {
|
||||
record.key = props.rowKey(record);
|
||||
return record;
|
||||
});
|
||||
}
|
||||
let leftDataSource = [...dataSource];
|
||||
let rightDataSource = [];
|
||||
|
||||
|
||||
@@ -29,14 +29,3 @@ english: Transfer
|
||||
| searchPlaceholder | 搜索框的默认值 | String | '请输入搜索内容' |
|
||||
| notFoundContent | 当列表为空时显示的内容 | React.node | '列表为空' |
|
||||
| footer | 底部渲染函数 | Function(props) | |
|
||||
|
||||
|
||||
## 注意
|
||||
|
||||
按照 React 的[规范](http://facebook.github.io/react/docs/multiple-components.html#dynamic-children),所有的组件数组必须绑定 key。在 Transfer 中,`dataSource`里的数据值需要指定 `key` 值。对于 `dataSource` 默认将每列数据的 `key` 属性作为唯一的标识。
|
||||
|
||||
如果你的数据没有这个属性,务必使用 `rowKey` 来指定数据列的主键。
|
||||
```jsx
|
||||
// 比如你的数据主键是 uid
|
||||
return <Transfer rowKey={record => record.uid} />;
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import RcTree from 'rc-tree';
|
||||
import animation from '../_util/openAnimation';
|
||||
import animation from '../util/openAnimation';
|
||||
|
||||
export default class Tree extends React.Component {
|
||||
static TreeNode = RcTree.TreeNode;
|
||||
|
||||
@@ -157,7 +157,6 @@ ReactDOM.render(<ExtendPalettes key="palettes" />, mountNode);
|
||||
`````__react
|
||||
const Values = require('values.js');
|
||||
const CopyToClipboard = require('react-copy-to-clipboard');
|
||||
const antd = require('antd');
|
||||
const Button = antd.Button;
|
||||
const InputNumber = antd.InputNumber;
|
||||
const Slider = antd.Slider;
|
||||
|
||||
@@ -7,7 +7,7 @@ title: 可收起展开的侧边导航
|
||||
|
||||
````jsx
|
||||
import { Menu, Breadcrumb, Icon } from 'antd';
|
||||
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
||||
import BrowserDemo from 'site/component/BrowserDemo';
|
||||
const SubMenu = Menu.SubMenu;
|
||||
|
||||
const AsideCollapse = React.createClass({
|
||||
|
||||
@@ -9,7 +9,7 @@ title: 侧边导航
|
||||
|
||||
````jsx
|
||||
import { Menu, Breadcrumb, Icon } from 'antd';
|
||||
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
||||
import BrowserDemo from 'site/component/BrowserDemo';
|
||||
const SubMenu = Menu.SubMenu;
|
||||
|
||||
ReactDOM.render(
|
||||
|
||||
@@ -9,7 +9,7 @@ title: 吊顶规范
|
||||
|
||||
````jsx
|
||||
import { Menu, Breadcrumb } from 'antd';
|
||||
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
||||
import BrowserDemo from 'site/component/BrowserDemo';
|
||||
|
||||
ReactDOM.render(
|
||||
<BrowserDemo>
|
||||
|
||||
@@ -7,7 +7,7 @@ title: 顶部导航 + 侧边栏
|
||||
|
||||
````jsx
|
||||
import { Menu, Breadcrumb, Icon } from 'antd';
|
||||
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
||||
import BrowserDemo from 'site/component/BrowserDemo';
|
||||
const SubMenu = Menu.SubMenu;
|
||||
|
||||
ReactDOM.render(
|
||||
|
||||
@@ -11,7 +11,7 @@ title: 顶部导航
|
||||
|
||||
````jsx
|
||||
import { Menu, Breadcrumb } from 'antd';
|
||||
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
||||
import BrowserDemo from 'site/component/BrowserDemo';
|
||||
|
||||
ReactDOM.render(
|
||||
<BrowserDemo>
|
||||
|
||||
@@ -11,7 +11,6 @@ english: Motion
|
||||
|
||||
`````__react
|
||||
const cssAnimation = require('css-animation');
|
||||
const antd = require('antd');
|
||||
const Select = antd.Select;
|
||||
const Option = Select.Option;
|
||||
const OptGroup = Select.OptGroup;
|
||||
|
||||
2004
index.d.ts
vendored
2004
index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Ant Design - 一个 UI 设计语言</title>
|
||||
<link rel="icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
|
||||
<link rel="stylesheet" type="text/css" href="{{ root }}index.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="./index.css"/>
|
||||
<!--[if lt IE 10]>
|
||||
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.1.14/es5-shim.min.js,es5-shim/4.1.14/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
|
||||
<![endif]-->
|
||||
@@ -30,7 +30,6 @@
|
||||
return '<span class="' + className + '">' + letter + '</span>';
|
||||
}).join('');
|
||||
</script>
|
||||
<script src="{{ root }}common.js"></script>
|
||||
<script src="{{ root }}index.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
34
index.js
34
index.js
@@ -1,26 +1,28 @@
|
||||
/* eslint no-console:0 */
|
||||
// this file is not used if use https://github.com/ant-design/babel-plugin-antd
|
||||
|
||||
function camelCase(name) {
|
||||
return name.charAt(0).toUpperCase() +
|
||||
name.slice(1).replace(/-(\w)/g, (m, n) => {
|
||||
return n.toUpperCase();
|
||||
});
|
||||
}
|
||||
import {
|
||||
Rate, Affix, DatePicker, Tooltip, Tag, Carousel, Tabs, Modal, Dropdown, Progress, Popover, Select,
|
||||
Breadcrumb, Popconfirm, Pagination, Steps, InputNumber, Switch, Checkbox, Table, Collapse, message,
|
||||
Slider, QueueAnim, Radio, notification, Alert, Validation, Tree, TreeSelect, Upload,
|
||||
Badge, Menu, Timeline, Button, Icon, Row, Col, Spin, Form, Input, Calendar, TimePicker,
|
||||
Card, LocaleProvider, Transfer, Cascader,
|
||||
} from 'antd';
|
||||
|
||||
const req = require.context('./components', true, /^\.\/[^_][\w-]+\/(style\/)?index\.jsx?$/);
|
||||
|
||||
req.keys().forEach((mod) => {
|
||||
const v = req(mod);
|
||||
const match = mod.match(/^\.\/([^_][\w-]+)\/index\.jsx?$/);
|
||||
if (match && match[1]) {
|
||||
exports[camelCase(match[1])] = v;
|
||||
}
|
||||
});
|
||||
// copy from above
|
||||
const antd = {
|
||||
Rate, Affix, DatePicker, Tooltip, Tag, Carousel, Tabs, Modal, Dropdown, Progress, Popover, Select,
|
||||
Breadcrumb, Popconfirm, Pagination, Steps, InputNumber, Switch, Checkbox, Table, Collapse, message,
|
||||
Slider, QueueAnim, Radio, notification, Alert, Validation, Tree, TreeSelect, Upload,
|
||||
Badge, Menu, Timeline, Button, Icon, Row, Col, Spin, Form, Input, Calendar, TimePicker,
|
||||
Card, LocaleProvider, Transfer, Cascader,
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof console !== 'undefined' && console.warn) {
|
||||
console.warn(`You are using prebuilt antd,
|
||||
console.warn(`you are using prebuild antd,
|
||||
please use https://github.com/ant-design/babel-plugin-antd to reduce app bundle size.`);
|
||||
}
|
||||
}
|
||||
|
||||
export default antd;
|
||||
|
||||
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "antd",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.1",
|
||||
"title": "Ant Design",
|
||||
"description": "一个 UI 设计语言",
|
||||
"homepage": "http://ant.design/",
|
||||
@@ -29,7 +29,7 @@
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"index.d.ts"
|
||||
"type-definitions"
|
||||
],
|
||||
"typings": "type-definitions/antd.d.ts",
|
||||
"license": "MIT",
|
||||
@@ -40,7 +40,6 @@
|
||||
"gregorian-calendar": "~4.1.0",
|
||||
"gregorian-calendar-format": "~4.1.0",
|
||||
"normalize.css": "^4.1.1",
|
||||
"nunjucks": "^2.4.2",
|
||||
"rc-animate": "~2.0.4",
|
||||
"rc-calendar": "~5.5.4",
|
||||
"rc-cascader": "~0.9.9",
|
||||
@@ -58,16 +57,16 @@
|
||||
"rc-radio": "~2.0.0",
|
||||
"rc-rate": "~1.1.1",
|
||||
"rc-select": "~6.4.0",
|
||||
"rc-slider": "~3.7.0",
|
||||
"rc-slider": "~3.6.2",
|
||||
"rc-steps": "~2.1.3",
|
||||
"rc-switch": "~1.4.2",
|
||||
"rc-table": "~4.1.1",
|
||||
"rc-table": "~4.0.6",
|
||||
"rc-tabs": "~5.9.1",
|
||||
"rc-time-picker": "~1.1.4",
|
||||
"rc-tooltip": "~3.3.2",
|
||||
"rc-tree": "~1.3.1",
|
||||
"rc-tree-select": "~1.7.2",
|
||||
"rc-upload": "~1.13.0",
|
||||
"rc-upload": "~1.12.0",
|
||||
"rc-util": "~3.1.3",
|
||||
"react-slick": "~0.12.0",
|
||||
"warning": "~2.1.0"
|
||||
@@ -77,10 +76,6 @@
|
||||
"babel-eslint": "^6.0.2",
|
||||
"babel-jest": "^12.0.2",
|
||||
"babel-plugin-antd": "^0.4.0",
|
||||
"bisheng": "^0.5.0",
|
||||
"bisheng-plugin-description": "^0.1.1",
|
||||
"bisheng-plugin-react": "^0.1.0",
|
||||
"bisheng-plugin-toc": "0.2.0",
|
||||
"dom-scroll-into-view": "^1.1.0",
|
||||
"enquire.js": "^2.1.1",
|
||||
"es6-shim": "^0.35.0",
|
||||
@@ -109,7 +104,6 @@
|
||||
"react": "^15.0.0",
|
||||
"react-addons-test-utils": "^15.0.0",
|
||||
"react-copy-to-clipboard": "^4.0.1",
|
||||
"react-document-title": "^2.0.1",
|
||||
"react-dom": "^15.0.0",
|
||||
"react-github-button": "^0.1.1",
|
||||
"react-intl": "^2.0.1",
|
||||
@@ -124,9 +118,9 @@
|
||||
"dist": "antd-tools run dist",
|
||||
"compile": "antd-tools run compile",
|
||||
"clean": "antd-tools run clean",
|
||||
"start": "bisheng start -c ./site/bisheng.config.js",
|
||||
"start": "antd-tools run start",
|
||||
"site": "antd-tools run site",
|
||||
"pre-deploy": "cp CNAME _site",
|
||||
"pre-deploy": "cp CNAME _site && rsync -R components/*/demo/*.json _site",
|
||||
"deploy": "antd-tools run update-self && antd-tools run deploy",
|
||||
"just-deploy": "antd-tools run just-deploy",
|
||||
"lint": "npm run srclint && npm run demolint && npm run lesshint",
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
const React = require('react');
|
||||
const Link = require('react-router').Link;
|
||||
const toReactComponent = require('jsonml-to-react-component');
|
||||
const JsonML = require('jsonml.js/lib/utils');
|
||||
const VideoPlayer = require('./VideoPlayer');
|
||||
const ImagePreview = require('./ImagePreview');
|
||||
|
||||
function isHeading(node) {
|
||||
return /h[1-6]/i.test(JsonML.getTagName(node));
|
||||
}
|
||||
|
||||
module.exports = () => {
|
||||
return {
|
||||
converters: [
|
||||
[(node) => JsonML.isElement(node) && isHeading(node), (node, index) => {
|
||||
const children = JsonML.getChildren(node);
|
||||
return React.createElement(JsonML.getTagName(node), {
|
||||
key: index,
|
||||
id: children,
|
||||
...JsonML.getAttributes(node),
|
||||
}, [
|
||||
<span key="title">{children.map((child) => toReactComponent(child))}</span>,
|
||||
<a href={`#${children}`} className="anchor" key="anchor">#</a>,
|
||||
]);
|
||||
}],
|
||||
[(node) => JsonML.isElement(node) && JsonML.getTagName(node) === 'video', (node, index) =>
|
||||
<VideoPlayer video={JsonML.getAttributes(node)} key={index} />,
|
||||
],
|
||||
[(node) => JsonML.isElement(node) && JsonML.getTagName(node) === 'a' && !(
|
||||
JsonML.getAttributes(node).class ||
|
||||
(JsonML.getAttributes(node).href &&
|
||||
JsonML.getAttributes(node).href.indexOf('http') === 0) ||
|
||||
/^#/.test(JsonML.getAttributes(node).href)
|
||||
), (node, index) => {
|
||||
return <Link to={JsonML.getAttributes(node).href} key={index}>{toReactComponent(JsonML.getChildren(node)[0])}</Link>;
|
||||
}],
|
||||
[(node) => {
|
||||
return JsonML.isElement(node) &&
|
||||
JsonML.getTagName(node) === 'p' &&
|
||||
JsonML.getTagName(JsonML.getChildren(node)[0]) === 'img' &&
|
||||
/preview-img/gi.test(JsonML.getAttributes(JsonML.getChildren(node)[0]).class);
|
||||
}, (node, index) => {
|
||||
const imgs = JsonML.getChildren(node)
|
||||
.filter((img) => JsonML.isElement(img) && Object.keys(JsonML.getAttributes(img)).length > 0)
|
||||
.map((img) => JsonML.getAttributes(img));
|
||||
return <ImagePreview imgs={imgs} key={index} />;
|
||||
}],
|
||||
],
|
||||
};
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
const path = require('path');
|
||||
const processDoc = require('./process-doc');
|
||||
const processDemo = require('./process-demo');
|
||||
|
||||
module.exports = (markdownData) => {
|
||||
const isDemo = path.dirname(markdownData.meta.filename).endsWith('/demo');
|
||||
if (isDemo) {
|
||||
return processDemo(markdownData);
|
||||
}
|
||||
return processDoc(markdownData);
|
||||
};
|
||||
@@ -1,91 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const JsonML = require('jsonml.js/lib/utils');
|
||||
const pkgPath = path.join(process.cwd(), 'package.json');
|
||||
const pkgName = require(pkgPath).name;
|
||||
|
||||
const nunjucks = require('nunjucks');
|
||||
nunjucks.configure({ autoescape: false });
|
||||
|
||||
const babel = require('babel-core');
|
||||
const babelrc = {
|
||||
presets: ['es2015', 'react'].map((m) => {
|
||||
return require.resolve(`babel-preset-${m}`);
|
||||
}),
|
||||
};
|
||||
|
||||
const tmpl = fs.readFileSync(path.join(__dirname, 'template.html')).toString();
|
||||
|
||||
function isStyleTag(node) {
|
||||
return node && JsonML.getTagName(node) === 'style';
|
||||
}
|
||||
|
||||
function getCode(node) {
|
||||
return JsonML.getChildren(
|
||||
JsonML.getChildren(node)[0]
|
||||
)[0];
|
||||
}
|
||||
|
||||
module.exports = (markdownData) => {
|
||||
const meta = markdownData.meta;
|
||||
meta.id = meta.filename.replace(/\.md$/, '').replace(/\//g, '-');
|
||||
|
||||
const contentChildren = JsonML.getChildren(markdownData.content);
|
||||
const chineseIntroStart = contentChildren.findIndex((node) => {
|
||||
return JsonML.getTagName(node) === 'h2' &&
|
||||
JsonML.getChildren(node)[0] === 'zh-CN';
|
||||
});
|
||||
const englishIntroStart = contentChildren.findIndex((node) => {
|
||||
return JsonML.getTagName(node) === 'h2' &&
|
||||
JsonML.getChildren(node)[0] === 'en-US';
|
||||
});
|
||||
const codeIndex = contentChildren.findIndex((node) => {
|
||||
return JsonML.getTagName(node) === 'pre' &&
|
||||
JsonML.getAttributes(node).lang === 'jsx';
|
||||
});
|
||||
if (chineseIntroStart > -1 /* equal to englishIntroStart > -1 */) {
|
||||
markdownData.content = {
|
||||
'zh-CN': contentChildren.slice(chineseIntroStart + 1, englishIntroStart),
|
||||
'en-US': contentChildren.slice(englishIntroStart + 1, codeIndex),
|
||||
};
|
||||
} else {
|
||||
markdownData.content = contentChildren.slice(0, codeIndex);
|
||||
}
|
||||
|
||||
markdownData.highlightedCode = contentChildren[codeIndex].slice(0, 2);
|
||||
const preview = [
|
||||
'pre', { lang: '__react' },
|
||||
];
|
||||
const componentsPath = path.join(process.cwd(), 'components');
|
||||
preview.push([
|
||||
'code',
|
||||
getCode(contentChildren[codeIndex])
|
||||
.replace(`${pkgName}/lib`, componentsPath),
|
||||
]);
|
||||
markdownData.preview = preview;
|
||||
|
||||
const styleNode = contentChildren.find((node) => {
|
||||
return isStyleTag(node) ||
|
||||
(JsonML.getTagName(node) === 'pre' && JsonML.getAttributes(node).lang === 'css');
|
||||
});
|
||||
if (isStyleTag(styleNode)) {
|
||||
markdownData.style = JsonML.getChildren(styleNode)[0];
|
||||
} else if (styleNode) {
|
||||
const styleTag = contentChildren.find(isStyleTag);
|
||||
markdownData.style = getCode(styleNode) + (styleTag ? JsonML.getChildren(styleTag)[0] : '');
|
||||
markdownData.highlightedStyle = JsonML.getAttributes(styleNode).highlighted;
|
||||
}
|
||||
|
||||
if (meta.iframe) {
|
||||
const html = nunjucks.renderString(tmpl, {
|
||||
id: meta.id,
|
||||
style: markdownData.style,
|
||||
script: babel.transform(getCode(markdownData.preview), babelrc).code,
|
||||
});
|
||||
const fileName = `demo-${Math.random()}.html`;
|
||||
fs.writeFile(path.join(process.cwd(), '_site', fileName), html);
|
||||
markdownData.src = path.join('/', fileName);
|
||||
}
|
||||
|
||||
return markdownData;
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
const JsonML = require('jsonml.js/lib/utils');
|
||||
|
||||
module.exports = (markdownData) => {
|
||||
const contentChildren = JsonML.getChildren(markdownData.content);
|
||||
const apiStartIndex = contentChildren.findIndex((node) => {
|
||||
return JsonML.getTagName(node) === 'h2' &&
|
||||
JsonML.getChildren(node)[0] === 'API';
|
||||
});
|
||||
|
||||
if (apiStartIndex > -1) {
|
||||
const content = contentChildren.slice(0, apiStartIndex);
|
||||
markdownData.content = ['section'].concat(content);
|
||||
|
||||
const api = contentChildren.slice(apiStartIndex);
|
||||
markdownData.api = ['section'].concat(api);
|
||||
}
|
||||
|
||||
return markdownData;
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Demo</title>
|
||||
<link rel="stylesheet" href="../index.css" />
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
background: none;
|
||||
}
|
||||
{{ style }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="{{ id }}" class="code-box-demo"></div>
|
||||
<script>
|
||||
function require(module) {
|
||||
if (module === 'react-router') {
|
||||
return window.ReactRouter;
|
||||
}
|
||||
return window.parent[module];
|
||||
}
|
||||
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
var mountNode = document.getElementById('{{ id }}');
|
||||
</script>
|
||||
<script src="https://npmcdn.com/react-router/umd/ReactRouter.min.js"></script>
|
||||
<script>
|
||||
{{ script }}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
port: 8001,
|
||||
source: [
|
||||
'./components',
|
||||
'./docs',
|
||||
'CHANGELOG.md', // TODO: fix it in bisheng
|
||||
],
|
||||
theme: './site/theme',
|
||||
htmlTemplate: './site/theme/static/template.html',
|
||||
plugins: [
|
||||
'bisheng-plugin-description',
|
||||
'bisheng-plugin-toc?maxDepth=2',
|
||||
'bisheng-plugin-react?lang=__react',
|
||||
'./site/bisheng-plugin-antd',
|
||||
],
|
||||
webpackConfig(config) {
|
||||
config.resolve.alias = {
|
||||
antd: process.cwd(),
|
||||
site: path.join(process.cwd(), 'site'),
|
||||
};
|
||||
|
||||
config.babel.plugins.push([
|
||||
require.resolve('babel-plugin-antd'),
|
||||
{
|
||||
style: true,
|
||||
libraryName: 'antd',
|
||||
libDir: 'components',
|
||||
},
|
||||
]);
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
||||
18
site/common/lib.js
Normal file
18
site/common/lib.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import './styles/highlight.less';
|
||||
import './styles/common.less';
|
||||
import './styles/markdown.less';
|
||||
import './styles/toc.less';
|
||||
import './styles/font.less';
|
||||
import './styles/resource.less';
|
||||
import './styles/clearfix.less';
|
||||
import './styles/demo.less';
|
||||
import './styles/page-nav.less';
|
||||
import './styles/footer.less';
|
||||
import './styles/preview-img.less';
|
||||
import './styles/mock-browser.less';
|
||||
import './styles/colors.less';
|
||||
import './styles/motion.less';
|
||||
import './styles/responsive.less';
|
||||
import './styles/new-version-info-modal.less';
|
||||
|
||||
import 'es6-shim';
|
||||
14
site/common/styles/clearfix.less
Normal file
14
site/common/styles/clearfix.less
Normal file
@@ -0,0 +1,14 @@
|
||||
.clearfix {
|
||||
zoom: 1;
|
||||
&:before,
|
||||
&:after {
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
&:after {
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
font-size: 0;
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ a {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
div.main-container {
|
||||
.main-container {
|
||||
padding: 0 6% 120px 4%;
|
||||
margin-left: -1px;
|
||||
background: #fff;
|
||||
@@ -39,7 +39,7 @@
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.code-box:target {
|
||||
.code-box.code-box-target {
|
||||
border: 1px solid rgba(45, 183, 245, 0.7);
|
||||
box-shadow: 0 0 4px rgba(45, 183, 245, 0.5);
|
||||
}
|
||||
@@ -70,7 +70,7 @@
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.code-box-meta.markdown {
|
||||
.code-box-meta {
|
||||
position: relative;
|
||||
padding: 16px;
|
||||
border-radius: 0 0 6px 6px;
|
||||
@@ -80,7 +80,7 @@
|
||||
}
|
||||
|
||||
.code-box-meta h4,
|
||||
section.code-box-meta p {
|
||||
.code-box-meta p {
|
||||
margin: 0;
|
||||
width: 93%;
|
||||
}
|
||||
@@ -165,7 +165,6 @@ section.code-box-meta p {
|
||||
opacity: 0;
|
||||
overflow: auto;
|
||||
transition: all 0.4s ease;
|
||||
border-radius: 0 0 6px 6px;
|
||||
}
|
||||
.code-box .highlight-wrapper-expand {
|
||||
max-height: 500px;
|
||||
@@ -173,11 +172,8 @@ section.code-box-meta p {
|
||||
}
|
||||
|
||||
.code-box .highlight {
|
||||
pre {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
}
|
||||
padding: 5px;
|
||||
|
||||
&:not(:first-child) {
|
||||
border-top: 1px dashed #e9e9e9;
|
||||
}
|
||||
@@ -258,6 +254,7 @@ section.code-box-meta p {
|
||||
width:15%;
|
||||
float:right;
|
||||
margin:12px 10px 0;
|
||||
|
||||
}
|
||||
.code-box-demo .demo-content .demo-listBox .demo-list ul li {
|
||||
height: 25px;
|
||||
@@ -345,6 +342,8 @@ section.code-box-meta p {
|
||||
content: "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// queue-animate style, should be remove after queue-animate is remove.
|
||||
.code-box-demo .demo-header {
|
||||
width: 100%;
|
||||
@@ -99,6 +99,7 @@
|
||||
|
||||
.markdown pre code {
|
||||
border: none;
|
||||
padding: 1em 2em;
|
||||
background: #f7f7f7;
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
13
site/component/App.jsx
Normal file
13
site/component/App.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import Header from './Header';
|
||||
import Footer from './Footer';
|
||||
|
||||
export default function App(props) {
|
||||
return (
|
||||
<div className="page-wrapper">
|
||||
<Header {...props} />
|
||||
{props.children}
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
90
site/component/Article/index.jsx
Normal file
90
site/component/Article/index.jsx
Normal file
@@ -0,0 +1,90 @@
|
||||
import React, { Children, cloneElement } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import * as utils from '../utils';
|
||||
import { getTagName, getChildren } from 'jsonml.js/lib/utils';
|
||||
import { Timeline } from 'antd';
|
||||
|
||||
export default class Article extends React.Component {
|
||||
componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const { title, chinese, english } = this.props.content.meta;
|
||||
utils.setTitle(`${title || chinese || english} - Ant Design`);
|
||||
const links = Array.apply(null, document.querySelectorAll('.outside-link.internal'));
|
||||
if (links.length === 0) {
|
||||
return;
|
||||
}
|
||||
const checkImgUrl = 'http://alipay-rmsdeploy-dev-image.oss-cn-hangzhou-zmf.aliyuncs.com/rmsportal/JdVaTbZzPxEldUi.png';
|
||||
utils.ping(checkImgUrl, status => {
|
||||
if (status === 'responded') {
|
||||
links.forEach(link => (link.style.display = 'block'));
|
||||
}
|
||||
});
|
||||
}
|
||||
getArticle(article) {
|
||||
const { content } = this.props;
|
||||
const { meta } = content;
|
||||
if (!meta.timeline) {
|
||||
return article;
|
||||
}
|
||||
const timelineItems = [];
|
||||
let temp = [];
|
||||
Children.forEach(article.props.children, (child, i) => {
|
||||
if (child.type === 'h2' && temp.length > 0) {
|
||||
timelineItems.push(<Timeline.Item key={i}>{temp}</Timeline.Item>);
|
||||
temp = [];
|
||||
}
|
||||
temp.push(child);
|
||||
});
|
||||
return cloneElement(article, {
|
||||
children: <Timeline>{timelineItems}</Timeline>,
|
||||
});
|
||||
}
|
||||
render() {
|
||||
const { content, location } = this.props;
|
||||
const jumper = content.description.filter((node) => {
|
||||
return getTagName(node) === 'h2';
|
||||
}).map((node) => {
|
||||
return (
|
||||
<li key={getChildren(node)[0]}>
|
||||
<Link to={{ pathname: location.pathname, query: { scrollTo: getChildren(node)[0] } }}>
|
||||
{utils.jsonmlToComponent(location.pathname, getChildren(node)[0])}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
|
||||
const { meta, intro, description } = content;
|
||||
|
||||
return (
|
||||
<article className="markdown">
|
||||
<h1>
|
||||
{meta.title || meta.english} {meta.subtitle || meta.chinese}
|
||||
{
|
||||
!meta.subtitle ? null :
|
||||
<span className="subtitle">{meta.subtitle}</span>
|
||||
}
|
||||
</h1>
|
||||
{
|
||||
!intro ? null :
|
||||
utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
['section', { className: 'markdown' }].concat(intro)
|
||||
)
|
||||
}
|
||||
{
|
||||
(jumper.length > 0 && meta.toc !== false) ?
|
||||
<section className="toc"><ul>{jumper}</ul></section> :
|
||||
null
|
||||
}
|
||||
{
|
||||
this.getArticle(utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
['section', { className: 'markdown' }].concat(description)
|
||||
))
|
||||
}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
}
|
||||
131
site/component/ComponentDoc/index.jsx
Normal file
131
site/component/ComponentDoc/index.jsx
Normal file
@@ -0,0 +1,131 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import classNames from 'classnames';
|
||||
import { Row, Col, Icon, Affix } from 'antd';
|
||||
import Demo from '../Demo';
|
||||
import * as utils from '../utils';
|
||||
import demosList from '../../../_data/demos-list';
|
||||
|
||||
export default class ComponentDoc extends React.Component {
|
||||
static contextTypes = {
|
||||
intl: React.PropTypes.object,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
expandAll: false,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const { title, subtitle, chinese, english } = this.props.doc.meta;
|
||||
utils.setTitle(`${subtitle || chinese || ''} ${title || english} - Ant Design`);
|
||||
}
|
||||
|
||||
handleExpandToggle = () => {
|
||||
this.setState({
|
||||
expandAll: !this.state.expandAll,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { doc, location } = this.props;
|
||||
const scrollTo = location.query.scrollTo;
|
||||
const { description, meta } = doc;
|
||||
const locale = this.context.intl.locale;
|
||||
const demos = (demosList[meta.fileName.replace(`.${locale}`, '')] || [])
|
||||
.filter((demoData) => !demoData.meta.hidden);
|
||||
const expand = this.state.expandAll;
|
||||
|
||||
const isSingleCol = meta.cols === 1;
|
||||
const leftChildren = [];
|
||||
const rightChildren = [];
|
||||
demos.sort((a, b) => {
|
||||
return parseInt(a.meta.order, 10) - parseInt(b.meta.order, 10);
|
||||
}).forEach((demoData, index) => {
|
||||
if (index % 2 === 0 || isSingleCol) {
|
||||
leftChildren.push(
|
||||
<Demo {...demoData} className={scrollTo === demoData.id ? 'code-box-target' : ''}
|
||||
key={index}
|
||||
expand={expand} pathname={location.pathname} />
|
||||
);
|
||||
} else {
|
||||
rightChildren.push(
|
||||
<Demo {...demoData} className={scrollTo === demoData.id ? 'code-box-target' : ''}
|
||||
key={index}
|
||||
expand={expand} pathname={location.pathname} />
|
||||
);
|
||||
}
|
||||
});
|
||||
const expandTriggerClass = classNames({
|
||||
'code-box-expand-trigger': true,
|
||||
'code-box-expand-trigger-active': expand,
|
||||
});
|
||||
|
||||
const jumper = demos.map((demo) => {
|
||||
const title = demo.meta.title;
|
||||
const localizeTitle = typeof title === 'object' ?
|
||||
title[locale] : title;
|
||||
return (
|
||||
<li key={demo.id}>
|
||||
<Link className={demo.id === scrollTo ? 'current' : ''}
|
||||
to={{ pathname: location.pathname, query: { scrollTo: `${demo.id}` } }}>
|
||||
{localizeTitle}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<article>
|
||||
<Affix className="toc-affix" offsetTop={16}>
|
||||
<ul className="toc demos-anchor">
|
||||
{jumper}
|
||||
</ul>
|
||||
</Affix>
|
||||
<section className="markdown">
|
||||
<h1>{meta.title || meta.english} {meta.subtitle || meta.chinese}</h1>
|
||||
{
|
||||
utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
['section', { className: 'markdown' }]
|
||||
.concat(description)
|
||||
)
|
||||
}
|
||||
<h2>
|
||||
代码演示
|
||||
<Icon type="appstore" className={expandTriggerClass}
|
||||
title="展开全部代码" onClick={this.handleExpandToggle} />
|
||||
</h2>
|
||||
</section>
|
||||
<Row gutter={16}>
|
||||
<Col span={isSingleCol ? '24' : '12'}
|
||||
className={isSingleCol ?
|
||||
'code-boxes-col-1-1' :
|
||||
'code-boxes-col-2-1'
|
||||
}
|
||||
>
|
||||
{leftChildren}
|
||||
</Col>
|
||||
{
|
||||
isSingleCol ? null :
|
||||
<Col className="code-boxes-col-2-1" span="12">{rightChildren}</Col>
|
||||
}
|
||||
</Row>
|
||||
{
|
||||
utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
['section', {
|
||||
className: 'markdown api-container',
|
||||
}].concat(doc.api || [])
|
||||
)
|
||||
}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Link } from 'react-router';
|
||||
import classNames from 'classnames';
|
||||
import * as utils from '../utils';
|
||||
|
||||
const isLocal = location.port;
|
||||
|
||||
export default class Demo extends React.Component {
|
||||
static contextTypes = {
|
||||
@@ -28,40 +31,27 @@ export default class Demo extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {
|
||||
meta,
|
||||
src,
|
||||
content,
|
||||
preview,
|
||||
highlightedCode,
|
||||
style,
|
||||
highlightedStyle,
|
||||
} = props;
|
||||
|
||||
const { id, className, meta, intro, preview, style, src,
|
||||
highlightedCode, highlightedStyle, pathname } = this.props;
|
||||
const codeExpand = this.state.codeExpand;
|
||||
const codeBoxClass = classNames({
|
||||
'code-box': true,
|
||||
[className]: className,
|
||||
expand: codeExpand,
|
||||
});
|
||||
|
||||
const locale = this.context.intl.locale;
|
||||
const localizedTitle = meta.title[locale] || meta.title;
|
||||
const localizeIntro = content[locale] || content;
|
||||
const introChildren = props.utils
|
||||
.toReactComponent(['div'].concat(localizeIntro));
|
||||
|
||||
const highlightClass = classNames({
|
||||
'highlight-wrapper': true,
|
||||
'highlight-wrapper-expand': codeExpand,
|
||||
});
|
||||
const localizeIntro = intro[locale] || intro;
|
||||
const introChildren = utils.jsonmlToComponent(pathname, ['div'].concat(localizeIntro));
|
||||
const localizedTitle = typeof meta.title === 'object' ?
|
||||
meta.title[locale] : meta.title;
|
||||
return (
|
||||
<section className={codeBoxClass} id={meta.id}>
|
||||
<section className={codeBoxClass} id={id}>
|
||||
<section className="code-box-demo">
|
||||
{
|
||||
meta.iframe ?
|
||||
<iframe src={src} /> :
|
||||
preview(React, ReactDOM)
|
||||
<iframe src={isLocal ? src : src.replace('./_site', '')} /> :
|
||||
preview
|
||||
}
|
||||
{
|
||||
!!style ?
|
||||
@@ -71,19 +61,23 @@ export default class Demo extends React.Component {
|
||||
</section>
|
||||
<section className="code-box-meta markdown">
|
||||
<div className="code-box-title">
|
||||
<a href={`#${meta.id}`}>
|
||||
<Link to={{ pathname, query: { scrollTo: id } }}>
|
||||
{localizedTitle}
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
{introChildren}
|
||||
<span className="collapse anticon anticon-circle-o-right"
|
||||
onClick={this.handleCodeExapnd}
|
||||
unselectable="none" />
|
||||
</section>
|
||||
<section className={highlightClass}
|
||||
<section className={`highlight-wrapper ${codeExpand ? 'highlight-wrapper-expand' : ''}`}
|
||||
key="code">
|
||||
<div className="highlight">
|
||||
{props.utils.toReactComponent(highlightedCode)}
|
||||
<pre>
|
||||
<code className="javascript" dangerouslySetInnerHTML={{
|
||||
__html: highlightedCode,
|
||||
}} />
|
||||
</pre>
|
||||
</div>
|
||||
{
|
||||
highlightedStyle ?
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user