@@ -14,7 +14,10 @@ simple usage, has clear, show search
14
14
---
15
15
16
16
```` jsx
17
- import { Select } from ' @alifd/next' ;
17
+ import { Select , Button , Radio , TreeSelect , Drawer , Dialog , Message , DatePicker , DatePicker2 , CascaderSelect } from ' @alifd/next' ;
18
+ import ' whatwg-fetch' ;
19
+
20
+ const TreeNode = TreeSelect .Node ;
18
21
19
22
const Option = Select .Option ;
20
23
@@ -34,8 +37,155 @@ const onBlur = () => {
34
37
console .log (' blur' );
35
38
};
36
39
40
+
41
+ class Demo extends React .Component {
42
+ state = {
43
+ visible: false ,
44
+ placement: ' right'
45
+ };
46
+
47
+ onOpen = () => {
48
+ this .setState ({
49
+ visible: true
50
+ });
51
+ };
52
+
53
+ onClose = (reason ) => {
54
+
55
+ this .setState ({
56
+ visible: false
57
+ });
58
+ };
59
+
60
+ onPlacementChange = dir => {
61
+ this .setState ({
62
+ placement: dir
63
+ });
64
+ }
65
+
66
+ render () {
67
+ return (
68
+ < div>
69
+ < Radio .Group
70
+ dataSource= {[' right' , ' bottom' , ' left' , ' top' ]}
71
+ defaultValue= {' right' }
72
+ onChange= {this .onPlacementChange }
73
+ / >
74
+ < br/ >
75
+ < br/ >
76
+ < Button type= " primary" onClick= {this .onOpen }> open < / Button>
77
+ < Drawer
78
+ title= " 标题"
79
+ visible= {this .state .visible }
80
+ placement= {this .state .placement }
81
+ onClose= {this .onClose }>
82
+ Start your business here by searching a popular product
83
+ < / Drawer>
84
+ < / div>
85
+ );
86
+ }
87
+ }
88
+
89
+
90
+ const popupCustomIcon = () => {
91
+ Dialog .confirm ({
92
+ title: " Confirm" ,
93
+ content: ' set icon as "warning" ' ,
94
+ closeMode: [' mask' , ' icon' , ' esc' ],
95
+ messageProps: {
96
+ type: " warning"
97
+ },
98
+ onOk : () => console .log (" ok" ),
99
+ onCancel : () => console .log (" cancel" )
100
+ });
101
+ };
102
+
103
+ const notice = () => {
104
+ Message .notice (' This is a Toast Message Notice' );
105
+ };
106
+
107
+
108
+ class Demo3 extends React .Component {
109
+ constructor (props ) {
110
+ super (props);
111
+
112
+ this .state = {
113
+ data: []
114
+ };
115
+ }
116
+
117
+ componentDidMount () {
118
+ fetch (' https://os.alipayobjects.com/rmsportal/ODDwqcDFTLAguOvWEolX.json' )
119
+ .then (response => response .json ())
120
+ .then (data => {
121
+ this .setState ({ data });
122
+ })
123
+ .catch (e => console .log (e));
124
+ }
125
+
126
+ handleChange = (value , data , extra ) => {
127
+ console .log (value, data, extra);
128
+ }
129
+
130
+ render () {
131
+ return < CascaderSelect dataSource= {this .state .data } onChange= {this .handleChange } / > ;
132
+ }
133
+ }
134
+
135
+
136
+ class Demo4 extends React .Component {
137
+ constructor (props ) {
138
+ super (props);
139
+
140
+ this .handleChange = this .handleChange .bind (this );
141
+ }
142
+
143
+ handleChange (value , data ) {
144
+ console .log (value, data);
145
+ }
146
+
147
+ render () {
148
+ return (
149
+ < TreeSelect
150
+ treeDefaultExpandAll
151
+ onChange= {this .handleChange }
152
+ style= {{ width: 200 }}
153
+ >
154
+ < TreeNode key= " 1" value= " 1" label= " Component" >
155
+ < TreeNode key= " 2" value= " 2" label= " Form" >
156
+ < TreeNode key= " 4" value= " 4" label= " Input" / >
157
+ < TreeNode key= " 5" value= " 5" label= " Select" disabled / >
158
+ < / TreeNode>
159
+ < TreeNode key= " 3" value= " 3" label= " Display" >
160
+ < TreeNode key= " 6" value= " 6" label= " Table" / >
161
+ < / TreeNode>
162
+ < / TreeNode>
163
+ < / TreeSelect>
164
+ );
165
+ }
166
+ }
167
+
168
+
37
169
ReactDOM .render (
38
170
< div>
171
+ Drawer:
172
+ < br / >
173
+ < Demo / >
174
+ < br / >
175
+ Dialog:
176
+ < br / >
177
+ < Button onClick= {popupCustomIcon}> custom< / Button>
178
+ < br / >
179
+ < br / >
180
+ Toast:
181
+ < br / >
182
+ < Button type= " primary" onClick= {notice}>
183
+ Display Toast Message Notice
184
+ < / Button>
185
+ < br / >
186
+ < br / >
187
+ Select:
188
+ < br / >
39
189
< Select
40
190
id= " basic-demo"
41
191
onChange= {onChange}
@@ -50,38 +200,15 @@ ReactDOM.render(
50
200
< Option value= " frank" > Frank< / Option>
51
201
< Option value= " hugo" > Hugo< / Option>
52
202
< / Select>
53
-
54
-
55
- < Select
56
- defaultValue= " clear"
57
- hasClear
58
- style= {{marginRight: 8 }}
59
- >
60
- < Option value= " jack" > Jack< / Option>
61
- < Option value= " frank" > Frank< / Option>
62
- < Option value= " clear" > clear< / Option>
63
- < / Select>
64
-
65
- < Select
66
- placeholder= " show search"
67
- showSearch
68
- hasClear
69
- style= {{marginRight: 8 }}
70
- >
71
- < Option value= " jack" > Jack< / Option>
72
- < Option value= " frank" > Frank< / Option>
73
- < Option value= " hugo" > Hugo< / Option>
74
- < / Select>
75
-
76
- < Select
77
- disabled
78
- defaultValue= " frank"
79
- style= {{marginRight: 8 }}
80
- >
81
- < Option value= " jack" > Jack< / Option>
82
- < Option value= " frank" > Frank< / Option>
83
- < Option value= " hugo" > Hugo< / Option>
84
- < / Select>
203
+ < br / >< br / >
204
+ < DatePicker / >
205
+ < br / >< br / >
206
+ < DatePicker2 / >
207
+ < br / >< br / >
208
+ < Demo3 / >
209
+ < br / >< br / >
210
+ < Demo4 / >
211
+ < br / >< br / >
85
212
86
213
< / div> ,
87
214
mountNode
0 commit comments