Skip to content

Commit f7fa835

Browse files
authored
fix: Fix Indent to correct level (react-component#390)
* test: update snapshot * fix lint * fix more lint * bump ci node version
1 parent fa14b88 commit f7fa835

File tree

14 files changed

+150
-78
lines changed

14 files changed

+150
-78
lines changed

.eslintrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
const base = require('@umijs/fabric/dist/eslint');
2-
31
module.exports = {
4-
...base,
2+
extends: [require.resolve('@umijs/fabric/dist/eslint')],
3+
54
rules: {
6-
...base.rules,
75
'react/sort-comp': 0,
86
'default-case': 0,
97
'eslint-comments/disable-enable-pair': 0,
@@ -12,5 +10,7 @@ module.exports = {
1210
'jsx-a11y/label-has-for': 0,
1311
'jsx-a11y/label-has-associated-control': 0,
1412
'no-loop-func': 0,
13+
'@typescript-eslint/no-loop-func': 0,
14+
'max-classes-per-file': 0,
1515
},
1616
};

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ notifications:
77
88

99
node_js:
10-
- 10
10+
- 14
1111

1212
before_install:
1313
- |

assets/index.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.@{treePrefixCls} {
55
margin: 0;
66
border: 1px solid transparent;
7-
7+
88
&-focused:not(&-active-focused) {
99
border-color: cyan;
1010
}
@@ -210,6 +210,7 @@
210210
vertical-align: top;
211211
}
212212
&-indent-unit {
213+
width: 16px;
213214
display: inline-block;
214215
padding-left: 18px;
215216
}

examples/animation.jsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,27 @@ function getTreeData() {
8181
{
8282
key: '1',
8383
title: 'node 1',
84-
children: new Array(1000)
85-
.fill(null)
86-
.map((_, index) => ({ title: `auto ${index}`, key: `auto-${index}` })),
84+
// children: new Array(1000)
85+
// .fill(null)
86+
// .map((_, index) => ({ title: `auto ${index}`, key: `auto-${index}` })),
87+
children: [
88+
{
89+
key: '1-0',
90+
title: 'node 1-0',
91+
children: [
92+
{ key: '1-0-0', title: 'node 1-0-0' },
93+
{
94+
key: '1-0-1',
95+
title: 'node 1-0-1',
96+
children: [
97+
{ key: '1-0-1-0', title: 'node 1-0-1-0' },
98+
{ key: '1-0-1-1', title: 'node 1-0-1-1' },
99+
],
100+
},
101+
{ key: '1-0-2', title: 'node 1-0-2' },
102+
],
103+
},
104+
],
87105
},
88106
];
89107
}
@@ -105,7 +123,8 @@ const Demo = () => {
105123
<h3>With Virtual</h3>
106124
<Tree
107125
ref={treeRef}
108-
defaultExpandAll={false}
126+
// defaultExpandAll={false}
127+
defaultExpandAll
109128
defaultExpandedKeys={defaultExpandedKeys}
110129
motion={motion}
111130
height={200}

examples/animation.less

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,56 @@
55
.rc-tree-indent {
66
position: relative;
77
align-self: stretch;
8+
display: flex;
9+
flex-wrap: nowrap;
10+
align-items: stretch;
811

912
.rc-tree-indent-unit {
1013
position: relative;
1114
height: 100%;
1215

1316
&::before {
1417
position: absolute;
15-
top: 100%;
16-
right: -26px;
17-
bottom: -100%;
18+
top: 0;
19+
bottom: 0;
1820
border-right: 1px solid blue;
21+
left: 50%;
1922
content: '';
2023
}
2124

22-
// End should ignore
2325
&-end {
2426
&::before {
2527
display: none;
2628
}
2729
}
30+
31+
// End should ignore
32+
// &-end {
33+
// &::before {
34+
// display: none;
35+
// }
36+
// }
37+
}
38+
}
39+
40+
.rc-tree-switcher-noop {
41+
&::before {
42+
content: '';
43+
display: inline-block;
44+
width: 16px;
45+
height: 16px;
46+
background: red;
47+
border-radius: 100%;
2848
}
2949
}
3050

3151
// Motion
3252
&-motion:not(.node-motion-appear-active) {
33-
.rc-tree-indent-unit {
34-
&::before {
35-
display: none;
36-
}
37-
}
53+
// .rc-tree-indent-unit {
54+
// &::before {
55+
// display: none;
56+
// }
57+
// }
3858
}
3959
}
4060
}

examples/big-data.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Demo extends React.Component {
1313
selectedKeys: [],
1414
};
1515

16-
componentWillUpdate(nextProps, nextState) {
16+
componentDidUpdate(nextProps, nextState) {
1717
// invoked immediately before rendering with new props or state, not for initial 'render'
1818
// see componentWillReceiveProps if you need to call setState
1919
// console.log(nextState.gData === this.state.gData);

examples/dropdown.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ class DropdownTree extends React.Component {
5252
};
5353
}
5454

55-
componentWillReceiveProps(props) {
55+
static getDerivedStateFromProps(props) {
5656
if ('visible' in props) {
57-
this.setState({
57+
return {
5858
visible: props.visible,
59-
});
59+
};
6060
}
61+
return null;
6162
}
6263

6364
onChange = value => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@types/react": "^16.8.19",
5353
"@types/react-dom": "^16.8.4",
5454
"@types/warning": "^3.0.0",
55-
"@typescript-eslint/parser": "^4.0.1",
55+
"@umijs/fabric": "^2.3.1",
5656
"css-animation": "^1.2.0",
5757
"enzyme": "^3.3.0",
5858
"enzyme-adapter-react-16": "^1.1.1",

src/Indent.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ const Indent: React.FC<IndentProps> = ({ prefixCls, level, isStart, isEnd }) =>
2020
<span
2121
key={i}
2222
className={classNames(baseClassName, {
23-
[`${baseClassName}-start`]: isStart[i + 1],
24-
[`${baseClassName}-end`]: isEnd[i + 1],
25-
[`${baseClassName}-end-first-level`]: !i && isEnd[0],
23+
[`${baseClassName}-start`]: isStart[i],
24+
[`${baseClassName}-end`]: isEnd[i],
2625
})}
2726
/>,
2827
);

src/util.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import React from 'react';
66
import warning from 'rc-util/lib/warning';
77
import TreeNode, { TreeNodeProps } from './TreeNode';
8-
import { NodeElement, Key, DataNode, Entity, DataEntity, NodeInstance } from './interface';
8+
import { NodeElement, Key, DataNode, DataEntity, NodeInstance } from './interface';
99
import { TreeProps } from './Tree';
1010

1111
const DRAG_SIDE_RANGE = 0.25;
@@ -110,12 +110,6 @@ export function convertDataToTree(
110110
);
111111
}
112112

113-
// TODO: ========================= NEW LOGIC =========================
114-
interface Wrapper {
115-
posEntities: Record<string, Entity>;
116-
keyEntities: Record<Key, Entity>;
117-
}
118-
119113
/**
120114
* Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
121115
*/

0 commit comments

Comments
 (0)