/**
 * Common part of Checkbox & Radio
 */
import Icon from '../icon';
import { FindParentMixin } from './find-parent';
export const CheckboxMixin = (parent, bem) => ({
  mixins: [FindParentMixin],
  props: {
    name: null,
    value: null,
    disabled: Boolean,
    checkedColor: String,
    labelPosition: String,
    labelDisabled: Boolean,
    shape: {
      type: String,
      default: 'round'
    },
    bindGroup: {
      type: Boolean,
      default: true
    }
  },
  created() {
    if (this.bindGroup) {
      this.findParent(parent);
    }
  },
  computed: {
    isDisabled() {
      return (this.parent && this.parent.disabled) || this.disabled;
    },
    iconStyle() {
      const { checkedColor } = this;
      if (checkedColor && this.checked && !this.isDisabled) {
        return {
          borderColor: checkedColor,
          backgroundColor: checkedColor
        };
      }
    }
  },
  render() {
    const { slots, checked } = this;
    const CheckIcon = slots('icon', { checked }) || (