💄 fix eslint problems

This commit is contained in:
afc163 2018-11-28 15:00:03 +08:00
parent 647ba193cd
commit 83c192ea3e
No known key found for this signature in database
GPG Key ID: 738F973FCE5C6B48
313 changed files with 1122 additions and 730 deletions

View File

@ -14,33 +14,18 @@ const eslintrc = {
'babel', 'babel',
], ],
rules: { rules: {
'func-names': 0,
'arrow-body-style': 0,
'react/sort-comp': 0,
'react/prop-types': 0,
'react/jsx-first-prop-new-line': 0,
'react/jsx-one-expression-per-line': 0, 'react/jsx-one-expression-per-line': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0, 'react/forbid-prop-types': 0,
'import/no-extraneous-dependencies': ['error', {
devDependencies: ['site/**', 'tests/**', 'scripts/**', '**/*.test.js', '**/__tests__/*', '*.config.js', '**/*.md'],
}],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.md'] }], 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.md'] }],
'import/extensions': 0,
'import/no-unresolved': 0,
'import/no-extraneous-dependencies': 0,
'prefer-destructuring': 0,
'no-param-reassign': 0,
'no-return-assign': 0,
'max-len': 0,
'consistent-return': 0,
'no-redeclare': 0,
'react/require-extension': 0,
'jsx-a11y/no-static-element-interactions': 0, 'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/anchor-has-content': 0, 'jsx-a11y/anchor-has-content': 0,
'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0, 'jsx-a11y/anchor-is-valid': 0,
'react/no-danger': 0,
'comma-dangle': ['error', 'always-multiline'], 'comma-dangle': ['error', 'always-multiline'],
'function-paren-newline': 0,
'object-curly-newline': 0,
'no-restricted-globals': 0,
}, },
}; };
@ -61,9 +46,13 @@ if (process.env.RUN_ENV === 'DEMO') {
'react/no-access-state-in-setstate': 0, 'react/no-access-state-in-setstate': 0,
'react/destructuring-assignment': 0, 'react/destructuring-assignment': 0,
'react/no-multi-comp': 0, 'react/no-multi-comp': 0,
'react/prefer-stateless-function': 0,
'jsx-a11y/href-no-hash': 0, 'jsx-a11y/href-no-hash': 0,
'import/newline-after-import': 0, 'prefer-destructuring': 0, // TODO: remove later
'max-len': 0, // TODO: remove later
'consistent-return': 0, // TODO: remove later
'no-return-assign': 0, // TODO: remove later
'no-param-reassign': 0, // TODO: remove later
'import/no-extraneous-dependencies': 0,
}); });
} }

View File

