import type { CSSProperties } from 'vue'; import { defineComponent, ref, Transition } from 'vue'; import { flattenChildren } from '../../_util/props-util'; import classNames from '../../_util/classNames'; import type { MobilePopupProps } from './interface'; import { mobileProps } from './interface'; export default defineComponent({ name: 'MobilePopupInner', inheritAttrs: false, props: mobileProps, emits: ['mouseenter', 'mouseleave', 'mousedown', 'touchstart', 'align'], setup(props, { expose, slots }) { const elementRef = ref(); expose({ forceAlign: () => {}, getElement: () => elementRef.value, }); return () => { const { zIndex, visible, prefixCls, mobile: { popupClassName, popupStyle, popupMotion = {}, popupRender } = {}, } = props as MobilePopupProps; // ======================== Render ======================== const mergedStyle: CSSProperties = { zIndex, ...popupStyle, }; let childNode: any = flattenChildren(slots.default?.()); // Wrapper when multiple children if (childNode.length > 1) { childNode =
{childNode}
; } // Mobile support additional render if (popupRender) { childNode = popupRender(childNode); } const mergedClassName = classNames(prefixCls, popupClassName); return ( {visible ? (
{childNode}
) : null}
); }; }, });