forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ant-design#4732 from ant-design/feature-2.7
antd 2.7 features
- Loading branch information
Showing
91 changed files
with
1,917 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import AutoComplete from '..'; | ||
|
||
describe('AutoComplete with Custom Input Element Render', () => { | ||
it('AutoComplete with custom Input render perfectly', () => { | ||
const wrapper = mount( | ||
<AutoComplete dataSource={['12345', '23456', '34567']}> | ||
<textarea /> | ||
</AutoComplete> | ||
); | ||
|
||
expect(wrapper.find('textarea').length).toBe(1); | ||
wrapper.find('textarea').simulate('change', { target: { value: '123' } }); | ||
const dropdownWrapper = mount(wrapper.find('Trigger').node.getComponent()); | ||
|
||
expect(dropdownWrapper.find('MenuItem').length).toBe(1); | ||
expect(dropdownWrapper.find('MenuItem').props().value).toBe('12345'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
order: 3 | ||
title: | ||
zh-CN: 自定义输入组件 | ||
en-US: Customize Input Component | ||
--- | ||
|
||
## zh-CN | ||
|
||
自定义输入组件。 | ||
|
||
## en-US | ||
|
||
Customize Input Component | ||
|
||
````__react | ||
import { AutoComplete } from 'antd'; | ||
function onSelect(value) { | ||
console.log('onSelect', value); | ||
} | ||
const Complete = React.createClass({ | ||
getInitialState() { | ||
return { | ||
dataSource: [], | ||
}; | ||
}, | ||
handleChange(value) { | ||
this.setState({ | ||
dataSource: !value ? [] : [ | ||
value, | ||
value + value, | ||
value + value + value, | ||
], | ||
}); | ||
}, | ||
handleKeyPress(ev) { | ||
console.log('handleKeyPress', ev); | ||
}, | ||
render() { | ||
const { dataSource } = this.state; | ||
return ( | ||
<AutoComplete | ||
dataSource={dataSource} | ||
style={{ width: 200 }} | ||
onSelect={onSelect} | ||
onChange={this.handleChange} | ||
placeholder="input here" | ||
> | ||
<textarea onKeyPress={this.handleKeyPress} /> | ||
</AutoComplete> | ||
); | ||
}, | ||
}); | ||
ReactDOM.render(<Complete />, mountNode); | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@import "../../style/themes/default"; | ||
@import "../../style/mixins/index"; | ||
@import "../../input/style/mixin"; | ||
|
||
@input-prefix-cls: ~"@{ant-prefix}-input"; | ||
@select-prefix-cls: ~"@{ant-prefix}-select"; | ||
@autocomplete-prefix-cls: ~"@{select-prefix-cls}-auto-complete"; | ||
|
||
.@{autocomplete-prefix-cls}.@{select-prefix-cls} { | ||
|
||
.@{select-prefix-cls} { | ||
&-search--inline { | ||
position: relative; | ||
} | ||
&-selection { | ||
border: 0; | ||
&--single { | ||
height: auto; | ||
} | ||
&__rendered { | ||
margin-left: 0; | ||
margin-right: 0; | ||
line-height: 0; | ||
} | ||
&__placeholder { | ||
margin-left: 8px; | ||
margin-right: 8px; | ||
top: 12px; | ||
} | ||
} | ||
} | ||
|
||
.@{input-prefix-cls} { | ||
border: 1px solid @border-color-base; | ||
&:focus, | ||
&:hover { | ||
.hover; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.