Skip to content

Commit 3fe6822

Browse files
authored
Deps update (react-component#175)
* Use new life cycle api * Update rc-tools for new lint check * Accessibility to reach 100%
1 parent cf6a0e5 commit 3fe6822

19 files changed

+401
-290
lines changed

assets/index.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
>span:not(.@{treePrefixCls}-switcher),
162162
>a,
163163
>a span {
164-
color: #ccc;
164+
color: #767676;
165165
cursor: not-allowed;
166166
}
167167
}
@@ -189,4 +189,4 @@
189189
margin-right: 2px;
190190
vertical-align: top;
191191
}
192-
}
192+
}

examples/basic-controlled.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
/* eslint no-console:0 */
1+
/* eslint-disable no-console, react/no-unescaped-entities */
22
import 'rc-tree/assets/index.less';
33
import React from 'react';
44
import ReactDOM from 'react-dom';
55
import PropTypes from 'prop-types';
66
import Tree, { TreeNode } from 'rc-tree';
7-
import { gData,
8-
/* filterParentPosition, getFilterExpandedKeys,*/ getRadioSelectKeys } from './util';
97
import 'rc-dialog/assets/index.css';
108
import Modal from 'rc-dialog';
9+
import { gData, getRadioSelectKeys } from './util';
1110

