Upgrade rc-rate

This commit is contained in:
Wei Zhu 2017-11-28 10:48:58 +08:00
parent 58e742d987
commit 57d80c0c70
6 changed files with 32 additions and 3 deletions

View File

@ -0,0 +1,6 @@
import Rate from '..';
import focusTest from '../../../tests/shared/focusTest';
describe('Rate', () => {
focusTest(Rate);
});

View File

@ -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) | - |

View File

@ -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} />;
}
}

View File

@ -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) | - |

View File

@ -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);
}

View File

@ -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",