Skip to content

Commit 2737965

Browse files
committed
【级联选择器】根据组件2.1交互修改样式
1 parent 696eb7f commit 2737965

6 files changed

Lines changed: 32 additions & 47 deletions

File tree

src/components/c-cascader/demos/basic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ export default class Demo extends React.Component {
6868
options={addressOptions}
6969
onChange={this.onChange}
7070
placeholder="Please select"
71-
showSearch={{filter:this.filter }} />
71+
/>
7272
<div style={{ marginBottom: 24, marginTop: 40 }}>任意选项支持选择</div>
7373
<CCascader
7474
options={addressOptions}
7575
onChange={this.onChange}
7676
placeholder="Please select"
77-
showSearch={{filter:this.filter }}
77+
showSearch={{ filter:this.filter }}
7878
changeOnSelect/>
7979
</div>
8080
);

src/components/c-cascader/demos/customer-render.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ const addressOptions = [
4949
},
5050
];
5151

52-
const defaultOptions = [{
53-
label: '浙江',
54-
value: 'zj',
55-
}, {
56-
label: '杭州',
57-
value: 'hangzhou',
58-
}, {
59-
label: '余杭',
60-
value: 'yuhang',
61-
}];
6252
export default function Demo() {
6353
const onChange = value => {
6454
console.log(value);

src/components/c-cascader/demos/multiple.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { CCascader } from 'cloud-react';
1111
const addressOptions = [{
1212
label: '福建',
1313
value: 'fj',
14-
disabled: true,
1514
children: [{
1615
label: '福州',
1716
value: 'fuzhou',
@@ -61,27 +60,23 @@ const addressOptions = [{
6160
}],
6261
}];
6362

64-
const defaultOptions = [{
65-
label: '浙江',
66-
value: 'zj',
67-
}, {
68-
label: '杭州',
69-
value: 'hangzhou',
70-
}, {
71-
label: '余杭',
72-
value: 'yuhang',
73-
}];
7463
export default function Demo() {
7564
const [ value, setValue ] = useState([]);
76-
65+
const maxTagCount = addressOptions.reduce((acc, item) => {
66+
if (item.children && item.children.length){
67+
acc = acc + item.children.length;
68+
} else {
69+
acc += 1;
70+
}
71+
return acc;
72+
}, 0)
7773
const onChange = value => {
7874
setValue(value);
7975
}
8076

8177
const filter = (inputValue, path) => {
8278
return path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
8379
}
84-
8580
return (
8681
<div>
8782
<div style={{ marginBottom: 24 }}>多选级联组件</div>
@@ -92,15 +87,23 @@ export default function Demo() {
9287
value={value}
9388
multiple
9489
showSearch={{ filter: filter }}
95-
maxTagCount={2}/>
90+
maxTagCount={1}/>
9691
<div style={{ marginBottom: 24, marginTop: 40 }}>多选级联组件不可用</div>
9792
<CCascader
9893
options={addressOptions}
9994
placeholder="Please select"
10095
value={value}
10196
disabled
10297
multiple
103-
maxTagCount={2}/>
98+
maxTagCount={1}/>
99+
<div style={{ marginBottom: 24, marginTop: 40 }}>多选级联组件,全部展开</div>
100+
<CCascader
101+
options={addressOptions}
102+
onChange={onChange}
103+
placeholder="Please select"
104+
value={value}
105+
multiple
106+
maxTagCount={maxTagCount}/>
104107
</div>
105108
);
106109
}

src/components/c-cascader/demos/triggerType.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ const addressOptions = [
4949
},
5050
];
5151

52-
const defaultOptions = [{
53-
label: '浙江',
54-
value: 'zj',
55-
}, {
56-
label: '杭州',
57-
value: 'hangzhou',
58-
}, {
59-
label: '余杭',
60-
value: 'yuhang',
61-
}];
6252
export default function Demo() {
6353
const onChange = value => {
6454
console.log(value);

src/components/c-cascader/index.less

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,18 @@ input::-webkit-search-cancel-button {
164164
appearance: none;
165165
height: 30px;
166166
cursor: pointer;
167-
caret-color: rgba(0, 0, 0, 0);
167+
&:read-only {
168+
caret-color: rgba(0, 0, 0, 0);
169+
}
170+
168171
// width: 100%;
169172
}
170173

171174
&-multiple &-selector {
172175
display: flex;
173176
flex-wrap: wrap;
174177
align-items: center;
175-
padding: 1px 4px;
178+
padding: 0 12px 0 8px;
176179
max-height: 350px;
177180
overflow: auto;
178181
font-size: 12px;
@@ -241,14 +244,17 @@ input::-webkit-search-cancel-button {
241244
}
242245
}
243246

247+
&-multiple &-selection-overflow-item {
248+
height: 30px;
249+
}
244250
&-multiple &-selection-item {
245251
position: relative;
246252
display: flex;
247253
flex: none;
248254
box-sizing: border-box;
249255
max-width: 100%;
250256
height: 24px;
251-
margin-top: 0px;
257+
margin-top: 3px;
252258
margin-bottom: 0px;
253259
line-height: 22px;
254260
background: @gray-3;
@@ -322,13 +328,6 @@ input::-webkit-search-cancel-button {
322328
box-sizing: border-box;
323329
}
324330

325-
&-multiple &-selector {
326-
display: flex;
327-
flex-wrap: wrap;
328-
align-items: center;
329-
padding: 1px 4px;
330-
}
331-
332331
&-menus {
333332
display: flex;
334333
flex-wrap: nowrap;
@@ -349,6 +348,7 @@ input::-webkit-search-cancel-button {
349348
list-style: none;
350349
border-right: 1px solid @gray-4;
351350
-ms-overflow-style: -ms-autohiding-scrollbar;
351+
overflow: auto;
352352

353353
&-item {
354354
min-width: 100px;

src/components/c-cascader/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ group:
3131
| clearIcon | 清空图标 | ReactNode | <Icon type="close-fill-1" style={{ fontSize: '14px' }} />|
3232
| popupPlacement | 弹框位置 | bottomRight topRight bottomLeft topLeft | bottomLeft |
3333
| notFoundContent | 下拉列表为空时显示的内容 | string \| ReactNode | -- |
34+
| showSearch | 搜索配置 | object | -- |
35+
3436

3537
## 代码演示
3638

0 commit comments

Comments
 (0)