UNPKG

ifui

Version:

90 lines (74 loc) 3.44 kB
'use strict'; exports.__esModule = true; var _create = require('../utils/create'); var _create2 = _interopRequireDefault(_create); var _button = require('../button'); var _button2 = _interopRequireDefault(_button); var _popup = require('../mixins/popup'); var _popup2 = _interopRequireDefault(_popup); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = (0, _create2.default)({ render: function render() { var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('transition', { attrs: { "name": "ifu-dialog-bounce" } }, [_c('div', { directives: [{ name: "show", rawName: "v-show", value: _vm.value, expression: "value" }], class: [_vm.b(), _vm.className] }, [_vm.title ? _c('div', { class: _vm.b('header', { isolated: !_vm.message && !_vm.$slots.default }), domProps: { "textContent": _vm._s(_vm.title) } }) : _vm._e(), _vm.message || _vm.$slots.default ? _c('div', { class: _vm.b('content') }, [_vm._t("default", [_vm.message ? _c('div', { class: _vm.b('message', { 'has-title': _vm.title }), domProps: { "innerHTML": _vm._s(_vm.message) } }) : _vm._e()])], 2) : _vm._e(), _c('div', { staticClass: "ifu-hairline--top", class: _vm.b('footer', { 'buttons': _vm.showCancelButton && _vm.showConfirmButton }) }, [_c('ifu-button', { directives: [{ name: "show", rawName: "v-show", value: _vm.showCancelButton, expression: "showCancelButton" }], class: _vm.b('cancel'), attrs: { "loading": _vm.loading.cancel, "size": "large" }, on: { "click": function click($event) { _vm.handleAction('cancel'); } } }, [_vm._v("\n " + _vm._s(_vm.cancelButtonText || _vm.$t('cancel')) + "\n ")]), _c('ifu-button', { directives: [{ name: "show", rawName: "v-show", value: _vm.showConfirmButton, expression: "showConfirmButton" }], class: [_vm.b('confirm'), { 'ifu-hairline--left': _vm.showCancelButton && _vm.showConfirmButton }], attrs: { "size": "large", "loading": _vm.loading.confirm }, on: { "click": function click($event) { _vm.handleAction('confirm'); } } }, [_vm._v("\n " + _vm._s(_vm.confirmButtonText || _vm.$t('confirm')) + "\n ")])], 1)])]); }, name: 'dialog', components: { ifuButton: _button2.default }, mixins: [_popup2.default], props: { title: String, message: String, callback: Function, className: [String, Object, Array], beforeClose: Function, confirmButtonText: String, cancelButtonText: String, showCancelButton: Boolean, showConfirmButton: { type: Boolean, default: true }, overlay: { type: Boolean, default: true }, closeOnClickOverlay: { type: Boolean, default: false } }, data: function data() { return { loading: { confirm: false, cancel: false } }; }, methods: { handleAction: function handleAction(action) { var _this = this; if (this.beforeClose) { this.loading[action] = true; this.beforeClose(action, function (state) { if (state !== false) { _this.onClose(action); } _this.loading[action] = false; }); } else { this.onClose(action); } }, onClose: function onClose(action) { this.$emit('input', false); this.$emit(action); this.callback && this.callback(action); } } });