MobilePopupInner.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _extends from "@babel/runtime/helpers/esm/extends";
  3. import { createVNode as _createVNode } from "vue";
  4. import { defineComponent, ref, Transition } from 'vue';
  5. import { flattenChildren } from '../../_util/props-util';
  6. import classNames from '../../_util/classNames';
  7. import { mobileProps } from './interface';
  8. export default defineComponent({
  9. compatConfig: {
  10. MODE: 3
  11. },
  12. name: 'MobilePopupInner',
  13. inheritAttrs: false,
  14. props: mobileProps,
  15. emits: ['mouseenter', 'mouseleave', 'mousedown', 'touchstart', 'align'],
  16. setup(props, _ref) {
  17. let {
  18. expose,
  19. slots
  20. } = _ref;
  21. const elementRef = ref();
  22. expose({
  23. forceAlign: () => {},
  24. getElement: () => elementRef.value
  25. });
  26. return () => {
  27. var _a;
  28. const {
  29. zIndex,
  30. visible,
  31. prefixCls,
  32. mobile: {
  33. popupClassName,
  34. popupStyle,
  35. popupMotion = {},
  36. popupRender
  37. } = {}
  38. } = props;
  39. // ======================== Render ========================
  40. const mergedStyle = _extends({
  41. zIndex
  42. }, popupStyle);
  43. let childNode = flattenChildren((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots));
  44. // Wrapper when multiple children
  45. if (childNode.length > 1) {
  46. const _childNode = function () {
  47. return childNode;
  48. }();
  49. childNode = _createVNode("div", {
  50. "class": `${prefixCls}-content`
  51. }, [childNode]);
  52. }
  53. // Mobile support additional render
  54. if (popupRender) {
  55. childNode = popupRender(childNode);
  56. }
  57. const mergedClassName = classNames(prefixCls, popupClassName);
  58. return _createVNode(Transition, _objectSpread({
  59. "ref": elementRef
  60. }, popupMotion), {
  61. default: () => [visible ? _createVNode("div", {
  62. "class": mergedClassName,
  63. "style": mergedStyle
  64. }, [childNode]) : null]
  65. });
  66. };
  67. }
  68. });