1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 | import classNames from 'classnames';
|
7 | import React from 'react';
|
8 | import PropTypes from 'prop-types';
|
9 | import isRequiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';
|
10 |
|
11 | import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
12 |
|
13 | var propTypes = {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | id: isRequiredForA11y(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
20 |
|
21 | |
22 |
|
23 |
|
24 | placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
25 |
|
26 | |
27 |
|
28 |
|
29 | positionTop: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
30 | |
31 |
|
32 |
|
33 | positionLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
34 |
|
35 | |
36 |
|
37 |
|
38 | arrowOffsetTop: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
39 | |
40 |
|
41 |
|
42 | arrowOffsetLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
43 |
|
44 | |
45 |
|
46 |
|
47 | title: PropTypes.node
|
48 | };
|
49 |
|
50 | var defaultProps = {
|
51 | placement: 'right'
|
52 | };
|
53 |
|
54 | var Popover = function (_React$Component) {
|
55 | _inherits(Popover, _React$Component);
|
56 |
|
57 | function Popover() {
|
58 | _classCallCheck(this, Popover);
|
59 |
|
60 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
61 | }
|
62 |
|
63 | Popover.prototype.render = function render() {
|
64 | var _extends2;
|
65 |
|
66 | var _props = this.props,
|
67 | placement = _props.placement,
|
68 | positionTop = _props.positionTop,
|
69 | positionLeft = _props.positionLeft,
|
70 | arrowOffsetTop = _props.arrowOffsetTop,
|
71 | arrowOffsetLeft = _props.arrowOffsetLeft,
|
72 | title = _props.title,
|
73 | className = _props.className,
|
74 | style = _props.style,
|
75 | children = _props.children,
|
76 | props = _objectWithoutProperties(_props, ['placement', 'positionTop', 'positionLeft', 'arrowOffsetTop', 'arrowOffsetLeft', 'title', 'className', 'style', 'children']);
|
77 |
|
78 | var _splitBsProps = splitBsProps(props),
|
79 | bsProps = _splitBsProps[0],
|
80 | elementProps = _splitBsProps[1];
|
81 |
|
82 | var classes = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[placement] = true, _extends2));
|
83 |
|
84 | var outerStyle = _extends({
|
85 | display: 'block',
|
86 | top: positionTop,
|
87 | left: positionLeft
|
88 | }, style);
|
89 |
|
90 | var arrowStyle = {
|
91 | top: arrowOffsetTop,
|
92 | left: arrowOffsetLeft
|
93 | };
|
94 |
|
95 | return React.createElement(
|
96 | 'div',
|
97 | _extends({}, elementProps, {
|
98 | role: 'tooltip',
|
99 | className: classNames(className, classes),
|
100 | style: outerStyle
|
101 | }),
|
102 | React.createElement('div', { className: 'arrow', style: arrowStyle }),
|
103 | title && React.createElement(
|
104 | 'h3',
|
105 | { className: prefix(bsProps, 'title') },
|
106 | title
|
107 | ),
|
108 | React.createElement(
|
109 | 'div',
|
110 | { className: prefix(bsProps, 'content') },
|
111 | children
|
112 | )
|
113 | );
|
114 | };
|
115 |
|
116 | return Popover;
|
117 | }(React.Component);
|
118 |
|
119 | Popover.propTypes = propTypes;
|
120 | Popover.defaultProps = defaultProps;
|
121 |
|
122 | export default bsClass('popover', Popover); |
\ | No newline at end of file |