2018-03-21 07:45:01 +00:00
|
|
|
|
|
|
|
import PropTypes from '../_util/vue-types'
|
2018-12-10 14:38:49 +00:00
|
|
|
import { initDefaultProps, getOptionProps, getComponentFromProp } from '../_util/props-util'
|
2018-03-21 07:45:01 +00:00
|
|
|
import VcRate from '../vc-rate'
|
|
|
|
import Icon from '../icon'
|
|
|
|
|
|
|
|
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,
|
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: {
|
|
|
|
focus () {
|
|
|
|
this.$refs.refRate.focus()
|
|
|
|
},
|
|
|
|
blur () {
|
|
|
|
this.$refs.refRate.blur()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
render () {
|
2018-12-10 14:38:49 +00:00
|
|
|
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',
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<VcRate
|
|
|
|
{...rateProps}
|
2018-12-10 14:38:49 +00:00
|
|
|
/>
|
2018-03-21 07:45:01 +00:00
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
/* istanbul ignore next */
|
|
|
|
Rate.install = function (Vue) {
|
|
|
|
Vue.component(Rate.name, Rate)
|
|
|
|
}
|
|
|
|
export default Rate
|