2022-03-01 23:43:50 +08:00
|
|
|
import { buildProps, definePropType, isBoolean } from '@element-plus/utils'
|
2022-02-09 16:59:08 +08:00
|
|
|
import { UPDATE_MODEL_EVENT } from '@element-plus/constants'
|
2022-02-22 12:49:28 +08:00
|
|
|
import { dialogContentProps } from './dialog-content'
|
|
|
|
|
2022-02-09 16:59:08 +08:00
|
|
|
import type { ExtractPropTypes } from 'vue'
|
2021-09-13 12:01:37 +08:00
|
|
|
|
2022-03-01 23:43:50 +08:00
|
|
|
type DoneFn = (cancel: boolean) => void
|
|
|
|
export type DialogBeforeCloseFn = (done: DoneFn) => void
|
|
|
|
|
2021-10-06 19:56:24 +08:00
|
|
|
export const dialogProps = buildProps({
|
2022-02-22 12:49:28 +08:00
|
|
|
...dialogContentProps,
|
2021-09-13 12:01:37 +08:00
|
|
|
appendToBody: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-10-06 19:56:24 +08:00
|
|
|
beforeClose: {
|
2022-03-01 23:43:50 +08:00
|
|
|
type: definePropType<DialogBeforeCloseFn>(Function),
|
2021-10-06 19:56:24 +08:00
|
|
|
},
|
2021-09-13 12:01:37 +08:00
|
|
|
destroyOnClose: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
closeOnClickModal: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
closeOnPressEscape: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
lockScroll: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
modal: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
openDelay: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
closeDelay: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
top: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
modelValue: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
modalClass: String,
|
2021-10-06 19:56:24 +08:00
|
|
|
width: {
|
2021-09-13 12:01:37 +08:00
|
|
|
type: [String, Number],
|
2021-10-06 19:56:24 +08:00
|
|
|
},
|
2021-09-13 12:01:37 +08:00
|
|
|
zIndex: {
|
|
|
|
type: Number,
|
|
|
|
},
|
2022-03-01 00:45:42 +08:00
|
|
|
trapFocus: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-10-06 19:56:24 +08:00
|
|
|
} as const)
|
2022-02-22 12:49:28 +08:00
|
|
|
|
2021-09-13 12:01:37 +08:00
|
|
|
export type DialogProps = ExtractPropTypes<typeof dialogProps>
|
|
|
|
|
|
|
|
export const dialogEmits = {
|
2021-09-13 13:19:06 +08:00
|
|
|
open: () => true,
|
|
|
|
opened: () => true,
|
|
|
|
close: () => true,
|
|
|
|
closed: () => true,
|
2022-03-01 23:43:50 +08:00
|
|
|
[UPDATE_MODEL_EVENT]: (value: boolean) => isBoolean(value),
|
2022-02-22 12:49:28 +08:00
|
|
|
openAutoFocus: () => true,
|
|
|
|
closeAutoFocus: () => true,
|
2021-09-13 12:01:37 +08:00
|
|
|
}
|
|
|
|
export type DialogEmits = typeof dialogEmits
|