You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

import * as React from 'react';
import * as PropTypes from 'prop-types';
9 years ago
import RcRate from 'rc-rate';
import Icon from '../icon';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
9 years ago
export interface RateProps {
prefixCls?: string;
count?: number;
value?: number;
defaultValue?: number;
allowHalf?: boolean;
allowClear?: boolean;
disabled?: boolean;
onChange?: (value: number) => any;
onHoverChange?: (value: number) => any;
character?: React.ReactNode;
className?: string;
style?: React.CSSProperties;
}
export default class Rate extends React.Component<RateProps, any> {
9 years ago
static propTypes = {
prefixCls: PropTypes.string,
character: PropTypes.node,
9 years ago
};
7 years ago
static defaultProps = {
character: <Icon type="star" theme="filled" />,
9 years ago
};
7 years ago
private rcRate: any;
focus() {
this.rcRate.focus();
}
blur() {
this.rcRate.blur();
}
saveRate = (node: any) => {
this.rcRate = node;
};
7 years ago
renderRate = ({ getPrefixCls }: ConfigConsumerProps) => (
<RcRate
ref={this.saveRate}
{...this.props}
prefixCls={getPrefixCls('rate', this.props.prefixCls)}
/>
);
9 years ago
render() {
return <ConfigConsumer>{this.renderRate}</ConfigConsumer>;
9 years ago
}
}