2019-09-20 11:19:59 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
|
2017-11-09 07:58:53 +00:00
|
|
|
export default {
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'ACheckableTag',
|
2017-11-09 07:58:53 +00:00
|
|
|
model: {
|
|
|
|
prop: 'checked',
|
|
|
|
},
|
|
|
|
props: {
|
2019-09-20 11:19:59 +00:00
|
|
|
prefixCls: PropTypes.string,
|
2017-11-09 07:58:53 +00:00
|
|
|
checked: Boolean,
|
|
|
|
},
|
2019-09-20 11:19:59 +00:00
|
|
|
inject: {
|
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
|
|
|
},
|
2017-11-09 07:58:53 +00:00
|
|
|
computed: {
|
2019-01-12 03:33:27 +00:00
|
|
|
classes() {
|
2019-09-20 11:19:59 +00:00
|
|
|
const { checked, prefixCls: customizePrefixCls } = this;
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const prefixCls = getPrefixCls('tag', customizePrefixCls);
|
2017-11-09 07:58:53 +00:00
|
|
|
return {
|
|
|
|
[`${prefixCls}`]: true,
|
|
|
|
[`${prefixCls}-checkable`]: true,
|
|
|
|
[`${prefixCls}-checkable-checked`]: checked,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2017-11-09 07:58:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
handleClick() {
|
|
|
|
const { checked } = this;
|
|
|
|
this.$emit('input', !checked);
|
|
|
|
this.$emit('change', !checked);
|
2017-11-09 07:58:53 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
|
|
|
const { classes, handleClick, $slots } = this;
|
2018-03-19 01:43:31 +00:00
|
|
|
return (
|
|
|
|
<div class={classes} onClick={handleClick}>
|
|
|
|
{$slots.default}
|
|
|
|
</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-03-19 01:43:31 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|