1211
class Demo extends React.Component {
1312
static propTypes = {
13+
visible: PropTypes.bool,
1414
multiple: PropTypes.bool,
1515
};
1616
static defaultProps = {
@@ -41,7 +41,7 @@ class Demo extends React.Component {
4141
checkedKeys,
4242
});
4343
}
44-
onCheckStrictly = (checkedKeys, /* extra*/) => {
44+
onCheckStrictly = (checkedKeys, /* extra */) => {
4545
console.log(arguments);
4646
// const { checkedNodesPositions } = extra;
4747
// const pps = filterParentPosition(checkedNodesPositions.map(i => i.pos));

examples/basic.js

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint no-console:0 */
22
/* eslint no-alert:0 */
3+
/* eslint jsx-a11y/no-noninteractive-element-interactions:0 */
34
import React from 'react';
45
import PropTypes from 'prop-types';
56
import ReactDOM from 'react-dom';
@@ -21,7 +22,6 @@ class Demo extends React.Component {
2122
defaultExpandedKeys: keys,
2223
defaultSelectedKeys: keys,
2324
defaultCheckedKeys: keys,
24-
switchIt: true,
2525
};
2626
}
2727
onExpand = (expandedKeys) => {
@@ -46,62 +46,70 @@ class Demo extends React.Component {
4646
e.stopPropagation();
4747
};
4848
render() {
49-
const customLabel = (<span className="cus-label">
50-
<span>operations: </span>
51-
<span style={{ color: 'blue' }} onClick={this.onEdit}>Edit</span>&nbsp;
52-
<label onClick={(e) => e.stopPropagation()}><input type="checkbox" /> checked</label> &nbsp;
53-
<span style={{ color: 'red' }} onClick={this.onDel}>Delete</span>
54-
</span>);
55-
return (<div style={{ margin: '0 20px' }}>
56-
<h2>simple</h2>
57-
<Tree
58-
className="myCls" showLine checkable defaultExpandAll
59-
defaultExpandedKeys={this.state.defaultExpandedKeys}
60-
onExpand={this.onExpand}
61-
defaultSelectedKeys={this.state.defaultSelectedKeys}
62-
defaultCheckedKeys={this.state.defaultCheckedKeys}
63-
onSelect={this.onSelect} onCheck={this.onCheck}
64-
>
65-
<TreeNode title="parent 1" key="0-0">
66-
<TreeNode title={customLabel} key="0-0-0">
67-
<TreeNode title="leaf" key="0-0-0-0" style={{ background: 'rgba(255, 0, 0, 0.1)' }} />
68-
<TreeNode title="leaf" key="0-0-0-1" />
69-
</TreeNode>
70-
<TreeNode title="parent 1-1" key="0-0-1">
71-
<TreeNode title="parent 1-1-0" key="0-0-1-0" disableCheckbox />
72-
<TreeNode title="parent 1-1-1" key="0-0-1-1" />
73-
</TreeNode>
74-
<TreeNode title="parent 1-2" key="0-0-2" disabled>
75-
<TreeNode title="parent 1-2-0" key="0-0-2-0" disabled />
76-
<TreeNode title="parent 1-2-1" key="0-0-2-1" />
77-
</TreeNode>
78-
</TreeNode>
79-
</Tree>
49+
const customLabel = (
50+
<span className="cus-label">
51+
<span>operations: </span>
52+
<span style={{ color: 'blue' }} onClick={this.onEdit}>Edit</span>&nbsp;
53+
<label onClick={(e) => e.stopPropagation()}>
54+
<input type="checkbox" /> checked
55+
</label>
56+
&nbsp;
57+
<span style={{ color: '#EB0000' }} onClick={this.onDel}>Delete</span>
58+
</span>
59+
);
8060

81-
<h2>Check on Click TreeNode</h2>
82-
<Tree
83-
className="myCls"
84-
showLine
85-
checkable
86-
selectable={ false }
87-
defaultExpandAll
88-
onExpand={this.onExpand}
89-
defaultSelectedKeys={this.state.defaultSelectedKeys}
90-
defaultCheckedKeys={this.state.defaultCheckedKeys}
91-
onSelect={this.onSelect}
92-
onCheck={this.onCheck}
93-
>
94-
<TreeNode title="parent 1" key="0-0">
95-
<TreeNode title="parent 1-1" key="0-0-0">
96-
<TreeNode title="parent 1-1-0" key="0-0-0-0" />
61+
return (
62+
<div style={{ margin: '0 20px' }}>
63+
<h2>simple</h2>
64+
<Tree
65+
className="myCls" showLine checkable defaultExpandAll
66+
defaultExpandedKeys={this.state.defaultExpandedKeys}
67+
onExpand={this.onExpand}
68+
defaultSelectedKeys={this.state.defaultSelectedKeys}
69+
defaultCheckedKeys={this.state.defaultCheckedKeys}
70+
onSelect={this.onSelect} onCheck={this.onCheck}
71+
>
72+
<TreeNode title="parent 1" key="0-0">
73+
<TreeNode title={customLabel} key="0-0-0">
74+
<TreeNode title="leaf" key="0-0-0-0" style={{ background: 'rgba(255, 0, 0, 0.1)' }} />
75+
<TreeNode title="leaf" key="0-0-0-1" />
76+
</TreeNode>
77+
<TreeNode title="parent 1-1" key="0-0-1">
78+
<TreeNode title="parent 1-1-0" key="0-0-1-0" disableCheckbox />
79+
<TreeNode title="parent 1-1-1" key="0-0-1-1" />
80+
</TreeNode>
81+
<TreeNode title="parent 1-2" key="0-0-2" disabled>
82+
<TreeNode title="parent 1-2-0" key="0-0-2-0" disabled />
83+
<TreeNode title="parent 1-2-1" key="0-0-2-1" />
84+
</TreeNode>
9785
</TreeNode>
98-
<TreeNode title="parent 1-2" key="0-0-1">
99-
<TreeNode title="parent 1-2-0" key="0-0-1-0" disableCheckbox />
100-
<TreeNode title="parent 1-2-1" key="0-0-1-1" />
86+
</Tree>
87+
88+
<h2>Check on Click TreeNode</h2>
89+
<Tree
90+
className="myCls"
91+
showLine
92+
checkable
93+
selectable={ false }
94+
defaultExpandAll
95+
onExpand={this.onExpand}
96+
defaultSelectedKeys={this.state.defaultSelectedKeys}
97+
defaultCheckedKeys={this.state.defaultCheckedKeys}
98+
onSelect={this.onSelect}
99+
onCheck={this.onCheck}
100+
>
101+
<TreeNode title="parent 1" key="0-0">
102+
<TreeNode title="parent 1-1" key="0-0-0">
103+
<TreeNode title="parent 1-1-0" key="0-0-0-0" />
104+
</TreeNode>
105+
<TreeNode title="parent 1-2" key="0-0-1">
106+
<TreeNode title="parent 1-2-0" key="0-0-1-0" disableCheckbox />
107+
<TreeNode title="parent 1-2-1" key="0-0-1-1" />
108+
</TreeNode>
101109
</TreeNode>
102-
</TreeNode>
103-
</Tree>
104-
</div>);
110+
</Tree>
111+
</div>
112+
);
105113
}
106114
}
107115

examples/big-data-generator.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint react/no-string-refs:0 */
2+
13
import React from 'react';
24
import PropTypes from 'prop-types';
35
import { generateData, calcTotal } from './util';
@@ -42,15 +44,15 @@ class Gen extends React.Component {
4244
return (<div style={{ padding: '0 20px' }}>
4345
<h2>big data generator</h2>
4446
<form onSubmit={this.onGen}>
45-
<span style={{ marginRight: 10 }}>
47+
<label style={{ marginRight: 10 }}>
4648
x: <input ref="x" defaultValue={x} type="number" min="1" required style={{ width: 50 }} />
47-
</span>
48-
<span style={{ marginRight: 10 }}>
49+
</label>
50+
<label style={{ marginRight: 10 }}>
4951
y: <input ref="y" defaultValue={y} type="number" min="0" required style={{ width: 50 }} />
50-
</span>
51-
<span style={{ marginRight: 10 }}>
52+
</label>
53+
<label style={{ marginRight: 10 }}>
5254
z: <input ref="z" defaultValue={z} type="number" min="0" required style={{ width: 50 }} />
53-
</span>
55+
</label>
5456
<button type="submit">Generate</button>
5557
<p>total nodes: {this.state.nums || calcTotal(x, y, z)}</p>
5658
</form>

examples/big-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Demo extends React.Component {
3232
checkedKeys,
3333
});
3434
}
35-
onCheckStrictly = (checkedKeys1, /* extra*/) => {
35+
onCheckStrictly = (checkedKeys1, /* extra */) => {
3636
console.log(arguments);
3737
this.setState({
3838
checkedKeys1,

examples/contextmenu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint no-console:0 */
22
import 'rc-tree/assets/index.less';
3-
import './contextmenu.less';
43
import React from 'react';
54
import ReactDOM from 'react-dom';
65
import Tree, { TreeNode } from 'rc-tree';
76
import Tooltip from 'rc-tooltip';
7+
import './contextmenu.less';
88

99
function contains(root, n) {
1010
let node = n;
@@ -65,7 +65,7 @@ class Demo extends React.Component {
6565
trigger="click" placement="bottomRight" prefixCls="rc-tree-contextmenu"
6666
defaultVisible overlay={<h4>{info.node.props.title}</h4>}
6767
>
68-
<span></span>
68+
<span />
6969
</Tooltip>
7070
);
7171

examples/draggable.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint no-console:0 */
22
import 'rc-tree/assets/index.less';
3-
import './draggable.less';
43
import React from 'react';
54
import ReactDOM from 'react-dom';
65
import Tree, { TreeNode } from 'rc-tree';
76
import { gData } from './util';
7+
import './draggable.less';
88

99
class Demo extends React.Component {
1010
state = {
@@ -31,10 +31,11 @@ class Demo extends React.Component {
3131
const loop = (data, key, callback) => {
3232
data.forEach((item, index, arr) => {
3333
if (item.key === key) {
34-
return callback(item, index, arr);
34+
callback(item, index, arr);
35+
return;
3536
}
3637
if (item.children) {
37-
return loop(item.children, key, callback);
38+
loop(item.children, key, callback);
3839
}
3940
});
4041
};

examples/dropdown.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* eslint react/no-multi-comp:0 */
22
/* eslint no-console:0 */
3+
/* eslint react/no-string-refs:0 */
4+
35
import 'rc-tree/assets/index.less';
4-
import './dropdown.less';
56
import React from 'react';
67
import ReactDOM from 'react-dom';
78
import PropTypes from 'prop-types';
89
import Tree, { TreeNode } from 'rc-tree';
910
import Trigger from 'rc-trigger';
1011
import { gData } from './util';
12+
import './dropdown.less';
1113

1214
const placements = {
1315
topLeft: {

examples/icon.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint no-console:0 */
22
/* eslint no-alert:0 */
33
import React from 'react';
4+
import PropTypes from 'prop-types';
45
import classNames from 'classnames';
56
import ReactDOM from 'react-dom';
67
import Tree, { TreeNode } from 'rc-tree';
@@ -15,41 +16,40 @@ const Icon = ({ selected }) => (
1516
)}
1617
/>
1718
);
19+
Icon.propTypes = {
20+
selected: PropTypes.bool,
21+
};
1822

19-
class Demo extends React.Component {
20-
render() {
21-
return (
22-
<div>
23-
<h2>Customize icon with element</h2>
24-
<Tree
25-
defaultExpandAll
26-
>
27-
<TreeNode icon={<span className="customize-icon" />} title="Parent">
28-
<TreeNode icon={<span className="customize-icon sub-icon" />} title="Child" />
29-
</TreeNode>
30-
</Tree>
23+
const Demo = () => (
24+
<div>
25+
<h2>Customize icon with element</h2>
26+
<Tree
27+
defaultExpandAll
28+
>
29+
<TreeNode icon={<span className="customize-icon" />} title="Parent">
30+
<TreeNode icon={<span className="customize-icon sub-icon" />} title="Child" />
31+
</TreeNode>
32+
</Tree>
3133

32-
<h2>Customize icon with component</h2>
33-
<Tree
34-
defaultExpandAll
35-
>
36-
<TreeNode icon={Icon} title="Parent">
37-
<TreeNode icon={Icon} title="Child" />
38-
</TreeNode>
39-
</Tree>
34+
<h2>Customize icon with component</h2>
35+
<Tree
36+
defaultExpandAll
37+
>
38+
<TreeNode icon={Icon} title="Parent">
39+
<TreeNode icon={Icon} title="Child" />
40+
</TreeNode>
41+
</Tree>
4042

41-
<h2>Customize icon with Tree prop</h2>
42-
<Tree
43-
defaultExpandAll
44-
icon={Icon}
45-
>
46-
<TreeNode title="Parent">
47-
<TreeNode title="Child" />
48-
</TreeNode>
49-
</Tree>
50-
</div>
51-
);
52-
}
53-
}
43+
<h2>Customize icon with Tree prop</h2>
44+
<Tree
45+
defaultExpandAll
46+
icon={Icon}
47+
>
48+
<TreeNode title="Parent">
49+
<TreeNode title="Child" />
50+
</TreeNode>
51+
</Tree>
52+
</div>
53+
);
5454

5555
ReactDOM.render(<Demo />, document.getElementById('__react-content'));

examples/util.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint no-loop-func: 0*/
1+
/* eslint no-loop-func: 0 */
22
/* eslint no-console:0 */
33

44
export function generateData(x = 3, y = 2, z = 1, gData = []) {
@@ -23,13 +23,15 @@ export function generateData(x = 3, y = 2, z = 1, gData = []) {
2323
tns[index].children = [];
2424
return _loop(__level, key, tns[index].children);
2525
});
26+
27+
return null;
2628
}
2729
_loop(z);
2830
return gData;
2931
}
3032
export function calcTotal(x = 3, y = 2, z = 1) {
31-
/* eslint no-param-reassign:0*/
32-
const rec = (n) => n >= 0 ? x * Math.pow(y, n--) + rec(n) : 0;
33+
/* eslint no-param-reassign:0 */
34+
const rec = (n) => n >= 0 ? x * (y ** n--) + rec(n) : 0;
3335
return rec(z + 1);
3436
}
3537
console.log('总节点数(单个tree):', calcTotal());

0 commit comments

Comments
 (0)