feat: update vc-rate to 2.5.0
parent
21eed858fa
commit
f94a380aee
|
@ -0,0 +1,28 @@
|
||||||
|
import Rate from '../index';
|
||||||
|
import VcTooltip from '../../vc-tooltip/index';
|
||||||
|
import '../../vc-tooltip/assets/bootstrap_white.less';
|
||||||
|
import '../assets/index.less';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div style="margin: 100px">
|
||||||
|
<Rate
|
||||||
|
defaultValue={3}
|
||||||
|
characterRender={(node, props) => {
|
||||||
|
// console.dir(node);
|
||||||
|
// console.dir(props.index);
|
||||||
|
return (
|
||||||
|
<VcTooltip placement="top" overlay={props.index}>
|
||||||
|
{node}
|
||||||
|
</VcTooltip>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,3 +1,3 @@
|
||||||
// based on rc-rate 2.4.3
|
// based on rc-rate 2.5.0
|
||||||
import Rate from './src/';
|
import Rate from './src/';
|
||||||
export default Rate;
|
export default Rate;
|
||||||
|
|
|
@ -20,6 +20,7 @@ const rateProps = {
|
||||||
allowClear: PropTypes.bool,
|
allowClear: PropTypes.bool,
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
character: PropTypes.any,
|
character: PropTypes.any,
|
||||||
|
characterRender: PropTypes.func,
|
||||||
tabIndex: PropTypes.number,
|
tabIndex: PropTypes.number,
|
||||||
autoFocus: PropTypes.bool,
|
autoFocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -174,6 +175,7 @@ export default {
|
||||||
const stars = [];
|
const stars = [];
|
||||||
const disabledClass = disabled ? `${prefixCls}-disabled` : '';
|
const disabledClass = disabled ? `${prefixCls}-disabled` : '';
|
||||||
const character = getComponentFromProp(this, 'character');
|
const character = getComponentFromProp(this, 'character');
|
||||||
|
const characterRender = this.characterRender || this.$scopedSlots.characterRender;
|
||||||
for (let index = 0; index < count; index++) {
|
for (let index = 0; index < count; index++) {
|
||||||
const starProps = {
|
const starProps = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -184,6 +186,7 @@ export default {
|
||||||
allowHalf,
|
allowHalf,
|
||||||
value: hoverValue === undefined ? sValue : hoverValue,
|
value: hoverValue === undefined ? sValue : hoverValue,
|
||||||
character,
|
character,
|
||||||
|
characterRender,
|
||||||
focused,
|
focused,
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default {
|
||||||
allowHalf: PropTypes.bool,
|
allowHalf: PropTypes.bool,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
character: PropTypes.any,
|
character: PropTypes.any,
|
||||||
|
characterRender: PropTypes.func,
|
||||||
focused: PropTypes.bool,
|
focused: PropTypes.bool,
|
||||||
count: PropTypes.number,
|
count: PropTypes.number,
|
||||||
},
|
},
|
||||||
|
@ -52,10 +53,10 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const { onHover, onClick, onKeyDown, disabled, prefixCls, index, count, value } = this;
|
const { onHover, onClick, onKeyDown, disabled, prefixCls, characterRender, index, count, value } = this;
|
||||||
|
|
||||||
const character = getComponentFromProp(this, 'character');
|
const character = getComponentFromProp(this, 'character');
|
||||||
return (
|
let star = (
|
||||||
<li
|
<li
|
||||||
class={this.getClassName()}
|
class={this.getClassName()}
|
||||||
onClick={disabled ? noop : onClick}
|
onClick={disabled ? noop : onClick}
|
||||||
|
@ -71,5 +72,9 @@ export default {
|
||||||
<div class={`${prefixCls}-second`}>{character}</div>
|
<div class={`${prefixCls}-second`}>{character}</div>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
if (characterRender) {
|
||||||
|
star = characterRender(star, this.$props);
|
||||||
|
}
|
||||||
|
return star;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue