all files / packages/radio/src/ radio.vue

50% Statements 6/12
22.22% Branches 4/18
20% Functions 1/5
25% Lines 2/8
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                                                                                                                                   
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
 
import findParent from 'src/mixins/findParent';
 
export default {
  name: 'zan-radio',
 
  mixins: [findParent],
 
  props: {
    disabled: Boolean,
    value: {},
    name: [String, Number]
  },
 
  computed: {
    isGroup() {
      return !!this.findParentByComponentName('zan-radio-group');
    },
 
    currentValue: {
      get() {
        return this.isGroup && this.parentGroup ? this.parentGroup.value : this.value;
      },
 
      set(val) {
        if (this.isGroup && this.parentGroup) {
          this.parentGroup.$emit('input', val);
        } else {
          this.$emit('input', val);
        }
      }
    },
 
    isDisabled() {
      return this.isGroup && this.parentGroup
          ? this.parentGroup.disabled || this.disabled
          : this.disabled;
    }
  }
};