2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2017-05-09 13:40:33 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2016-03-30 13:20:03 +08:00
|
|
|
import RcRate from 'rc-rate';
|
2017-02-21 14:44:13 +08:00
|
|
|
import Icon from '../icon';
|
2016-03-30 13:20:03 +08:00
|
|
|
|
2016-08-10 09:46:56 +08:00
|
|
|
export interface RateProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
count?: number;
|
|
|
|
value?: number;
|
|
|
|
defaultValue?: number;
|
|
|
|
allowHalf?: boolean;
|
2017-12-15 15:30:38 +08:00
|
|
|
allowClear?: boolean;
|
2016-08-10 09:46:56 +08:00
|
|
|
disabled?: boolean;
|
|
|
|
onChange?: (value: number) => any;
|
2017-02-21 14:44:13 +08:00
|
|
|
onHoverChange?: (value: number) => any;
|
2017-03-06 14:23:38 +08:00
|
|
|
character?: React.ReactNode;
|
2017-02-21 14:44:13 +08:00
|
|
|
className?: string;
|
|
|
|
style?: React.CSSProperties;
|
2016-08-10 09:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class Rate extends React.Component<RateProps, any> {
|
2016-03-30 13:20:03 +08:00
|
|
|
static propTypes = {
|
|
|
|
prefixCls: PropTypes.string,
|
2017-03-06 14:23:38 +08:00
|
|
|
character: PropTypes.node,
|
2016-03-30 13:20:03 +08:00
|
|
|
};
|
2017-11-28 10:48:58 +08:00
|
|
|
|
2016-03-31 14:43:38 +08:00
|
|
|
static defaultProps = {
|
2016-03-30 13:20:03 +08:00
|
|
|
prefixCls: 'ant-rate',
|
2017-03-06 14:23:38 +08:00
|
|
|
character: <Icon type="star" />,
|
2016-03-30 13:20:03 +08:00
|
|
|
};
|
2017-11-28 10:48:58 +08:00
|
|
|
|
|
|
|
private rcRate: any;
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
this.rcRate.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
blur() {
|
|
|
|
this.rcRate.blur();
|
|
|
|
}
|
|
|
|
|
|
|
|
saveRate = (node: any) => {
|
|
|
|
this.rcRate = node;
|
|
|
|
}
|
|
|
|
|
2016-03-30 13:20:03 +08:00
|
|
|
render() {
|
2017-11-28 10:48:58 +08:00
|
|
|
return <RcRate ref={this.saveRate} {...this.props} />;
|
2016-03-30 13:20:03 +08:00
|
|
|
}
|
|
|
|
}
|