-
-
Notifications
You must be signed in to change notification settings - Fork 489
Expand file tree
/
Copy pathmultiple.tsx
More file actions
147 lines (132 loc) · 3.57 KB
/
multiple.tsx
File metadata and controls
147 lines (132 loc) · 3.57 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* eslint-disable no-console */
import React from 'react';
import Select, { Option } from '@rc-component/select';
import '../../assets/index.less';
const children: React.ReactNode[] = [];
for (let i = 10; i < 36; i += 1) {
children.push(
<Option key={i.toString(36) + i} disabled={i === 10} title={`中文${i}`}>
中文{i}
</Option>,
);
}
class Test extends React.Component {
state = {
useAnim: false,
suffixIcon: null,
loading: false,
value: ['a10'],
searchValue: '',
};
onChange = (value, options) => {
console.log('onChange', value, options);
this.setState({
value,
});
};
onSelect = (...args) => {
console.log(args);
};
onDeselect = (...args) => {
console.log(args);
};
useAnim = (e) => {
this.setState({
useAnim: e.target.checked,
});
};
showArrow = (e) => {
this.setState({
suffixIcon: e.target.checked ? <div>arrow</div> : null,
});
};
loading = (e) => {
this.setState({
loading: e.target.checked,
});
};
setSearchValue = (val) => {
this.setState({
searchValue: val,
});
};
render() {
const { useAnim, loading, value, suffixIcon } = this.state;
return (
<div>
<h2>multiple select(scroll the menu)</h2>
<p>
<label htmlFor="useAnim">
anim
<input id="useAnim" checked={useAnim} type="checkbox" onChange={this.useAnim} />
</label>
<p />
<label htmlFor="showArrow">
showArrow
<input
id="showArrow"
checked={!!suffixIcon}
type="checkbox"
onChange={this.showArrow}
/>
</label>
</p>
<p>
<label htmlFor="loading">
loading
<input id="loading" checked={loading} type="checkbox" onChange={this.loading} />
</label>
</p>
<div style={{ width: 300 }}>
<Select
autoFocus
value={value}
animation={useAnim ? 'slide-up' : null}
choiceTransitionName="rc-select-selection__choice-zoom"
style={{ width: 500 }}
mode="multiple"
loading={loading}
suffix={suffixIcon}
allowClear
optionFilterProp="children"
optionLabelProp="children"
onSelect={this.onSelect}
onDeselect={this.onDeselect}
placeholder="please select"
onChange={this.onChange}
onFocus={() => console.log('focus')}
onBlur={(v) => console.log('blur', v)}
tokenSeparators={[' ', ',']}
>
{children}
</Select>
</div>
<h2>multiple select with autoClearSearchValue = false</h2>
<div style={{ width: 300 }}>
<Select
value={value}
style={{ width: 500 }}
mode="multiple"
autoClearSearchValue={false}
showSearch={true}
searchValue={this.state.searchValue}
onSearch={this.setSearchValue}
optionFilterProp="children"
optionLabelProp="children"
onSelect={this.onSelect}
onDeselect={this.onDeselect}
placeholder="please select"
onChange={this.onChange}
onFocus={() => console.log('focus')}
onBlur={(v) => console.log('blur', v)}
tokenSeparators={[' ', ',']}
>
{children}
</Select>
</div>
</div>
);
}
}
export default Test;
/* eslint-enable */