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.
ant-design-vue/components/rate/index.jsx

56 lines
1.2 KiB

import PropTypes from '../_util/vue-types';
import { initDefaultProps, getOptionProps, getComponentFromProp } from '../_util/props-util';
import VcRate from '../vc-rate';
import Icon from '../icon';
7 years ago
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,
autoFocus: PropTypes.bool,
};
7 years ago
const Rate = {
name: 'ARate',
7 years ago
model: {
prop: 'value',
event: 'change',
},
props: initDefaultProps(RateProps, {
prefixCls: 'ant-rate',
}),
methods: {
focus() {
this.$refs.refRate.focus();
7 years ago
},
blur() {
this.$refs.refRate.blur();
7 years ago
},
},
render() {
const character = getComponentFromProp(this, 'character') || (
<Icon type="star" theme="filled" />
);
7 years ago
const rateProps = {
props: {
character,
...getOptionProps(this),
7 years ago
},
on: this.$listeners,
ref: 'refRate',
};
return <VcRate {...rateProps} />;
7 years ago
},
};
7 years ago
/* istanbul ignore next */
Rate.install = function(Vue) {
Vue.component(Rate.name, Rate);
};
export default Rate;