{"version":3,"file":"overlay.mjs","sources":["../../../../../../packages/components/overlay/src/overlay.ts"],"sourcesContent":["import { createVNode, defineComponent, h, renderSlot } from 'vue'\nimport { PatchFlags, buildProps, definePropType } from '@element-plus/utils'\nimport { useNamespace, useSameTarget } from '@element-plus/hooks'\n\nimport type { CSSProperties, ExtractPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\n\nexport const overlayProps = buildProps({\n mask: {\n type: Boolean,\n default: true,\n },\n customMaskEvent: Boolean,\n overlayClass: {\n type: definePropType>([\n String,\n Array,\n Object,\n ]),\n },\n zIndex: {\n type: definePropType([String, Number]),\n },\n} as const)\nexport type OverlayProps = ExtractPropTypes\n\nexport const overlayEmits = {\n click: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\nexport type OverlayEmits = typeof overlayEmits\n\nconst BLOCK = 'overlay'\n\nexport default defineComponent({\n name: 'ElOverlay',\n\n props: overlayProps,\n emits: overlayEmits,\n\n setup(props, { slots, emit }) {\n // No reactivity on this prop because when its rendering with a global\n // component, this will be a constant flag.\n const ns = useNamespace(BLOCK)\n\n const onMaskClick = (e: MouseEvent) => {\n emit('click', e)\n }\n\n const { onClick, onMousedown, onMouseup } = useSameTarget(\n props.customMaskEvent ? undefined : onMaskClick\n )\n\n // init here\n return () => {\n // when the vnode meets the same structure but with different change trigger\n // it will not automatically update, thus we simply use h function to manage updating\n return props.mask\n ? createVNode(\n 'div',\n {\n class: [ns.b(), props.overlayClass],\n style: {\n zIndex: props.zIndex,\n },\n onClick,\n onMousedown,\n onMouseup,\n },\n [renderSlot(slots, 'default')],\n PatchFlags.STYLE | PatchFlags.CLASS | PatchFlags.PROPS,\n ['onClick', 'onMouseup', 'onMousedown']\n )\n : h(\n 'div',\n {\n class: props.overlayClass,\n style: {\n zIndex: props.zIndex,\n position: 'fixed',\n top: '0px',\n right: '0px',\n bottom: '0px',\n left: '0px',\n } as CSSProperties,\n },\n [renderSlot(slots, 'default')]\n )\n }\n },\n})\n"],"names":[],"m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