import Vue from 'vue';
import "../../../src/scss/radio.scss";
export default Vue.extend({
  name: 'w-radio',
  props: {
    title: String,
    align: {
      type: String,
      default: 'left'
    },
    options: {
      type: Array,
      required: true
    },
    value: null
  },
  data: function data() {
    return {
      internalValue: this.value
    };
  },
  watch: {
    internalValue: function internalValue(val) {
      this.$emit('input', val);
      this.$emit('change', val);
    },
    value: function value(val) {
      this.internalValue = val;
    }
  },
  methods: {
    onClick: function onClick(option) {
      if (option.disabled) {
        return;
      }

      this.internalValue = option.value || option;
    },
    isChecked: function isChecked(option) {
      return typeof option === 'string' ? this.internalValue === option : this.internalValue === option.value;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("div", [this.title && h("div", {
      "class": "weui-cells__title",
      "domProps": {
        "innerHTML": this.title
      }
    }), h("div", {
      "class": "weui-cells weui-cells_radio"
    }, [this.options.map(function (option) {
      return h("label", {
        "key": option.label || option,
        "class": {
          'weui-cell': true,
          'weui-check__label': true,
          'weui-check__label-disabled': option.disabled
        },
        "on": {
          "click": function click() {
            _this.onClick(option);
          }
        }
      }, [h("div", {
        "class": "weui-cell__bd"
      }, [h("p", {
        "domProps": {
          "textContent": option.label || option
        }
      })]), h("div", {
        "class": "weui-cell__ft"
      }, [_this.isChecked(option) && h("span", {
        "class": "weui-icon-checked"
      })])]);
    })])]);
  }
});
//# sourceMappingURL=WRadio.js.map