import "../../../src/scss/actionsheet.scss";
import Vue from 'vue';
export default Vue.extend({
  name: 'w-actionsheet',
  props: {
    type: {
      type: String,
      default: 'ios'
    },
    title: String,
    actions: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    cancelText: {
      type: String,
      default: 'Cancel'
    },
    value: Boolean
  },
  data: function data() {
    return {
      currentValue: this.value
    };
  },
  watch: {
    currentValue: function currentValue(val) {
      this.$emit('input', val);
    },
    value: function value(val) {
      this.currentValue = val;
    }
  },
  methods: {
    itemClick: function itemClick(item) {
      if (item.method && typeof item.method === 'function') {
        item.method();
      }

      this.currentValue = false;
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var actionsheetMenu = h("div", {
      "class": "weui-actionsheet__menu"
    }, [this.actions.map(function (item) {
      return h("div", {
        "key": item.name,
        "class": "weui-actionsheet__cell",
        "on": {
          "click": function click() {
            return _this.itemClick(item);
          }
        },
        "domProps": {
          "textContent": item.name
        }
      });
    })]);

    var renderIos = function renderIos() {
      return h("div", [h("transition", {
        "attrs": {
          "enter-active-class": "weui-animate-fade-in",
          "leave-active-class": "weui-animate-fade-out"
        }
      }, [h("div", {
        "class": "weui-mask weui-animate-fade-in",
        "directives": [{
          name: "show",
          value: _this.currentValue
        }],
        "on": {
          "click": function click() {
            _this.currentValue = false;
          }
        }
      })]), h("transition", {
        "attrs": {
          "enter-active-class": "weui-animate-slide-up",
          "leave-active-class": "weui-animate-slide-down"
        }
      }, [h("div", {
        "class": "weui-actionsheet weui-actionsheet_toggle",
        "directives": [{
          name: "show",
          value: _this.currentValue
        }]
      }, [_this.title && h("div", {
        "class": "weui-actionsheet__title"
      }, [h("p", {
        "class": "weui-actionsheet__title-text",
        "domProps": {
          "innerHTML": _this.title
        }
      })]), actionsheetMenu, _this.cancelText && h("div", {
        "class": "weui-actionsheet__action"
      }, [h("div", {
        "class": "weui-actionsheet__cell",
        "on": {
          "click": function click() {
            _this.currentValue = false;
          }
        },
        "domProps": {
          "innerHTML": _this.cancelText
        }
      })])])])]);
    };

    var renderAndroid = function renderAndroid() {
      return h("transition", {
        "attrs": {
          "enter-active-class": "weui-animate-fade-in",
          "leave-active-class": "weui-animate-fade-out"
        }
      }, [h("div", {
        "class": "weui-skin_android",
        "directives": [{
          name: "show",
          value: _this.currentValue
        }]
      }, [h("div", {
        "class": "weui-mask",
        "on": {
          "click": function click() {
            _this.currentValue = false;
          }
        }
      }), h("div", {
        "class": "weui-actionsheet"
      }, [actionsheetMenu])])]);
    };

    return this.type === 'ios' ? renderIos() : renderAndroid();
  }
});
//# sourceMappingURL=WActionsheet.js.map