import PopupMixin from "../../../es5/mixins/popup";
import mixins from "../../../es5/utils/mixins";
var CONFIRM_TEXT = '确定';
var CANCEL_TEXT = '取消';
export default mixins(PopupMixin).extend({
  name: 'w-dialog',
  props: {
    skin: {
      type: String,
      default: 'ios'
    },
    title: String,
    message: String,
    confirmButtonText: {
      type: String,
      default: CONFIRM_TEXT
    },
    cancelButtonText: {
      type: String,
      default: CANCEL_TEXT
    },
    showConfirmButton: {
      type: Boolean,
      default: true
    },
    showCancelButton: {
      type: Boolean,
      default: true
    },
    callback: Function,
    beforeClose: Function
  },
  methods: {
    handleAction: function handleAction(action) {
      var _this = this;

      if (this.beforeClose) {
        this.beforeClose(action, function (state) {
          if (state !== false) {
            _this.onClose(action);
          }
        });
      } else {
        this.onClose(action);
      }
    },
    onClose: function onClose(action) {
      this.$emit('update:visible', false);
      this.$emit(action);
      this.callback && this.callback(action);
    }
  },
  render: function render() {
    var _this2 = this;

    var h = arguments[0];
    return h("transition-group", {
      "attrs": {
        "enter-active-class": "weui-animate-fade-in",
        "leave-active-class": "weui-animate-fade-out"
      }
    }, [h("div", {
      "class": "weui-mask",
      "directives": [{
        name: "show",
        value: this.visible
      }],
      "key": "mask"
    }), h("div", {
      "class": {
        'weui-dialog': true,
        'weui-skin_android': this.skin === 'android'
      },
      "directives": [{
        name: "show",
        value: this.visible
      }],
      "key": "dialog"
    }, [this.title && h("div", {
      "class": "weui-dialog__hd"
    }, [h("strong", {
      "class": "weui-dialog__title",
      "domProps": {
        "innerHTML": this.title
      }
    })]), h("div", {
      "class": "weui-dialog__bd",
      "domProps": {
        "innerHTML": this.message
      }
    }), h("div", {
      "class": "weui-dialog__ft"
    }, [this.showCancelButton && h("div", {
      "class": "weui-dialog__btn weui-dialog__btn_default",
      "on": {
        "click": function click() {
          _this2.handleAction('cancel');
        }
      },
      "domProps": {
        "textContent": this.cancelButtonText
      }
    }), this.showConfirmButton && h("div", {
      "class": "weui-dialog__btn weui-dialog__btn_primary",
      "on": {
        "click": function click() {
          _this2.handleAction('confirm');
        }
      },
      "domProps": {
        "textContent": this.confirmButtonText
      }
    })])])]);
  }
});
//# sourceMappingURL=WDialog.js.map