upgrade eslint-config-airbnb

This commit is contained in:
afc163 2018-06-27 15:55:04 +08:00
parent 6a0b4f1d27
commit 009ed08580
320 changed files with 876 additions and 456 deletions

View File

@ -8,13 +8,6 @@ const eslintrc = {
es6: true, es6: true,
}, },
parser: 'babel-eslint', parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true,
},
},
plugins: [ plugins: [
'markdown', 'markdown',
'react', 'react',
@ -65,6 +58,8 @@ if (process.env.RUN_ENV === 'DEMO') {
'eol-last': 0, 'eol-last': 0,
'no-script-url': 0, 'no-script-url': 0,
'prefer-rest-params': 0, 'prefer-rest-params': 0,
'react/no-access-state-in-setstate': 0,
'react/destructuring-assignment': 0,
'react/no-multi-comp': 0, 'react/no-multi-comp': 0,
'react/prefer-stateless-function': 0, 'react/prefer-stateless-function': 0,
'jsx-a11y/href-no-hash': 0, 'jsx-a11y/href-no-hash': 0,

View File

@ -21,6 +21,7 @@ class Demo extends React.Component {
top: 10, top: 10,
bottom: 10, bottom: 10,
} }
render() { render() {
return ( return (
<div> <div>
@ -54,8 +55,5 @@ class Demo extends React.Component {
} }
} }
ReactDOM.render( ReactDOM.render(<Demo />, mountNode);
<Demo />,
mountNode
);
```` ````

View File

@ -26,6 +26,6 @@ ReactDOM.render(
<Alert showIcon={false} message="Warning text without icon" banner /> <Alert showIcon={false} message="Warning text without icon" banner />
<br /> <br />
<Alert type="error" message="Error text" banner /> <Alert type="error" message="Error text" banner />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -17,8 +17,8 @@ The simplest usage for short messages.
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( ReactDOM.render(
<Alert message="Success Text" type="success" /> <Alert message="Success Text" type="success" />,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -35,6 +35,6 @@ ReactDOM.render(
closable closable
onClose={onClose} onClose={onClose}
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -17,6 +17,6 @@ Replace the default icon with customized text.
import { Alert } from 'antd'; import { Alert } from 'antd';
ReactDOM.render( ReactDOM.render(
<Alert message="Info Text" type="info" closeText="Close Now" /> <Alert message="Info Text" type="info" closeText="Close Now" />,
, mountNode); mountNode);
```` ````

View File

@ -38,6 +38,6 @@ ReactDOM.render(
description="Error Description Error Description Error Description Error Description" description="Error Description Error Description Error Description Error Description"
type="error" type="error"
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -46,6 +46,6 @@ ReactDOM.render(
type="error" type="error"
showIcon showIcon
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -20,9 +20,11 @@ class App extends React.Component {
state = { state = {
visible: true, visible: true,
} }
handleClose = () => { handleClose = () => {
this.setState({ visible: false }); this.setState({ visible: false });
} }
render() { render() {
return ( return (
<div> <div>
@ -43,6 +45,6 @@ class App extends React.Component {
} }
ReactDOM.render( ReactDOM.render(
<App /> <App />,
, mountNode); mountNode);
```` ````

View File

@ -22,6 +22,6 @@ ReactDOM.render(
<Alert message="Info Text" type="info" /> <Alert message="Info Text" type="info" />
<Alert message="Warning Text" type="warning" /> <Alert message="Warning Text" type="warning" />
<Alert message="Error Text" type="error" /> <Alert message="Error Text" type="error" />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ The simplest usage.
```jsx ```jsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
const { Link } = Anchor; const { Link } = Anchor;
ReactDOM.render( ReactDOM.render(
@ -25,8 +26,8 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor> </Anchor>,
, mountNode); mountNode);
``` ```
<style> <style>

View File

@ -15,6 +15,7 @@ Do not change state when page is scrolling.
```jsx ```jsx
import { Anchor } from 'antd'; import { Anchor } from 'antd';
const { Link } = Anchor; const { Link } = Anchor;
ReactDOM.render( ReactDOM.render(
@ -25,6 +26,6 @@ ReactDOM.render(
<Link href="#Anchor-Props" title="Anchor Props" /> <Link href="#Anchor-Props" title="Anchor Props" />
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor> </Anchor>,
, mountNode); mountNode);
``` ```

View File

@ -16,6 +16,7 @@ Basic Usage, set datasource of autocomplete with `dataSource` property.
````jsx ````jsx
import { Icon, Input, AutoComplete } from 'antd'; import { Icon, Input, AutoComplete } from 'antd';
const Option = AutoComplete.Option; const Option = AutoComplete.Option;
const OptGroup = AutoComplete.OptGroup; const OptGroup = AutoComplete.OptGroup;

View File

@ -15,6 +15,7 @@ Customize Input Component
````jsx ````jsx
import { AutoComplete, Input } from 'antd'; import { AutoComplete, Input } from 'antd';
const { TextArea } = Input; const { TextArea } = Input;
function onSelect(value) { function onSelect(value) {

View File

@ -16,6 +16,7 @@ Basic Usage, set datasource of autocomplete with `dataSource` property.
````jsx ````jsx
import { Icon, Button, Input, AutoComplete } from 'antd'; import { Icon, Button, Input, AutoComplete } from 'antd';
const Option = AutoComplete.Option; const Option = AutoComplete.Option;
function onSelect(value) { function onSelect(value) {

View File

@ -24,6 +24,6 @@ ReactDOM.render(
<span> <span>
<Badge dot><Avatar shape="square" icon="user" /></Badge> <Badge dot><Avatar shape="square" icon="user" /></Badge>
</span> </span>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -28,8 +28,8 @@ ReactDOM.render(
<Avatar shape="square" icon="user" /> <Avatar shape="square" icon="user" />
<Avatar shape="square" size="small" icon="user" /> <Avatar shape="square" size="small" icon="user" />
</div> </div>
</div> </div>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -27,6 +27,7 @@ class Autoset extends React.Component {
color: colorList[0], color: colorList[0],
}; };
} }
changeUser = () => { changeUser = () => {
const index = UserList.indexOf(this.state.user); const index = UserList.indexOf(this.state.user);
this.setState({ this.setState({
@ -34,6 +35,7 @@ class Autoset extends React.Component {
color: index < colorList.length - 1 ? colorList[index + 1] : colorList[0], color: index < colorList.length - 1 ? colorList[index + 1] : colorList[0],
}); });
} }
render() { render() {
return ( return (
<div> <div>
@ -48,6 +50,6 @@ class Autoset extends React.Component {
} }
} }
ReactDOM.render(<Autoset /> ReactDOM.render(<Autoset />,
, mountNode); mountNode);
```` ````

View File

@ -24,8 +24,8 @@ ReactDOM.render(
<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" /> <Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
<Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf' }}>U</Avatar> <Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf' }}>U</Avatar>
<Avatar style={{ backgroundColor: '#87d068' }} icon="user" /> <Avatar style={{ backgroundColor: '#87d068' }} icon="user" />
</div> </div>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -24,8 +24,8 @@ ReactDOM.render(
<Badge count={0} showZero> <Badge count={0} showZero>
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div> </div>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -15,6 +15,7 @@ The count will be animated as it changes.
````jsx ````jsx
import { Badge, Button, Icon, Switch } from 'antd'; import { Badge, Button, Icon, Switch } from 'antd';
const ButtonGroup = Button.Group; const ButtonGroup = Button.Group;
class Demo extends React.Component { class Demo extends React.Component {

View File

@ -28,8 +28,8 @@ ReactDOM.render(
<Badge dot> <Badge dot>
<a href="#">Link something</a> <a href="#">Link something</a>
</Badge> </Badge>
</div> </div>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -21,6 +21,6 @@ ReactDOM.render(
<Badge count={5}> <Badge count={5}>
<span className="head-example" /> <span className="head-example" />
</Badge> </Badge>
</a> </a>,
, mountNode); mountNode);
```` ````

View File

@ -23,6 +23,6 @@ ReactDOM.render(
<Badge count={25} /> <Badge count={25} />
<Badge count={4} style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }} /> <Badge count={4} style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }} />
<Badge count={109} style={{ backgroundColor: '#52c41a' }} /> <Badge count={109} style={{ backgroundColor: '#52c41a' }} />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -30,6 +30,6 @@ ReactDOM.render(
<Badge count={1000} overflowCount={999}> <Badge count={1000} overflowCount={999}>
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -33,6 +33,6 @@ ReactDOM.render(
<Badge status="processing" text="Processing" /> <Badge status="processing" text="Processing" />
<br /> <br />
<Badge status="warning" text="Warning" /> <Badge status="warning" text="Warning" />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -21,8 +21,8 @@ ReactDOM.render(
<Badge count={5} title="Custom hover text"> <Badge count={5} title="Custom hover text">
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div> </div>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -22,6 +22,6 @@ ReactDOM.render(
<Breadcrumb.Item><a href="">Application Center</a></Breadcrumb.Item> <Breadcrumb.Item><a href="">Application Center</a></Breadcrumb.Item>
<Breadcrumb.Item><a href="">Application List</a></Breadcrumb.Item> <Breadcrumb.Item><a href="">Application List</a></Breadcrumb.Item>
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>,
, mountNode); mountNode);
```` ````

View File

@ -76,8 +76,8 @@ const Home = withRouter((props) => {
ReactDOM.render( ReactDOM.render(
<Router> <Router>
<Home /> <Home />
</Router> </Router>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -51,8 +51,8 @@ ReactDOM.render(
</Route> </Route>
</Route> </Route>
</Route> </Route>
</Router> </Router>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -22,6 +22,6 @@ ReactDOM.render(
<Breadcrumb.Item href="">Application Center</Breadcrumb.Item> <Breadcrumb.Item href="">Application Center</Breadcrumb.Item>
<Breadcrumb.Item href="">Application List</Breadcrumb.Item> <Breadcrumb.Item href="">Application List</Breadcrumb.Item>
<Breadcrumb.Item>An Application</Breadcrumb.Item> <Breadcrumb.Item>An Application</Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>,
, mountNode); mountNode);
```` ````

View File

@ -28,6 +28,6 @@ ReactDOM.render(
<Breadcrumb.Item> <Breadcrumb.Item>
Application Application
</Breadcrumb.Item> </Breadcrumb.Item>
</Breadcrumb> </Breadcrumb>,
, mountNode); mountNode);
```` ````

View File

@ -26,6 +26,6 @@ ReactDOM.render(
<Button>Default</Button> <Button>Default</Button>
<Button type="dashed">Dashed</Button> <Button type="dashed">Dashed</Button>
<Button type="danger">Danger</Button> <Button type="danger">Danger</Button>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -19,6 +19,7 @@ The `size` can be set to `large`, `small` or left unset resulting in a default s
````jsx ````jsx
import { Button, Icon } from 'antd'; import { Button, Icon } from 'antd';
const ButtonGroup = Button.Group; const ButtonGroup = Button.Group;
ReactDOM.render( ReactDOM.render(

View File

@ -22,6 +22,6 @@ ReactDOM.render(
<Button ghost>Default</Button> <Button ghost>Default</Button>
<Button type="dashed" ghost>Dashed</Button> <Button type="dashed" ghost>Dashed</Button>
<Button type="danger" ghost>danger</Button> <Button type="danger" ghost>danger</Button>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -21,6 +21,6 @@ function onPanelChange(value, mode) {
} }
ReactDOM.render( ReactDOM.render(
<Calendar onPanelChange={onPanelChange} /> <Calendar onPanelChange={onPanelChange} />,
, mountNode); mountNode);
```` ````

View File

@ -23,6 +23,6 @@ function onPanelChange(value, mode) {
ReactDOM.render( ReactDOM.render(
<div style={{ width: 300, border: '1px solid #d9d9d9', borderRadius: 4 }}> <div style={{ width: 300, border: '1px solid #d9d9d9', borderRadius: 4 }}>
<Calendar fullscreen={false} onPanelChange={onPanelChange} /> <Calendar fullscreen={false} onPanelChange={onPanelChange} />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -76,8 +76,8 @@ function monthCellRender(value) {
} }
ReactDOM.render( ReactDOM.render(
<Calendar dateCellRender={dateCellRender} monthCellRender={monthCellRender} /> <Calendar dateCellRender={dateCellRender} monthCellRender={monthCellRender} />,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -22,15 +22,18 @@ class App extends React.Component {
value: moment('2017-01-25'), value: moment('2017-01-25'),
selectedValue: moment('2017-01-25'), selectedValue: moment('2017-01-25'),
} }
onSelect = (value) => { onSelect = (value) => {
this.setState({ this.setState({
value, value,
selectedValue: value, selectedValue: value,
}); });
} }
onPanelChange = (value) => { onPanelChange = (value) => {
this.setState({ value }); this.setState({ value });
} }
render() { render() {
const { value, selectedValue } = this.state; const { value, selectedValue } = this.state;
return ( return (

View File

@ -21,8 +21,8 @@ ReactDOM.render(
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
</Card> </Card>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -23,6 +23,6 @@ ReactDOM.render(
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
</Card> </Card>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -16,6 +16,7 @@ You can use `Card.Meta` to support more flexible content.
````jsx ````jsx
import { Card } from 'antd'; import { Card } from 'antd';
const { Meta } = Card; const { Meta } = Card;
ReactDOM.render( ReactDOM.render(
@ -28,6 +29,6 @@ ReactDOM.render(
title="Europe Street beat" title="Europe Street beat"
description="www.instagram.com" description="www.instagram.com"
/> />
</Card> </Card>,
, mountNode); mountNode);
```` ````

View File

@ -30,6 +30,6 @@ ReactDOM.render(
<Card.Grid style={gridStyle}>Content</Card.Grid> <Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid> <Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid> <Card.Grid style={gridStyle}>Content</Card.Grid>
</Card> </Card>,
, mountNode); mountNode);
```` ````

View File

@ -29,6 +29,6 @@ ReactDOM.render(
<Card title="Card title" bordered={false}>Card content</Card> <Card title="Card title" bordered={false}>Card content</Card>
</Col> </Col>
</Row> </Row>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -43,6 +43,6 @@ ReactDOM.render(
> >
Inner Card content Inner Card content
</Card> </Card>
</Card> </Card>,
, mountNode); mountNode);
```` ````

View File

@ -38,6 +38,6 @@ class LoadingCard extends React.Component {
} }
ReactDOM.render( ReactDOM.render(
<LoadingCard /> <LoadingCard />,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ A Card that supports `cover`, `avatar`, `title` and `description`.
````jsx ````jsx
import { Card, Icon, Avatar } from 'antd'; import { Card, Icon, Avatar } from 'antd';
const { Meta } = Card; const { Meta } = Card;
ReactDOM.render( ReactDOM.render(
@ -28,6 +29,6 @@ ReactDOM.render(
title="Card title" title="Card title"
description="This is the description" description="This is the description"
/> />
</Card> </Card>,
, mountNode); mountNode);
```` ````

View File

@ -21,6 +21,6 @@ ReactDOM.render(
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
<p>Card content</p> <p>Card content</p>
</Card> </Card>,
, mountNode); mountNode);
```` ````

View File

@ -51,10 +51,12 @@ class TabsCard extends React.Component {
key: 'tab1', key: 'tab1',
noTitleKey: 'app', noTitleKey: 'app',
} }
onTabChange = (key, type) => { onTabChange = (key, type) => {
console.log(key, type); console.log(key, type);
this.setState({ [type]: key }); this.setState({ [type]: key });
} }
render() { render() {
return ( return (
<div> <div>
@ -82,6 +84,6 @@ class TabsCard extends React.Component {
} }
ReactDOM.render( ReactDOM.render(
<TabsCard /> <TabsCard />,
, mountNode); mountNode);
```` ````

View File

@ -22,8 +22,8 @@ ReactDOM.render(
<div><h3>2</h3></div> <div><h3>2</h3></div>
<div><h3>3</h3></div> <div><h3>3</h3></div>
<div><h3>4</h3></div> <div><h3>4</h3></div>
</Carousel> </Carousel>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -26,8 +26,8 @@ ReactDOM.render(
<div><h3>2</h3></div> <div><h3>2</h3></div>
<div><h3>3</h3></div> <div><h3>3</h3></div>
<div><h3>4</h3></div> <div><h3>4</h3></div>
</Carousel> </Carousel>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -22,8 +22,8 @@ ReactDOM.render(
<div><h3>2</h3></div> <div><h3>2</h3></div>
<div><h3>3</h3></div> <div><h3>3</h3></div>
<div><h3>4</h3></div> <div><h3>4</h3></div>
</Carousel> </Carousel>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -22,8 +22,8 @@ ReactDOM.render(
<div><h3>2</h3></div> <div><h3>2</h3></div>
<div><h3>3</h3></div> <div><h3>3</h3></div>
<div><h3>4</h3></div> <div><h3>4</h3></div>
</Carousel> </Carousel>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -45,6 +45,6 @@ function onChange(value) {
} }
ReactDOM.render( ReactDOM.render(
<Cascader options={options} onChange={onChange} placeholder="Please select" /> <Cascader options={options} onChange={onChange} placeholder="Please select" />,
, mountNode); mountNode);
```` ````

View File

@ -45,6 +45,6 @@ function onChange(value) {
} }
ReactDOM.render( ReactDOM.render(
<Cascader options={options} onChange={onChange} changeOnSelect /> <Cascader options={options} onChange={onChange} changeOnSelect />,
, mountNode); mountNode);
```` ````

View File

@ -65,6 +65,6 @@ ReactDOM.render(
defaultValue={['zhejiang', 'hangzhou', 'xihu']} defaultValue={['zhejiang', 'hangzhou', 'xihu']}
displayRender={displayRender} displayRender={displayRender}
style={{ width: '100%' }} style={{ width: '100%' }}
/> />,
, mountNode); mountNode);
```` ````

View File

@ -42,6 +42,7 @@ class CitySwitcher extends React.Component {
text: selectedOptions.map(o => o.label).join(', '), text: selectedOptions.map(o => o.label).join(', '),
}); });
} }
render() { render() {
return ( return (
<span> <span>

View File

@ -45,6 +45,6 @@ function onChange(value) {
} }
ReactDOM.render( ReactDOM.render(
<Cascader defaultValue={['zhejiang', 'hangzhou', 'xihu']} options={options} onChange={onChange} /> <Cascader defaultValue={['zhejiang', 'hangzhou', 'xihu']} options={options} onChange={onChange} />,
, mountNode); mountNode);
```` ````

View File

@ -46,6 +46,6 @@ function onChange(value) {
} }
ReactDOM.render( ReactDOM.render(
<Cascader options={options} onChange={onChange} /> <Cascader options={options} onChange={onChange} />,
, mountNode); mountNode);
```` ````

View File

@ -45,6 +45,6 @@ function onChange(value) {
} }
ReactDOM.render( ReactDOM.render(
<Cascader filedNames={{ label: 'name', value: 'code', children: 'items' }} options={options} onChange={onChange} placeholder="Please select" /> <Cascader filedNames={{ label: 'name', value: 'code', children: 'items' }} options={options} onChange={onChange} placeholder="Please select" />,
, mountNode); mountNode);
```` ````

View File

@ -55,6 +55,6 @@ ReactDOM.render(
expandTrigger="hover" expandTrigger="hover"
displayRender={displayRender} displayRender={displayRender}
onChange={onChange} onChange={onChange}
/> />,
, mountNode); mountNode);
```` ````

View File

@ -34,9 +34,11 @@ class LazyOptions extends React.Component {
state = { state = {
options, options,
}; };
onChange = (value, selectedOptions) => { onChange = (value, selectedOptions) => {
console.log(value, selectedOptions); console.log(value, selectedOptions);
} }
loadData = (selectedOptions) => { loadData = (selectedOptions) => {
const targetOption = selectedOptions[selectedOptions.length - 1]; const targetOption = selectedOptions[selectedOptions.length - 1];
targetOption.loading = true; targetOption.loading = true;
@ -56,6 +58,7 @@ class LazyOptions extends React.Component {
}); });
}, 1000); }, 1000);
} }
render() { render() {
return ( return (
<Cascader <Cascader

View File

@ -49,6 +49,6 @@ ReactDOM.render(
<Cascader size="large" options={options} onChange={onChange} /><br /><br /> <Cascader size="large" options={options} onChange={onChange} /><br /><br />
<Cascader options={options} onChange={onChange} /><br /><br /> <Cascader options={options} onChange={onChange} /><br /><br />
<Cascader size="small" options={options} onChange={onChange} /><br /><br /> <Cascader size="small" options={options} onChange={onChange} /><br /><br />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -21,6 +21,6 @@ function onChange(e) {
} }
ReactDOM.render( ReactDOM.render(
<Checkbox onChange={onChange}>Checkbox</Checkbox> <Checkbox onChange={onChange}>Checkbox</Checkbox>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ The `indeterminate` property can help you to achieve a 'check all' effect.
````jsx ````jsx
import { Checkbox } from 'antd'; import { Checkbox } from 'antd';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const plainOptions = ['Apple', 'Pear', 'Orange']; const plainOptions = ['Apple', 'Pear', 'Orange'];
@ -26,6 +27,7 @@ class App extends React.Component {
indeterminate: true, indeterminate: true,
checkAll: false, checkAll: false,
}; };
render() { render() {
return ( return (
<div> <div>
@ -43,6 +45,7 @@ class App extends React.Component {
</div> </div>
); );
} }
onChange = (checkedList) => { onChange = (checkedList) => {
this.setState({ this.setState({
checkedList, checkedList,
@ -50,6 +53,7 @@ class App extends React.Component {
checkAll: checkedList.length === plainOptions.length, checkAll: checkedList.length === plainOptions.length,
}); });
} }
onCheckAllChange = (e) => { onCheckAllChange = (e) => {
this.setState({ this.setState({
checkedList: e.target.checked ? plainOptions : [], checkedList: e.target.checked ? plainOptions : [],

View File

@ -21,6 +21,7 @@ class App extends React.Component {
checked: true, checked: true,
disabled: false, disabled: false,
}; };
render() { render() {
const label = `${this.state.checked ? 'Checked' : 'Unchecked'}-${this.state.disabled ? 'Disabled' : 'Enabled'}`; const label = `${this.state.checked ? 'Checked' : 'Unchecked'}-${this.state.disabled ? 'Disabled' : 'Enabled'}`;
return ( return (
@ -54,12 +55,15 @@ class App extends React.Component {
</div> </div>
); );
} }
toggleChecked = () => { toggleChecked = () => {
this.setState({ checked: !this.state.checked }); this.setState({ checked: !this.state.checked });
} }
toggleDisable = () => { toggleDisable = () => {
this.setState({ disabled: !this.state.disabled }); this.setState({ disabled: !this.state.disabled });
} }
onChange = (e) => { onChange = (e) => {
console.log('checked = ', e.target.checked); console.log('checked = ', e.target.checked);
this.setState({ this.setState({

View File

@ -21,6 +21,6 @@ ReactDOM.render(
<Checkbox defaultChecked={false} disabled /> <Checkbox defaultChecked={false} disabled />
<br /> <br />
<Checkbox defaultChecked disabled /> <Checkbox defaultChecked disabled />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Generate a group of checkboxes from an array.
````jsx ````jsx
import { Checkbox } from 'antd'; import { Checkbox } from 'antd';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
function onChange(checkedValues) { function onChange(checkedValues) {
@ -40,6 +41,6 @@ ReactDOM.render(
<CheckboxGroup options={options} defaultValue={['Pear']} onChange={onChange} /> <CheckboxGroup options={options} defaultValue={['Pear']} onChange={onChange} />
<br /><br /> <br /><br />
<CheckboxGroup options={optionsWithDisabled} disabled defaultValue={['Apple']} onChange={onChange} /> <CheckboxGroup options={optionsWithDisabled} disabled defaultValue={['Apple']} onChange={onChange} />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Accordion mode, only one panel can be expanded at a time. The first panel will b
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
const text = ` const text = `
@ -34,6 +35,6 @@ ReactDOM.render(
<Panel header="This is panel header 3" key="3"> <Panel header="This is panel header 3" key="3">
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ More than one panel can be expanded at a time, the first panel is initialized to
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
function callback(key) { function callback(key) {
@ -38,8 +39,8 @@ ReactDOM.render(
<Panel header="This is panel header 3" key="3" disabled> <Panel header="This is panel header 3" key="3" disabled>
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````
<style> <style>

View File

@ -15,6 +15,7 @@ A borderless style of Collapse.
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
const text = ( const text = (
@ -36,6 +37,6 @@ ReactDOM.render(
<Panel header="This is panel header 3" key="3"> <Panel header="This is panel header 3" key="3">
{text} {text}
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Customize the background, border and margin styles for each panel.
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
const text = ` const text = `
@ -42,6 +43,6 @@ ReactDOM.render(
<Panel header="This is panel header 3" key="3" style={customPanelStyle}> <Panel header="This is panel header 3" key="3" style={customPanelStyle}>
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ title:
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
function callback(key) { function callback(key) {
@ -42,6 +43,6 @@ ReactDOM.render(
<Panel header="This is panel header 3" key="3"> <Panel header="This is panel header 3" key="3">
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ You can disable showing arrow icon by passing `showArrow={false}` to `CollapsePa
````jsx ````jsx
import { Collapse } from 'antd'; import { Collapse } from 'antd';
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
function callback(key) { function callback(key) {
@ -35,6 +36,6 @@ ReactDOM.render(
<Panel showArrow={false} header="This is panel header with no arrow icon" key="2"> <Panel showArrow={false} header="This is panel header with no arrow icon" key="2">
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse> </Collapse>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Basic use case. Users can select or input a date in panel.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { MonthPicker, RangePicker, WeekPicker } = DatePicker; const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
function onChange(date, dateString) { function onChange(date, dateString) {
@ -30,6 +31,6 @@ ReactDOM.render(
<RangePicker onChange={onChange} /> <RangePicker onChange={onChange} />
<br /> <br />
<WeekPicker onChange={onChange} placeholder="Select week" /> <WeekPicker onChange={onChange} placeholder="Select week" />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ We can customize the rendering of date cells in the calendar by providing a `dat
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
ReactDOM.render( ReactDOM.render(
@ -47,6 +48,6 @@ ReactDOM.render(
); );
}} }}
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -16,6 +16,7 @@ Disabled part of dates and time by `disabledDate` and `disabledTime` respectivel
````jsx ````jsx
import moment from 'moment'; import moment from 'moment';
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { MonthPicker, RangePicker } = DatePicker; const { MonthPicker, RangePicker } = DatePicker;
function range(start, end) { function range(start, end) {

View File

@ -16,6 +16,7 @@ A disabled state of the `DatePicker`.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
const { MonthPicker, RangePicker } = DatePicker; const { MonthPicker, RangePicker } = DatePicker;
const dateFormat = 'YYYY-MM-DD'; const dateFormat = 'YYYY-MM-DD';
@ -29,6 +30,6 @@ ReactDOM.render(
defaultValue={[moment('2015-06-06', dateFormat), moment('2015-06-06', dateFormat)]} defaultValue={[moment('2015-06-06', dateFormat), moment('2015-06-06', dateFormat)]}
disabled disabled
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Render extra footer in panel for customized requirements.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { RangePicker, MonthPicker } = DatePicker; const { RangePicker, MonthPicker } = DatePicker;
ReactDOM.render( ReactDOM.render(
@ -24,6 +25,6 @@ ReactDOM.render(
<RangePicker renderExtraFooter={() => 'extra footer'} /> <RangePicker renderExtraFooter={() => 'extra footer'} />
<RangePicker renderExtraFooter={() => 'extra footer'} showTime /> <RangePicker renderExtraFooter={() => 'extra footer'} showTime />
<MonthPicker renderExtraFooter={() => 'extra footer'} placeholder="Select month" /> <MonthPicker renderExtraFooter={() => 'extra footer'} placeholder="Select month" />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -16,6 +16,7 @@ We can set the date format by `format`.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
const { MonthPicker, RangePicker } = DatePicker; const { MonthPicker, RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD'; const dateFormat = 'YYYY/MM/DD';
@ -30,6 +31,6 @@ ReactDOM.render(
defaultValue={[moment('2015/01/01', dateFormat), moment('2015/01/01', dateFormat)]} defaultValue={[moment('2015/01/01', dateFormat), moment('2015/01/01', dateFormat)]}
format={dateFormat} format={dateFormat}
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ Determing which panel to show with `mode` and `onPanelChange`.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
class ControlledDatePicker extends React.Component { class ControlledDatePicker extends React.Component {
@ -77,6 +78,6 @@ ReactDOM.render(
<ControlledDatePicker /> <ControlledDatePicker />
<br /> <br />
<ControlledRangePicker /> <ControlledRangePicker />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -16,6 +16,7 @@ We can set presetted ranges to RangePicker to improve user experience.
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
const RangePicker = DatePicker.RangePicker; const RangePicker = DatePicker.RangePicker;
function onChange(dates, dateStrings) { function onChange(dates, dateStrings) {

View File

@ -16,6 +16,7 @@ The input box comes in three sizes. `default` will be used if `size` is omitted.
````jsx ````jsx
import { DatePicker, Radio } from 'antd'; import { DatePicker, Radio } from 'antd';
const { MonthPicker, RangePicker, WeekPicker } = DatePicker; const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
class PickerSizesDemo extends React.Component { class PickerSizesDemo extends React.Component {

View File

@ -15,6 +15,7 @@ This property provide an additional time selection. When `showTime` is an Object
````jsx ````jsx
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
function onChange(value, dateString) { function onChange(value, dateString) {
@ -43,6 +44,6 @@ ReactDOM.render(
onChange={onChange} onChange={onChange}
onOk={onOk} onOk={onOk}
/> />
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -25,6 +25,6 @@ ReactDOM.render(
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
<Divider dashed /> <Divider dashed />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -22,6 +22,6 @@ ReactDOM.render(
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
<Divider orientation="right">Right Text</Divider> <Divider orientation="right">Right Text</Divider>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -23,6 +23,6 @@ ReactDOM.render(
<a href="#">Link</a> <a href="#">Link</a>
<Divider type="vertical" /> <Divider type="vertical" />
<a href="#">Link</a> <a href="#">Link</a>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -35,6 +35,6 @@ ReactDOM.render(
<a className="ant-dropdown-link" href="#"> <a className="ant-dropdown-link" href="#">
Hover me <Icon type="down" /> Hover me <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -27,6 +27,6 @@ const menu = (
ReactDOM.render( ReactDOM.render(
<Dropdown overlay={menu} trigger={['contextMenu']}> <Dropdown overlay={menu} trigger={['contextMenu']}>
<span style={{ userSelect: 'none' }}>Right Click on Me</span> <span style={{ userSelect: 'none' }}>Right Click on Me</span>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -52,6 +52,6 @@ ReactDOM.render(
Button <Icon type="down" /> Button <Icon type="down" />
</Button> </Button>
</Dropdown> </Dropdown>
</div> </div>,
, mountNode); mountNode);
```` ````

View File

@ -15,6 +15,7 @@ An event will be triggered when you click menu items, in which you can make diff
````jsx ````jsx
import { Menu, Dropdown, Icon, message } from 'antd'; import { Menu, Dropdown, Icon, message } from 'antd';
const onClick = function ({ key }) { const onClick = function ({ key }) {
message.info(`Click on item ${key}`); message.info(`Click on item ${key}`);
}; };
@ -32,6 +33,6 @@ ReactDOM.render(
<a className="ant-dropdown-link" href="#"> <a className="ant-dropdown-link" href="#">
Hover me, Click menu item <Icon type="down" /> Hover me, Click menu item <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -34,6 +34,6 @@ ReactDOM.render(
<a className="ant-dropdown-link" href="#"> <a className="ant-dropdown-link" href="#">
Hover me <Icon type="down" /> Hover me <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -20,14 +20,17 @@ class OverlayVisible extends React.Component {
state = { state = {
visible: false, visible: false,
}; };
handleMenuClick = (e) => { handleMenuClick = (e) => {
if (e.key === '3') { if (e.key === '3') {
this.setState({ visible: false }); this.setState({ visible: false });
} }
} }
handleVisibleChange = (flag) => { handleVisibleChange = (flag) => {
this.setState({ visible: flag }); this.setState({ visible: flag });
} }
render() { render() {
const menu = ( const menu = (
<Menu onClick={this.handleMenuClick}> <Menu onClick={this.handleMenuClick}>

View File

@ -51,8 +51,8 @@ ReactDOM.render(
<Dropdown overlay={menu} placement="topRight"> <Dropdown overlay={menu} placement="topRight">
<Button>topRight</Button> <Button>topRight</Button>
</Dropdown> </Dropdown>
</div> </div>,
, mountNode); mountNode);
```` ````
````css ````css

View File

@ -15,6 +15,7 @@ The menu has multiple levels.
````jsx ````jsx
import { Menu, Dropdown, Icon } from 'antd'; import { Menu, Dropdown, Icon } from 'antd';
const SubMenu = Menu.SubMenu; const SubMenu = Menu.SubMenu;
const menu = ( const menu = (
@ -37,6 +38,6 @@ ReactDOM.render(
<a className="ant-dropdown-link" href="#"> <a className="ant-dropdown-link" href="#">
Cascading menu <Icon type="down" /> Cascading menu <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -34,6 +34,6 @@ ReactDOM.render(
<a className="ant-dropdown-link" href="#"> <a className="ant-dropdown-link" href="#">
Click me <Icon type="down" /> Click me <Icon type="down" />
</a> </a>
</Dropdown> </Dropdown>,
, mountNode); mountNode);
```` ````

View File

@ -20,6 +20,7 @@ Because the width of label is not fixed, you may need to adjust it by customizin
````jsx ````jsx
import { Form, Row, Col, Input, Button, Icon } from 'antd'; import { Form, Row, Col, Input, Button, Icon } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
class AdvancedSearchForm extends React.Component { class AdvancedSearchForm extends React.Component {

View File

@ -15,6 +15,7 @@ Use `setFieldsValue` to set other control's value programmaticly.
````jsx ````jsx
import { Form, Select, Input, Button } from 'antd'; import { Form, Select, Input, Button } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
const Option = Select.Option; const Option = Select.Option;
@ -27,12 +28,14 @@ class App extends React.Component {
} }
}); });
} }
handleSelectChange = (value) => { handleSelectChange = (value) => {
console.log(value); console.log(value);
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`, note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`,
}); });
} }
render() { render() {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
return ( return (

View File

@ -21,6 +21,7 @@ Customized or third-party form controls can be used in Form, too. Controls must
````jsx ````jsx
import { Form, Input, Select, Button } from 'antd'; import { Form, Input, Select, Button } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
const Option = Select.Option; const Option = Select.Option;
@ -34,6 +35,7 @@ class PriceInput extends React.Component {
currency: value.currency || 'rmb', currency: value.currency || 'rmb',
}; };
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps) {
@ -41,6 +43,7 @@ class PriceInput extends React.Component {
this.setState(value); this.setState(value);
} }
} }
handleNumberChange = (e) => { handleNumberChange = (e) => {
const number = parseInt(e.target.value || 0, 10); const number = parseInt(e.target.value || 0, 10);
if (isNaN(number)) { if (isNaN(number)) {
@ -51,12 +54,14 @@ class PriceInput extends React.Component {
} }
this.triggerChange({ number }); this.triggerChange({ number });
} }
handleCurrencyChange = (currency) => { handleCurrencyChange = (currency) => {
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ currency }); this.setState({ currency });
} }
this.triggerChange({ currency }); this.triggerChange({ currency });
} }
triggerChange = (changedValue) => { triggerChange = (changedValue) => {
// Should provide an event to pass value to Form. // Should provide an event to pass value to Form.
const onChange = this.props.onChange; const onChange = this.props.onChange;
@ -64,6 +69,7 @@ class PriceInput extends React.Component {
onChange(Object.assign({}, this.state, changedValue)); onChange(Object.assign({}, this.state, changedValue));
} }
} }
render() { render() {
const { size } = this.props; const { size } = this.props;
const state = this.state; const state = this.state;
@ -99,6 +105,7 @@ class Demo extends React.Component {
} }
}); });
} }
checkPrice = (rule, value, callback) => { checkPrice = (rule, value, callback) => {
if (value.number > 0) { if (value.number > 0) {
callback(); callback();
@ -106,6 +113,7 @@ class Demo extends React.Component {
} }
callback('Price must greater than zero!'); callback('Price must greater than zero!');
} }
render() { render() {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
return ( return (

View File

@ -15,6 +15,7 @@ Add or remove form items dynamically.
````jsx ````jsx
import { Form, Input, Icon, Button } from 'antd'; import { Form, Input, Icon, Button } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
let uuid = 0; let uuid = 0;

Some files were not shown because too many files have changed in this diff Show More