docs: Document AutoComplete[onSearch]

Related: #5610
This commit is contained in:
Wei Zhu 2017-04-13 11:11:24 +08:00
parent 9ef7b23b53
commit dfaa647950
6 changed files with 10 additions and 8 deletions

View File

@ -25,7 +25,7 @@ class Complete extends React.Component {
dataSource: [],
}
handleChange = (value) => {
handleSearch = (value) => {
this.setState({
dataSource: !value ? [] : [
value,
@ -46,7 +46,7 @@ class Complete extends React.Component {
dataSource={dataSource}
style={{ width: 200, height: 50 }}
onSelect={onSelect}
onChange={this.handleChange}
onSearch={this.handleSearch}
placeholder="input here"
>
<textarea onKeyPress={this.handleKeyPress} style={{ height: 50 }} />

View File

@ -25,7 +25,7 @@ class Complete extends React.Component {
dataSource: [],
}
handleChange = (value) => {
handleSearch = (value) => {
this.setState({
dataSource: !value ? [] : [
value,
@ -42,7 +42,7 @@ class Complete extends React.Component {
dataSource={dataSource}
style={{ width: 200 }}
onSelect={onSelect}
onChange={this.handleChange}
onSearch={this.handleSearch}
placeholder="input here"
/>
);

View File

@ -23,7 +23,7 @@ class Complete extends React.Component {
result: [],
}
handleChange = (value) => {
handleSearch = (value) => {
let result;
if (!value || value.indexOf('@') >= 0) {
result = [];
@ -41,7 +41,7 @@ class Complete extends React.Component {
return (
<AutoComplete
style={{ width: 200 }}
onChange={this.handleChange}
onSearch={this.handleSearch}
placeholder="input here"
>
{children}

View File

@ -57,7 +57,7 @@ class Complete extends React.Component {
dataSource: [],
}
handleChange = (value) => {
handleSearch = (value) => {
this.setState({
dataSource: value ? searchResult(value) : [],
});
@ -73,7 +73,7 @@ class Complete extends React.Component {
style={{ width: '100%' }}
dataSource={dataSource.map(renderOption)}
onSelect={onSelect}
onChange={this.handleChange}
onSearch={this.handleSearch}
placeholder="input here"
optionLabelProp="text"
>

View File

@ -26,6 +26,7 @@ const dataSource = ['12345', '23456', '34567'];
| allowClear | Show clear button, effective in multiple mode only. | boolean | false |
| onChange | Called when select an option or input value change, or value of input is changed | function(value, label) | - |
| onSelect | Called when a option is selected. param is option's value and option instance. | function(value, option) | - |
| onSearch | Called when searching items. | function(value) | - |
| disabled | Whether disabled select | boolean | false |
| defaultActiveFirstOption | Whether active first option by default | boolean | true |
| placeholder | placeholder of input | string | - |

View File

@ -27,6 +27,7 @@ const dataSource = ['12345', '23456', '34567'];
| allowClear | 支持清除, 单选模式有效 | boolean | false |
| onChange | 选中 option或 input 的 value 变化时,调用此函数 | function(value) | 无 |
| onSelect | 被选中时调用,参数为选中项的 value 值 | function(value, option) | 无 |
| onSearch | 搜索补全项的时候调用 | function(value) | 无 |
| disabled | 是否禁用 | boolean | false |
| defaultActiveFirstOption | 是否默认高亮第一个选项。 | boolean | true
| placeholder | 输入框提示 | string | - |