mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
Upgrade rc-rate
This commit is contained in:
parent
58e742d987
commit
57d80c0c70
6
components/rate/__tests__/index.test.js
Normal file
6
components/rate/__tests__/index.test.js
Normal file
@ -0,0 +1,6 @@
|
||||
import Rate from '..';
|
||||
import focusTest from '../../../tests/shared/focusTest';
|
||||
|
||||
describe('Rate', () => {
|
||||
focusTest(Rate);
|
||||
});
|
@ -23,5 +23,8 @@ Rate component.
|
||||
| disabled | read only, unable to interact | boolean | false |
|
||||
| style | custom style object of rate | object | - |
|
||||
| value | current value | number | - |
|
||||
| onBlur | callback when component lose focus | Function() | - |
|
||||
| onChange | callback when select value | Function(value: number) | - |
|
||||
| onFocus | callback when component get focus | Function() | - |
|
||||
| onHoverChange | callback when hover item | Function(value: number) | - |
|
||||
| onKeyDown | callback when keydown on component | Function(event) | - |
|
||||
|
@ -22,11 +22,27 @@ export default class Rate extends React.Component<RateProps, any> {
|
||||
prefixCls: PropTypes.string,
|
||||
character: PropTypes.node,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-rate',
|
||||
character: <Icon type="star" />,
|
||||
};
|
||||
|
||||
private rcRate: any;
|
||||
|
||||
focus() {
|
||||
this.rcRate.focus();
|
||||
}
|
||||
|
||||
blur() {
|
||||
this.rcRate.blur();
|
||||
}
|
||||
|
||||
saveRate = (node: any) => {
|
||||
this.rcRate = node;
|
||||
}
|
||||
|
||||
render() {
|
||||
return <RcRate {...this.props} />;
|
||||
return <RcRate ref={this.saveRate} {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ title: Rate
|
||||
| disabled | 只读,无法进行交互 | boolean | false |
|
||||
| style | 自定义样式对象 | object | - |
|
||||
| value | 当前数,受控值 | number | - |
|
||||
| onBlur | 失去焦点时的回调 | Function() | - |
|
||||
| onChange | 选择时的回调 | Function(value: number) | - |
|
||||
| onFocus | 获取焦点时的回调 | Function() | - |
|
||||
| onHoverChange | 鼠标经过时数值变化的回调 | Function(value: number) | - |
|
||||
| onKeyDown | 按键回调 | Function(event) | - |
|
||||
|
@ -11,6 +11,7 @@
|
||||
font-size: 20px;
|
||||
display: inline-block;
|
||||
color: @rate-star-color;
|
||||
outline: none;
|
||||
|
||||
&-disabled &-star {
|
||||
cursor: not-allowed;
|
||||
@ -36,7 +37,7 @@
|
||||
color: @rate-star-bg;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
&-focused, &:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
||||
"rc-notification": "~3.0.0",
|
||||
"rc-pagination": "~1.12.4",
|
||||
"rc-progress": "~2.2.2",
|
||||
"rc-rate": "~2.2.0",
|
||||
"rc-rate": "~2.3.0",
|
||||
"rc-select": "~7.3.2",
|
||||
"rc-slider": "~8.4.0",
|
||||
"rc-steps": "~3.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user