'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _checkbox = require('../mixins/checkbox');

exports['default'] = {
    name: 'SnRadio',

    mixins: [(0, _checkbox.CheckboxMixin)({
        role: 'radio',
        parent: 'snRadio'
    })],

    computed: {
        currentValue: {
            get: function get() {
                return this.parent ? this.parent.value : this.value;
            },
            set: function set(val) {
                (this.parent || this).$emit('input', val);
            }
        },

        checked: function checked() {
            return this.currentValue === this.name;
        }
    },

    methods: {
        toggle: function toggle() {
            if (this.currentValue === this.name) {
                this.currentValue = '';
            } else {
                this.currentValue = this.name;
            }
        }
    }
};
module.exports = exports.default;