2019-01-12 03:33:27 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import { initDefaultProps, getOptionProps, getComponentFromProp } from '../_util/props-util';
|
|
|
|
import VcRate from '../vc-rate';
|
|
|
|
import Icon from '../icon';
|
2018-03-21 07:45:01 +00:00
|
|
|
|
|
|
|
export const RateProps = {
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
count: PropTypes.number,
|
|
|
|
value: PropTypes.value,
|
|
|
|
defaultValue: PropTypes.value,
|
|
|
|
allowHalf: PropTypes.bool,
|
|
|
|
allowClear: PropTypes.bool,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
character: PropTypes.any,
|
2018-06-06 02:46:54 +00:00
|
|
|
autoFocus: PropTypes.bool,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-21 07:45:01 +00:00
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
const Rate = {
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'ARate',
|
2018-03-21 07:45:01 +00:00
|
|
|
model: {
|
|
|
|
prop: 'value',
|
|
|
|
event: 'change',
|
|
|
|
},
|
|
|
|
props: initDefaultProps(RateProps, {
|
|
|
|
prefixCls: 'ant-rate',
|
|
|
|
}),
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
focus() {
|
|
|
|
this.$refs.refRate.focus();
|
2018-03-21 07:45:01 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
blur() {
|
|
|
|
this.$refs.refRate.blur();
|
2018-03-21 07:45:01 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
|
|
|
const character = getComponentFromProp(this, 'character') || (
|
|
|
|
<Icon type="star" theme="filled" />
|
|
|
|
);
|
2018-03-21 07:45:01 +00:00
|
|
|
const rateProps = {
|
|
|
|
props: {
|
|
|
|
character,
|
2018-12-10 14:38:49 +00:00
|
|
|
...getOptionProps(this),
|
2018-03-21 07:45:01 +00:00
|
|
|
},
|
|
|
|
on: this.$listeners,
|
|
|
|
ref: 'refRate',
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return <VcRate {...rateProps} />;
|
2018-03-21 07:45:01 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-21 07:45:01 +00:00
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
/* istanbul ignore next */
|
2019-01-12 03:33:27 +00:00
|
|
|
Rate.install = function(Vue) {
|
|
|
|
Vue.component(Rate.name, Rate);
|
|
|
|
};
|
|
|
|
export default Rate;
|