diff --git a/src/dialog/Dialog.js b/src/dialog/Dialog.js
index 75777458f..379795117 100644
--- a/src/dialog/Dialog.js
+++ b/src/dialog/Dialog.js
@@ -1,25 +1,32 @@
+import { reactive } from 'vue';
+
// Utils
import { createNamespace, addUnit, pick } from '../utils';
import { BORDER_TOP, BORDER_LEFT } from '../utils/constant';
// Components
-import Popup from '../popup';
+import Popup, { popupSharedProps } from '../popup';
import Button from '../button';
import ActionBar from '../action-bar';
import ActionBarButton from '../action-bar-button';
const [createComponent, bem, t] = createNamespace('dialog');
+const popupKeys = [
+ ...Object.keys(popupSharedProps),
+ 'transition',
+ 'closeOnPopstate',
+];
+
export default createComponent({
props: {
- show: Boolean,
+ ...popupSharedProps,
title: String,
theme: String,
width: [Number, String],
message: String,
- className: null,
callback: Function,
- lazyRender: Boolean,
+ className: null,
beforeClose: Function,
messageAlign: String,
showCancelButton: Boolean,
@@ -28,10 +35,6 @@ export default createComponent({
confirmButtonText: String,
confirmButtonColor: String,
closeOnClickOverlay: Boolean,
- overlay: {
- type: Boolean,
- default: true,
- },
allowHtml: {
type: Boolean,
default: true,
@@ -52,180 +55,160 @@ export default createComponent({
emits: ['confirm', 'cancel', 'update:show'],
- data() {
- return {
- loading: {
- confirm: false,
- cancel: false,
- },
+ setup(props, { emit, slots }) {
+ const loading = reactive({
+ confirm: false,
+ cancel: false,
+ });
+
+ const onUpdateShow = (value) => {
+ emit('update:show', value);
};
- },
- methods: {
- onClickOverlay() {
- this.handleAction('overlay');
- },
+ const close = (action) => {
+ onUpdateShow(false);
+ if (props.callback) {
+ props.callback(action);
+ }
+ };
- handleAction(action) {
- this.$emit(action);
-
- // show not trigger close event when hidden
- if (!this.show) {
+ const handleAction = (action) => {
+ // should not trigger close event when hidden
+ if (!props.show) {
return;
}
- if (this.beforeClose) {
- this.loading[action] = true;
- this.beforeClose(action, (state) => {
- if (state !== false && this.loading[action]) {
- this.onClose(action);
- }
+ emit(action);
- this.loading.confirm = false;
- this.loading.cancel = false;
+ if (props.beforeClose) {
+ loading[action] = true;
+ props.beforeClose(action, (result) => {
+ if (result !== false && loading[action]) {
+ close(action);
+ }
+ loading[action] = false;
});
} else {
- this.onClose(action);
+ close(action);
}
- },
-
- onClose(action) {
- this.onUpdateShow(false);
-
- if (this.callback) {
- this.callback(action);
- }
- },
-
- onUpdateShow(value) {
- this.$emit('update:show', value);
- },
-
- genRoundButtons() {
- return (
-