-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathpanel.tsx
110 lines (102 loc) · 2.13 KB
/
panel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-disable @typescript-eslint/no-shadow */
import React from 'react';
import '../assets/index.less';
import Cascader from '../src';
const addressOptions = [
{
label: '福建',
value: 'fj',
children: [
{
label: '福州',
value: 'fuzhou',
children: [
{
label: '马尾',
value: 'mawei',
},
],
},
{
label: '泉州',
value: 'quanzhou',
},
],
},
{
label: '浙江',
value: 'zj',
children: [
{
label: '杭州',
value: 'hangzhou',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
],
},
{
label: '北京',
value: 'bj',
children: [
{
label: '朝阳区',
value: 'chaoyang',
},
{
label: '海淀区',
value: 'haidian',
},
],
},
];
export default () => {
const [value, setValue] = React.useState<string[]>([]);
const [value2, setValue2] = React.useState<string[][]>([]);
const [disabled, setDisabled] = React.useState(false);
return (
<>
<h1>Panel</h1>
<button
onClick={() => {
setValue(['bj', 'haidian']);
}}
>
Set Value
</button>
<button
onClick={() => {
setDisabled(prev => !prev);
}}
>
{disabled ? 'enable panel' : 'disable panel'}
</button>
<Cascader.Panel
value={value}
options={addressOptions}
onChange={nextValue => {
console.log('Change:', nextValue);
setValue(nextValue);
}}
disabled={disabled}
/>
<Cascader.Panel
checkable
value={value2}
options={addressOptions}
onChange={nextValue => {
console.log('Change:', nextValue);
setValue2(nextValue);
}}
disabled={disabled}
defaultActiveKey={['bj', 'haidian']}
/>
<Cascader.Panel options={addressOptions} disabled={disabled} direction="rtl" />
<Cascader.Panel notFoundContent="Empty!!!" />
</>
);
};