import type { CSSProperties } from 'vue'; import { defineComponent } from 'vue'; import classNames from '../_util/classNames'; import type { PosInfo } from './hooks/useTarget'; import useId from '../_util/hooks/useId'; import Portal from '../_util/PortalWrapper'; import { someType, objectType, booleanType } from '../_util/type'; const COVER_PROPS = { fill: 'transparent', 'pointer-events': 'auto', }; export interface MaskProps { prefixCls?: string; pos: PosInfo; // 获取引导卡片指向的元素 rootClassName?: string; showMask?: boolean; style?: CSSProperties; fill?: string; open?: boolean; animated?: boolean | { placeholder: boolean }; zIndex?: number; } const Mask = defineComponent({ name: 'TourMask', props: { prefixCls: { type: String }, pos: objectType(), // 获取引导卡片指向的元素 rootClassName: { type: String }, showMask: booleanType(), fill: { type: String, default: 'rgba(0,0,0,0.5)' }, open: booleanType(), animated: someType([Boolean, Object]), zIndex: { type: Number }, }, setup(props, { attrs }) { const id = useId(); return () => { const { prefixCls, open, rootClassName, pos, showMask, fill, animated, zIndex } = props; const maskId = `${prefixCls}-mask-${id}`; const mergedAnimated = typeof animated === 'object' ? animated?.placeholder : animated; return ( open && (
{showMask ? ( {pos && ( )} {/* Block click region */} {pos && ( <> )} ) : null}
), }} /> ); }; }, }); export default Mask;