index.js 1.64 KB
Newer Older
liang ce committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
import _extends from 'babel-runtime/helpers/extends';
import Tooltip from '../tooltip';
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
import PropTypes from '../_util/vue-types';
import { getOptionProps, getComponentFromProp } from '../_util/props-util';

var props = abstractTooltipProps();
var Popover = {
  name: 'APopover',
  props: _extends({}, props, {
    prefixCls: PropTypes.string.def('ant-popover'),
    transitionName: PropTypes.string.def('zoom-big'),
    content: PropTypes.any,
    title: PropTypes.any
  }),
  model: {
    prop: 'visible',
    event: 'visibleChange'
  },
  methods: {
    getPopupDomNode: function getPopupDomNode() {
      return this.$refs.tooltip.getPopupDomNode();
    }
  },

  render: function render() {
    var h = arguments[0];
    var title = this.title,
        prefixCls = this.prefixCls,
        $slots = this.$slots;

    var props = getOptionProps(this);
    delete props.title;
    delete props.content;
    var tooltipProps = {
      props: _extends({}, props),
      ref: 'tooltip',
      on: this.$listeners
    };
    return h(
      Tooltip,
      tooltipProps,
      [h(
        'template',
        { slot: 'title' },
        [h('div', [(title || $slots.title) && h(
          'div',
          { 'class': prefixCls + '-title' },
          [getComponentFromProp(this, 'title')]
        ), h(
          'div',
          { 'class': prefixCls + '-inner-content' },
          [getComponentFromProp(this, 'content')]
        )])]
      ), this.$slots['default']]
    );
  }
};

/* istanbul ignore next */
Popover.install = function (Vue) {
  Vue.component(Popover.name, Popover);
};

export default Popover;