element-plus
Version:
A Component Library for Vue 3
1 lines • 9.07 kB
Source Map (JSON)
{"version":3,"file":"dialog.mjs","sources":["../../../../../../packages/components/dialog/src/dialog.ts"],"sourcesContent":["import { buildProps, definePropType, isBoolean } from '@element-plus/utils'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { teleportProps } from '@element-plus/components/teleport'\nimport {\n dialogContentProps,\n dialogContentPropsDefaults,\n} from './dialog-content'\n\nimport type { ExtractPublicPropTypes, InjectionKey, TransitionProps } from 'vue'\nimport type { DialogContentProps } from './dialog-content'\nimport type Dialog from './dialog.vue'\n\ntype DoneFn = (cancel?: boolean) => void\n\nexport type DialogBeforeCloseFn = (done: DoneFn) => void\n\nexport type DialogTransition = string | TransitionProps\n\n/**\n * @description dialog component props\n */\nexport interface DialogProps extends DialogContentProps {\n /**\n * @description whether to append Dialog itself to body. A nested Dialog should have this attribute set to `true`\n */\n appendToBody?: boolean\n /**\n * @description which element the Dialog appends to\n */\n appendTo?: string | HTMLElement\n /**\n * @description callback before Dialog closes, and it will prevent Dialog from closing, use done to close the dialog\n */\n beforeClose?: DialogBeforeCloseFn\n /**\n * @description destroy elements in Dialog when closed\n */\n destroyOnClose?: boolean\n /**\n * @description whether the Dialog can be closed by clicking the mask\n */\n closeOnClickModal?: boolean\n /**\n * @description whether the Dialog can be closed by pressing ESC\n */\n closeOnPressEscape?: boolean\n /**\n * @description whether scroll of body is disabled while Dialog is displayed\n */\n lockScroll?: boolean\n /**\n * @description whether a mask is displayed\n */\n modal?: boolean\n /**\n * @description whether the mask is penetrable\n */\n modalPenetrable?: boolean\n /**\n * @description the Time(milliseconds) before open\n */\n openDelay?: number\n /**\n * @description the Time(milliseconds) before close\n */\n closeDelay?: number\n /**\n * @description value for `margin-top` of Dialog CSS, default is 15vh\n */\n top?: string\n /**\n * @description visibility of Dialog\n */\n modelValue?: boolean\n /**\n * @description custom class names for mask\n */\n modalClass?: string\n /**\n * @description width of Dialog, default is 50%\n */\n width?: string | number\n /**\n * @description same as z-index in native CSS, z-order of dialog\n */\n zIndex?: number\n /**\n * @description trap focus within dialog\n */\n trapFocus?: boolean\n /**\n * @description header's aria-level attribute\n */\n headerAriaLevel?: string\n /**\n * @description custom transition configuration for dialog animation, it can be a string (transition name) or an object with Vue transition props\n */\n transition?: DialogTransition\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `DialogProps` instead.\n */\nexport const dialogProps = buildProps({\n ...dialogContentProps,\n /**\n * @description whether to append Dialog itself to body. A nested Dialog should have this attribute set to `true`\n */\n appendToBody: Boolean,\n /**\n * @description which element the Dialog appends to\n */\n appendTo: {\n type: teleportProps.to.type,\n default: 'body',\n },\n /**\n * @description callback before Dialog closes, and it will prevent Dialog from closing, use done to close the dialog\n */\n beforeClose: {\n type: definePropType<DialogBeforeCloseFn>(Function),\n },\n /**\n * @description destroy elements in Dialog when closed\n */\n destroyOnClose: Boolean,\n /**\n * @description whether the Dialog can be closed by clicking the mask\n */\n closeOnClickModal: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether the Dialog can be closed by pressing ESC\n */\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether scroll of body is disabled while Dialog is displayed\n */\n lockScroll: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether a mask is displayed\n */\n modal: {\n type: Boolean,\n default: true,\n },\n /**\n * @description whether the mask is penetrable\n */\n modalPenetrable: Boolean,\n /**\n * @description the Time(milliseconds) before open\n */\n openDelay: {\n type: Number,\n default: 0,\n },\n /**\n * @description the Time(milliseconds) before close\n */\n closeDelay: {\n type: Number,\n default: 0,\n },\n /**\n * @description value for `margin-top` of Dialog CSS, default is 15vh\n */\n top: {\n type: String,\n },\n /**\n * @description visibility of Dialog\n */\n modelValue: Boolean,\n /**\n * @description custom class names for mask\n */\n modalClass: String,\n /**\n * @description custom class names for header wrapper\n */\n headerClass: String,\n /**\n * @description custom class names for body wrapper\n */\n bodyClass: String,\n /**\n * @description custom class names for footer wrapper\n */\n footerClass: String,\n /**\n * @description width of Dialog, default is 50%\n */\n width: {\n type: [String, Number],\n },\n /**\n * @description same as z-index in native CSS, z-order of dialog\n */\n zIndex: {\n type: Number,\n },\n trapFocus: Boolean,\n /**\n * @description header's aria-level attribute\n */\n headerAriaLevel: {\n type: String,\n default: '2',\n },\n /**\n * @description custom transition configuration for dialog animation, it can be a string (transition name) or an object with Vue transition props\n */\n transition: {\n type: definePropType<DialogTransition>([String, Object]),\n default: undefined,\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `DialogProps` instead.\n */\nexport type DialogPropsPublic = ExtractPublicPropTypes<typeof dialogProps>\n\nexport const dialogEmits = {\n open: () => true,\n opened: () => true,\n close: () => true,\n closed: () => true,\n [UPDATE_MODEL_EVENT]: (value: boolean) => isBoolean(value),\n openAutoFocus: () => true,\n closeAutoFocus: () => true,\n}\nexport type DialogEmits = typeof dialogEmits\nexport type DialogInstance = InstanceType<typeof Dialog> & unknown\nexport interface DialogConfigContext {\n alignCenter?: boolean\n draggable?: boolean\n overflow?: boolean\n transition?: DialogTransition\n}\n\nexport const dialogContextKey: InjectionKey<DialogConfigContext> =\n Symbol('dialogContextKey')\n\nexport const dialogPropsDefaults = {\n ...dialogContentPropsDefaults,\n appendTo: 'body',\n closeOnClickModal: true,\n closeOnPressEscape: true,\n lockScroll: true,\n modal: true,\n openDelay: 0,\n closeDelay: 0,\n headerAriaLevel: '2',\n transition: undefined,\n} as const\n"],"names":[],"mappings":";;;;;;AAuGO,MAAM,cAAc,UAAA,CAAW;AAAA,EACpC,GAAG,kBAAA;AAAA;AAAA;AAAA;AAAA,EAIH,YAAA,EAAc,OAAA;AAAA;AAAA;AAAA;AAAA,EAId,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,cAAc,EAAA,CAAG,IAAA;AAAA,IACvB,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAIA,WAAA,EAAa;AAAA,IACX,IAAA,EAAM,eAAoC,QAAQ;AAAA,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