@ -12,9 +12,7 @@ class AffixMounter extends React.Component {
}); });
} }
getTarget = () => { getTarget = () => this.container
return this.container;
}
render() { render() {
return ( return (
@ -34,7 +32,7 @@ class AffixMounter extends React.Component {
> >
<Affix <Affix
target={() => this.container} target={() => this.container}
ref={ele => this.affix = ele} ref={(ele) => { this.affix = ele; }}
{...this.props} {...this.props}
> >
<Button type="primary"> <Button type="primary">
@ -59,11 +57,9 @@ describe('Affix Render', () => {
}); });
const scrollTo = (top) => { const scrollTo = (top) => {
wrapper.instance().affix.fixedNode.parentNode.getBoundingClientRect = jest.fn(() => { wrapper.instance().affix.fixedNode.parentNode.getBoundingClientRect = jest.fn(() => ({
return { bottom: 100, height: 28, left: 0, right: 0, top: 50 - top, width: 195,
bottom: 100, height: 28, left: 0, right: 0, top: 50 - top, width: 195, }));
};
});
wrapper.instance().container.scrollTop = top; wrapper.instance().container.scrollTop = top;
events.scroll({ events.scroll({
type: 'scroll', type: 'scroll',

View File

@ -27,5 +27,6 @@ ReactDOM.render(
<br /> <br />
<Alert type="error" message="Error text" banner /> <Alert type="error" message="Error text" banner />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -18,7 +18,8 @@ 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

@ -16,7 +16,7 @@ To show close button.
````jsx ````jsx
import { Alert } from 'antd'; import { Alert } from 'antd';
const onClose = function (e) { const onClose = (e) => {
console.log(e, 'I was closed.'); console.log(e, 'I was closed.');
}; };
@ -36,5 +36,6 @@ ReactDOM.render(
onClose={onClose} onClose={onClose}
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -18,5 +18,6 @@ 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

@ -55,5 +55,6 @@ ReactDOM.render(
showIcon showIcon
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

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

View File

@ -47,5 +47,6 @@ ReactDOM.render(
showIcon showIcon
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -46,5 +46,6 @@ class App extends React.Component {
ReactDOM.render( ReactDOM.render(
<App />, <App />,
mountNode); mountNode
);
```` ````

View File

@ -23,5 +23,6 @@ ReactDOM.render(
<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

@ -92,7 +92,7 @@ describe('Anchor Render', () => {
let anchorInstance = null; let anchorInstance = null;
function AnchorUpdate({ href }) { function AnchorUpdate({ href }) {
return ( return (
<Anchor ref={c => anchorInstance = c}> <Anchor ref={(c) => { anchorInstance = c; }}>
<Link href={href} title="API" /> <Link href={href} title="API" />
</Anchor> </Anchor>
); );
@ -107,7 +107,7 @@ describe('Anchor Render', () => {
it('Anchor onClick event', () => { it('Anchor onClick event', () => {
let event; let event;
let link; let link;
const handleClick = (...arg) => ([event, link] = arg); const handleClick = (...arg) => { [event, link] = arg; };
const href = '#API'; const href = '#API';
const title = 'API'; const title = 'API';

View File

@ -27,7 +27,8 @@ ReactDOM.render(
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>,
mountNode); mountNode
);
``` ```
<style> <style>

View File

@ -32,5 +32,6 @@ ReactDOM.render(
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>,
mountNode); mountNode
);
``` ```

View File

@ -27,5 +27,6 @@ ReactDOM.render(
<Link href="#Link-Props" title="Link Props" /> <Link href="#Link-Props" title="Link Props" />
</Link> </Link>
</Anchor>, </Anchor>,
mountNode); mountNode
);
``` ```

View File

@ -35,9 +35,7 @@ class Complete extends React.Component {
render() { render() {
const { result } = this.state; const { result } = this.state;
const children = result.map((email) => { const children = result.map(email => <Option key={email}>{email}</Option>);
return <Option key={email}>{email}</Option>;
});
return ( return (
<AutoComplete <AutoComplete
style={{ width: 200 }} style={{ width: 200 }}

View File

@ -15,7 +15,9 @@ Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/s
Basic Usage, set datasource of autocomplete with `dataSource` property. 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;

View File

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

View File

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

View File

@ -25,7 +25,8 @@ ReactDOM.render(
<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

@ -25,7 +25,8 @@ ReactDOM.render(
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div>, </div>,
mountNode); mountNode
);
```` ````
<style> <style>

View File

@ -14,7 +14,9 @@ title:
The count will be animated as it changes. 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;

View File

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

View File

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

View File

@ -24,7 +24,8 @@ ReactDOM.render(
<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
);
```` ````
<style> <style>

View File

@ -31,5 +31,6 @@ ReactDOM.render(
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

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

View File

@ -22,7 +22,8 @@ ReactDOM.render(
<a href="#" className="head-example" /> <a href="#" className="head-example" />
</Badge> </Badge>
</div>, </div>,
mountNode); mountNode
);
```` ````
<style> <style>

View File

@ -1,5 +1,7 @@
import React from 'react'; import React from 'react';
import { Route, Switch, Link, withRouter, MemoryRouter } from 'react-router-dom'; import {
Route, Switch, Link, withRouter, MemoryRouter,
} from 'react-router-dom';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import Breadcrumb from '../index'; import Breadcrumb from '../index';

View File

@ -23,5 +23,6 @@ ReactDOM.render(
<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

@ -16,7 +16,9 @@ title:
Used together with `react-router@4` or other router. Used together with `react-router@4` or other router.
````jsx ````jsx
import { HashRouter as Router, Route, Switch, Link, withRouter } from 'react-router-dom'; import {
HashRouter as Router, Route, Switch, Link, withRouter,
} from 'react-router-dom';
import { Breadcrumb, Alert } from 'antd'; import { Breadcrumb, Alert } from 'antd';
const Apps = () => ( const Apps = () => (
@ -77,7 +79,8 @@ ReactDOM.render(
<Router> <Router>
<Home /> <Home />
</Router>, </Router>,
mountNode); mountNode
);
```` ````
````css ````css

View File

@ -16,7 +16,9 @@ title:
Used together with `react-router@2` `react-router@3`. Used together with `react-router@2` `react-router@3`.
````jsx ````jsx
import { Router, Route, Link, hashHistory } from 'react-router'; import {
Router, Route, Link, hashHistory,
} from 'react-router';
import { Breadcrumb, Alert } from 'antd'; import { Breadcrumb, Alert } from 'antd';
const Apps = () => ( const Apps = () => (
@ -52,7 +54,8 @@ ReactDOM.render(
</Route> </Route>
</Route> </Route>
</Router>, </Router>,
mountNode); mountNode
);
```` ````
````css ````css

View File

@ -23,5 +23,6 @@ ReactDOM.render(
<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

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

View File

@ -23,5 +23,6 @@ ReactDOM.render(
<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

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

View File

@ -23,5 +23,6 @@ ReactDOM.render(
<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

@ -15,7 +15,9 @@ If you need several buttons, we recommend that you use 1 primary button + n seco
````jsx ````jsx
import { Button, Menu, Dropdown, Icon } from 'antd'; import {
Button, Menu, Dropdown, Icon,
} from 'antd';
function handleMenuClick(e) { function handleMenuClick(e) {
console.log('click', e); console.log('click', e);

View File

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

View File

@ -24,5 +24,6 @@ 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

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

View File

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

View File

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

View File

@ -30,5 +30,6 @@ ReactDOM.render(
description="www.instagram.com" description="www.instagram.com"
/> />
</Card>, </Card>,
mountNode); mountNode
);
```` ````

View File

@ -31,5 +31,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>, </Card>,
mountNode); mountNode
);
```` ````

View File

@ -30,5 +30,6 @@ ReactDOM.render(
</Col> </Col>
</Row> </Row>
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

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

View File

@ -14,7 +14,9 @@ title:
Shows a loading indicator while the contents of the card is being fetched. Shows a loading indicator while the contents of the card is being fetched.
````jsx ````jsx
import { Skeleton, Switch, Card, Icon, Avatar } from 'antd'; import {
Skeleton, Switch, Card, Icon, Avatar,
} from 'antd';
const { Meta } = Card; const { Meta } = Card;

View File

@ -30,5 +30,6 @@ ReactDOM.render(
description="This is the description" description="This is the description"
/> />
</Card>, </Card>,
mountNode); mountNode
);
```` ````

View File

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

View File

@ -49,7 +49,7 @@ describe('Carousel', () => {
it('cancel resize listener when unmount', async () => { it('cancel resize listener when unmount', async () => {
const wrapper = mount(<Carousel autoplay><div>1</div><div>2</div><div>3</div></Carousel>); const wrapper = mount(<Carousel autoplay><div>1</div><div>2</div><div>3</div></Carousel>);
const onWindowResized = wrapper.instance().onWindowResized; const { onWindowResized } = wrapper.instance();
const spy = jest.spyOn(wrapper.instance().onWindowResized, 'cancel'); const spy = jest.spyOn(wrapper.instance().onWindowResized, 'cancel');
const spy2 = jest.spyOn(window, 'removeEventListener'); const spy2 = jest.spyOn(window, 'removeEventListener');
wrapper.unmount(); wrapper.unmount();

View File

@ -23,7 +23,8 @@ ReactDOM.render(
<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

@ -27,7 +27,8 @@ ReactDOM.render(
<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

@ -23,7 +23,8 @@ ReactDOM.render(
<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

@ -23,7 +23,8 @@ ReactDOM.render(
<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

@ -46,5 +46,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

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

View File

@ -66,5 +66,6 @@ ReactDOM.render(
displayRender={displayRender} displayRender={displayRender}
style={{ width: '100%' }} style={{ width: '100%' }}
/>, />,
mountNode); mountNode
);
```` ````

View File

@ -46,5 +46,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

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

View File

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

View File

@ -56,5 +56,6 @@ ReactDOM.render(
displayRender={displayRender} displayRender={displayRender}
onChange={onChange} onChange={onChange}
/>, />,
mountNode); mountNode
);
```` ````

View File

@ -50,5 +50,6 @@ ReactDOM.render(
<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

@ -61,5 +61,6 @@ ReactDOM.render(
placeholder="Please select" placeholder="Please select"
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

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

View File

@ -28,6 +28,22 @@ class App extends React.Component {
checkAll: false, checkAll: false,
}; };
onChange = (checkedList) => {
this.setState({
checkedList,
indeterminate: !!checkedList.length && (checkedList.length < plainOptions.length),
checkAll: checkedList.length === plainOptions.length,
});
}
onCheckAllChange = (e) => {
this.setState({
checkedList: e.target.checked ? plainOptions : [],
indeterminate: false,
checkAll: e.target.checked,
});
}
render() { render() {
return ( return (
<div> <div>
@ -45,22 +61,6 @@ class App extends React.Component {
</div> </div>
); );
} }
onChange = (checkedList) => {
this.setState({
checkedList,
indeterminate: !!checkedList.length && (checkedList.length < plainOptions.length),
checkAll: checkedList.length === plainOptions.length,
});
}
onCheckAllChange = (e) => {
this.setState({
checkedList: e.target.checked ? plainOptions : [],
indeterminate: false,
checkAll: e.target.checked,
});
}
} }
ReactDOM.render(<App />, mountNode); ReactDOM.render(<App />, mountNode);

View File

@ -22,6 +22,21 @@ class App extends React.Component {
disabled: false, disabled: false,
}; };
toggleChecked = () => {
this.setState({ checked: !this.state.checked });
}
toggleDisable = () => {
this.setState({ disabled: !this.state.disabled });
}
onChange = (e) => {
console.log('checked = ', e.target.checked);
this.setState({
checked: e.target.checked,
});
}
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 (
@ -55,21 +70,6 @@ class App extends React.Component {
</div> </div>
); );
} }
toggleChecked = () => {
this.setState({ checked: !this.state.checked });
}
toggleDisable = () => {
this.setState({ disabled: !this.state.disabled });
}
onChange = (e) => {
console.log('checked = ', e.target.checked);
this.setState({
checked: e.target.checked,
});
}
} }
ReactDOM.render(<App />, mountNode); ReactDOM.render(<App />, mountNode);

View File

@ -22,5 +22,6 @@ ReactDOM.render(
<br /> <br />
<Checkbox defaultChecked disabled /> <Checkbox defaultChecked disabled />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -42,5 +42,6 @@ ReactDOM.render(
<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

@ -36,5 +36,6 @@ ReactDOM.render(
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````

View File

@ -40,7 +40,8 @@ ReactDOM.render(
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````
<style> <style>

View File

@ -38,5 +38,6 @@ ReactDOM.render(
{text} {text}
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````

View File

@ -44,5 +44,6 @@ ReactDOM.render(
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````

View File

@ -44,5 +44,6 @@ ReactDOM.render(
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````

View File

@ -37,5 +37,6 @@ ReactDOM.render(
<p>{text}</p> <p>{text}</p>
</Panel> </Panel>
</Collapse>, </Collapse>,
mountNode); mountNode
);
```` ````

View File

@ -80,16 +80,17 @@ describe('DatePicker', () => {
onChange = (value) => { onChange = (value) => {
let { cleared } = this.state; let { cleared } = this.state;
let newValue = value;
if (cleared) { if (cleared) {
value = moment(moment(value).format('YYYY-MM-DD 12:12:12')); newValue = moment(moment(value).format('YYYY-MM-DD 12:12:12'));
cleared = false; cleared = false;
} }
if (!value) { if (!newValue) {
cleared = true; cleared = true;
} }
this.setState({ value, cleared }); this.setState({ value: newValue, cleared });
} }
render() { render() {

View File

@ -83,7 +83,13 @@ describe('RangePicker with showTime', () => {
const onChangeFn = jest.fn(); const onChangeFn = jest.fn();
const onOpenChangeFn = jest.fn(); const onOpenChangeFn = jest.fn();
const wrapper = mount( const wrapper = mount(
<RangePicker showTime open onOk={onOkFn} onChange={onChangeFn} onOpenChange={onOpenChangeFn} /> <RangePicker
showTime
open
onOk={onOkFn}
onChange={onChangeFn}
onOpenChange={onOpenChangeFn}
/>
); );
const calendarWrapper = mount(wrapper.find('Trigger').instance().getComponent()); const calendarWrapper = mount(wrapper.find('Trigger').instance().getComponent());

View File

@ -32,5 +32,6 @@ ReactDOM.render(
<br /> <br />
<WeekPicker onChange={onChange} placeholder="Select week" /> <WeekPicker onChange={onChange} placeholder="Select week" />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -49,5 +49,6 @@ ReactDOM.render(
}} }}
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -31,5 +31,6 @@ ReactDOM.render(
disabled disabled
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -26,5 +26,6 @@ ReactDOM.render(
<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

@ -32,5 +32,6 @@ ReactDOM.render(
format={dateFormat} format={dateFormat}
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -79,5 +79,6 @@ ReactDOM.render(
<br /> <br />
<ControlledRangePicker /> <ControlledRangePicker />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -42,5 +42,6 @@ ReactDOM.render(
<br /> <br />
<WeekPicker suffixIcon="ab" onChange={onChange} placeholder="Select week" /> <WeekPicker suffixIcon="ab" onChange={onChange} placeholder="Select week" />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -45,5 +45,6 @@ ReactDOM.render(
onOk={onOk} onOk={onOk}
/> />
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -26,5 +26,6 @@ ReactDOM.render(
<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

@ -23,5 +23,6 @@ ReactDOM.render(
<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

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

View File

@ -14,7 +14,9 @@ title:
A drawer containing an editable form which needs to be collapsed by clicking the close button. A drawer containing an editable form which needs to be collapsed by clicking the close button.
```jsx ```jsx
import { Drawer, Form, Button, Col, Row, Input, Select, DatePicker } from 'antd'; import {
Drawer, Form, Button, Col, Row, Input, Select, DatePicker,
} from 'antd';
const { Option } = Select; const { Option } = Select;

View File

@ -14,7 +14,9 @@ title:
Use when you need to quickly preview the outline of the object. Such as list item preview. Use when you need to quickly preview the outline of the object. Such as list item preview.
```jsx ```jsx
import { Drawer, List, Avatar, Divider, Col, Row } from 'antd'; import {
Drawer, List, Avatar, Divider, Col, Row,
} from 'antd';
const pStyle = { const pStyle = {
fontSize: 16, fontSize: 16,

View File

@ -36,5 +36,6 @@ ReactDOM.render(
Hover me <Icon type="down" /> Hover me <Icon type="down" />
</a> </a>
</Dropdown>, </Dropdown>,
mountNode); mountNode
);
```` ````

View File

@ -28,5 +28,6 @@ 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

@ -14,7 +14,9 @@ title:
A button is on the left, and a related functional menu is on the right. A button is on the left, and a related functional menu is on the right.
````jsx ````jsx
import { Menu, Dropdown, Button, Icon, message } from 'antd'; import {
Menu, Dropdown, Button, Icon, message,
} from 'antd';
function handleButtonClick(e) { function handleButtonClick(e) {
message.info('Click on left button.'); message.info('Click on left button.');
@ -53,5 +55,6 @@ ReactDOM.render(
</Button> </Button>
</Dropdown> </Dropdown>
</div>, </div>,
mountNode); mountNode
);
```` ````

View File

@ -14,9 +14,11 @@ title:
An event will be triggered when you click menu items, in which you can make different operations according to item's key. An event will be triggered when you click menu items, in which you can make different operations according to item's key.
````jsx ````jsx
import { Menu, Dropdown, Icon, message } from 'antd'; import {
Menu, Dropdown, Icon, message,
} from 'antd';
const onClick = function ({ key }) { const onClick = ({ key }) => {
message.info(`Click on item ${key}`); message.info(`Click on item ${key}`);
}; };
@ -34,5 +36,6 @@ ReactDOM.render(
Hover me, Click menu item <Icon type="down" /> Hover me, Click menu item <Icon type="down" />
</a> </a>
</Dropdown>, </Dropdown>,
mountNode); mountNode
);
```` ````

View File

@ -35,5 +35,6 @@ ReactDOM.render(
Hover me <Icon type="down" /> Hover me <Icon type="down" />
</a> </a>
</Dropdown>, </Dropdown>,
mountNode); mountNode
);
```` ````

View File

@ -40,7 +40,8 @@ class OverlayVisible extends React.Component {
</Menu> </Menu>
); );
return ( return (
<Dropdown overlay={menu} <Dropdown
overlay={menu}
onVisibleChange={this.handleVisibleChange} onVisibleChange={this.handleVisibleChange}
visible={this.state.visible} visible={this.state.visible}
> >

View File

@ -52,7 +52,8 @@ ReactDOM.render(
<Button>topRight</Button> <Button>topRight</Button>
</Dropdown> </Dropdown>
</div>, </div>,
mountNode); mountNode
);
```` ````
````css ````css

View File

@ -39,5 +39,6 @@ ReactDOM.render(
Cascading menu <Icon type="down" /> Cascading menu <Icon type="down" />
</a> </a>
</Dropdown>, </Dropdown>,
mountNode); mountNode
);
```` ````

View File

@ -35,5 +35,6 @@ ReactDOM.render(
Click me <Icon type="down" /> Click me <Icon type="down" />
</a> </a>
</Dropdown>, </Dropdown>,
mountNode); mountNode
);
```` ````

View File

@ -32,7 +32,7 @@ describe('Form', () => {
} }
const Wrapped = Form.create()(TestForm); const Wrapped = Form.create()(TestForm);
let form; let form;
mount(<Wrapped wrappedComponentRef={node => form = node} />); mount(<Wrapped wrappedComponentRef={(node) => { form = node; }} />);
expect(form).toBeInstanceOf(TestForm); expect(form).toBeInstanceOf(TestForm);
}); });
}); });

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