Skip to content

Commit 048cc9c

Browse files
author
liyuan-meng
committed
[TreeSelect]废弃 searchInbox 属性,多选组件支持配置已选数据超长展示省略号
1 parent 69b31af commit 048cc9c

16 files changed

Lines changed: 487 additions & 291 deletions

src/components/tree-select/demos/basic-tree-select.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class TreeSelectDemo extends React.Component {
6161
{/*<h5>单选搜索框在下拉框内</h5>*/}
6262
<TreeSelect
6363
searchable
64-
searchInBox={false}
6564
allowClear
6665
onSearch={this.handleSearch}
6766
value={{
@@ -77,7 +76,6 @@ class TreeSelectDemo extends React.Component {
7776
{/*<div>*/}
7877
{/* <h5>单选搜索框在下拉框外(新)</h5>*/}
7978
{/* <TreeSelect*/}
80-
{/* searchInBox*/}
8179
{/* searchable*/}
8280
{/* allowClear*/}
8381
{/* onSearch={this.handleSearch}*/}

src/components/tree-select/demos/multiple.md renamed to src/components/tree-select/demos/basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class TreeSelectDemo extends React.Component {
163163
allowClear
164164
placeholder="选择一个选项"
165165
style={{ width: 328 }}
166-
footerTypes={['ok', 'reset']}
166+
footerTypes={['ok', 'cancel']}
167167
dataSource={this.treeData}
168168
showIcon={false}
169169
value={this.state.confirmNodes}

src/components/tree-select/demos/dynamicLoad.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class TreeSelectDemo extends React.Component {
100100
<h5>单选</h5>
101101
<TreeSelect
102102
searchable
103-
searchInBox
104103
allowClear
105104
type="single"
106105
containParentNode
@@ -146,7 +145,6 @@ class TreeSelectDemo extends React.Component {
146145
<h5>多选</h5>
147146
<TreeSelect
148147
searchable
149-
searchInBox
150148
allowClear
151149
type="multiple"
152150
containParentNode

src/components/tree-select/demos/line.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class TreeSelectDemo extends React.Component {
132132
showLine
133133
lineType="dashed"
134134
searchable
135-
searchInBox
136135
allowClear
137136
type="single"
138137
isUnfold
@@ -150,7 +149,6 @@ class TreeSelectDemo extends React.Component {
150149
<TreeSelect
151150
showLine
152151
searchable
153-
searchInBox
154152
allowClear
155153
type="multiple"
156154
isUnfold

src/components/tree-select/demos/path.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class TreeSelectDemo extends React.Component {
130130
<h5>单选</h5>
131131
<TreeSelect
132132
searchable
133-
searchInBox
134133
showPath
135134
allowClear
136135
type="single"
@@ -148,7 +147,6 @@ class TreeSelectDemo extends React.Component {
148147
<h5>多选</h5>
149148
<TreeSelect
150149
searchable
151-
searchInBox
152150
allowClear
153151
showPath
154152
type="multiple"

src/components/tree-select/demos/searchable.md

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,25 @@ class TreeSelectDemo extends React.Component {
4747
name: '禁止删除节点4',
4848
pId: 11,
4949
children: []
50-
}
50+
},
51+
{
52+
id: 115,
53+
name: '禁止删除节点5',
54+
pId: 11,
55+
children: []
56+
},
57+
{
58+
id: 116,
59+
name: '禁止删除节点6',
60+
pId: 11,
61+
children: []
62+
},
63+
{
64+
id: 117,
65+
name: '禁止删除节点7',
66+
pId: 11,
67+
children: []
68+
}
5169
]
5270
},
5371
{
@@ -58,6 +76,15 @@ class TreeSelectDemo extends React.Component {
5876
disableAdd: true,
5977
disableRename: true,
6078
children: []
79+
},
80+
{
81+
id: 15,
82+
name: '超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长',
83+
pId: 1,
84+
disableRemove: true,
85+
disableAdd: true,
86+
disableRename: true,
87+
children: []
6188
}
6289
];
6390

@@ -94,9 +121,26 @@ class TreeSelectDemo extends React.Component {
94121
this.setState({ disabled: checked })
95122
}}>禁用</Checkbox>
96123
<div>
97-
<h5>单选搜索框在下拉框外(新)</h5>
124+
<h5>单选</h5>
125+
<TreeSelect
126+
searchable
127+
allowClear
128+
disabled={this.state.disabled}
129+
type="single"
130+
isUnfold
131+
containParentNode
132+
placeholder="选择一个选项"
133+
style={{ width: 328 }}
134+
dataSource={this.treeData}
135+
value={this.state.singleNodes}
136+
onChange={this.onChangeSingle}
137+
/>
138+
</div>
139+
<div>
140+
<h5>单选-已选数据超长可滚动</h5>
98141
<TreeSelect
99142
searchable
143+
scrollSelected
100144
allowClear
101145
disabled={this.state.disabled}
102146
type="single"
@@ -110,7 +154,7 @@ class TreeSelectDemo extends React.Component {
110154
/>
111155
</div>
112156
<div>
113-
<h5>多选搜索框在下拉框外(新)</h5>
157+
<h5>多选</h5>
114158
<TreeSelect
115159
searchable
116160
allowClear
@@ -126,10 +170,10 @@ class TreeSelectDemo extends React.Component {
126170
/>
127171
</div>
128172
<div>
129-
<h5>多选限制标签数量(新)</h5>
173+
<h5>多选-限制标签展示数量</h5>
130174
<TreeSelect
131175
searchable
132-
maxTagCount={1}
176+
maxTagCount={5}
133177
allowClear
134178
disabled={this.state.disabled}
135179
type="multiple"
@@ -143,27 +187,65 @@ class TreeSelectDemo extends React.Component {
143187
/>
144188
</div>
145189
<div>
146-
<h5 style={{ color: 'rgba(0,0,0,0.45)', fontWeight: 400 }}>单选搜索框在下拉框内(旧)</h5>
190+
<h5>多选-不限制标签展示数量</h5>
147191
<TreeSelect
148192
searchable
149-
searchInBox={false}
193+
maxTagCount={0}
150194
allowClear
151195
disabled={this.state.disabled}
152-
type="single"
196+
type="multiple"
153197
isUnfold
154198
containParentNode
155199
placeholder="选择一个选项"
156200
style={{ width: 328 }}
157201
dataSource={this.treeData}
158-
value={this.state.singleNodes}
159-
onChange={this.onChangeSingle}
202+
value={this.state.selectedNodes}
203+
onChange={this.handleChange}
204+
/>
205+
</div>
206+
<div>
207+
<h5>多选-不限制标签展示数量且展示滚动条</h5>
208+
<TreeSelect
209+
searchable
210+
maxTagCount={0}
211+
maxHeight={58}
212+
allowClear
213+
disabled={this.state.disabled}
214+
type="multiple"
215+
isUnfold
216+
containParentNode
217+
placeholder="选择一个选项"
218+
style={{ width: 328 }}
219+
dataSource={this.treeData}
220+
value={this.state.selectedNodes}
221+
onChange={this.handleChange}
222+
/>
223+
</div>
224+
<div>
225+
<h5>多选-已选数据逗号分隔且超长展示省略号</h5>
226+
<TreeSelect
227+
searchable
228+
maxTagCount={0}
229+
showTag={false}
230+
allowClear
231+
disabled={this.state.disabled}
232+
type="multiple"
233+
isUnfold
234+
containParentNode
235+
placeholder="选择一个选项"
236+
style={{ width: 328 }}
237+
dataSource={this.treeData}
238+
value={this.state.selectedNodes}
239+
onChange={this.handleChange}
160240
/>
161241
</div>
162242
<div>
163-
<h5 style={{ color: 'rgba(0,0,0,0.45)', fontWeight: 400 }}>多选搜索框在下拉框内(旧)</h5>
243+
<h5>多选-已选数据逗号分隔且超长可滚动</h5>
164244
<TreeSelect
165245
searchable
166-
searchInBox={false}
246+
maxTagCount={0}
247+
showTag={false}
248+
scrollSelected
167249
allowClear
168250
disabled={this.state.disabled}
169251
type="multiple"

src/components/tree-select/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import ShuyunUtils from 'shuyun-utils';
66
import ContextProvider from '@contexts/context-provider';
77
import { noop } from '@utils';
88

9-
import Tree from './tree';
9+
import Tree from './tree/tree';
1010
import Selected from './selected';
11-
import SingleTree from './single-tree';
11+
import SingleTree from './tree/single-tree';
1212
import { selector, SINGLE, MULTIPLE, getNodePath } from './const';
1313

1414
import './index.less';
@@ -197,9 +197,9 @@ class TreeSelect extends Component {
197197
}
198198
};
199199

200-
handleSelect = () => {
200+
handleSelect = ({ isClose = false } = {}) => {
201201
const { open } = this.state;
202-
const { onSelectOpen, onSelectClose, open: propOpen, searchInBox, type } = this.props;
202+
const { onSelectOpen, onSelectClose, open: propOpen, type } = this.props;
203203
if (open) {
204204
onSelectClose();
205205
} else {
@@ -211,7 +211,7 @@ class TreeSelect extends Component {
211211
setTimeout(() => {
212212
this.optionsNode.current.classList.add('show');
213213
});
214-
} else if (!searchInBox || searchInBox && type === MULTIPLE || searchInBox && type !== MULTIPLE && !this.state.isSearch) {
214+
} else if (type !== MULTIPLE && !this.state.isSearch || isClose) {
215215
this.optionsNode.current.classList.remove('show');
216216
setTimeout(() => {
217217
this.setState({ open: !open });
@@ -290,7 +290,7 @@ class TreeSelect extends Component {
290290
prevValue: selectedNodes,
291291
});
292292
this.props.onOk(node, selectedNodes);
293-
this.handleSelect();
293+
this.handleSelect({ isClose: true });
294294
};
295295

296296
handleCancel = () => {
@@ -299,7 +299,7 @@ class TreeSelect extends Component {
299299
value: prevValue,
300300
});
301301
this.props.onCancel();
302-
this.handleSelect();
302+
this.handleSelect({ isClose: true });
303303
};
304304

305305
handleReset = () => {
@@ -386,7 +386,6 @@ class TreeSelect extends Component {
386386
treeData={this.props.isDynamicLoad ? this.props.dataSource : this.state.treeData}
387387
disabled={disabled}
388388
searchable={searchable}
389-
searchInBox={this.props.searchInBox}
390389
treeRef={this.treeRef}
391390
setSearchStatus={this.setSearchStatus}
392391
onMultiChange={this.onValueChange}
@@ -427,14 +426,15 @@ TreeSelect.propTypes = {
427426
onOk: PropTypes.func,
428427
onCancel: PropTypes.func,
429428
onReset: PropTypes.func,
430-
searchInBox: PropTypes.bool,
431429
showTag: PropTypes.bool,
432430
maxTagCount: PropTypes.number,
431+
scrollSelected: PropTypes.bool,
433432
dropdownStyle: PropTypes.object,
434433
dropdownClassName: PropTypes.string,
435434
position: PropTypes.oneOf(['top', 'bottom', 'auto']),
436435
maxHeight: PropTypes.number,
437436
size: PropTypes.oneOf(['small', 'default', 'large']),
437+
borderRadiusSize: PropTypes.oneOf(['default', 'medium', 'large', 'circle']),
438438
};
439439

440440
TreeSelect.defaultProps = {
@@ -460,14 +460,15 @@ TreeSelect.defaultProps = {
460460
onOk: noop,
461461
onCancel: noop,
462462
onReset: noop,
463-
searchInBox: true,
464463
showTag: true,
465464
maxTagCount: 1,
465+
scrollSelected: false,
466466
dropdownStyle: {},
467467
dropdownClassName: '',
468468
position: 'bottom',
469469
maxHeight: undefined,
470470
size: 'default',
471+
borderRadiusSize: 'default',
471472
};
472473

473474
export default TreeSelect;

0 commit comments

Comments
 (0)