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 | var defaultProps = {
|
46 | placement: 'right'
|
47 | };
|
48 |
|
49 | var Tooltip = function (_React$Component) {
|
50 | _inherits(Tooltip, _React$Component);
|
51 |
|
52 | function Tooltip() {
|
53 | _classCallCheck(this, Tooltip);
|
54 |
|
55 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
56 | }
|
57 |
|
58 | Tooltip.prototype.render = function render() {
|
59 | var _extends2;
|
60 |
|
61 | var _props = this.props,
|
62 | placement = _props.placement,
|
63 | positionTop = _props.positionTop,
|
64 | positionLeft = _props.positionLeft,
|
65 | arrowOffsetTop = _props.arrowOffsetTop,
|
66 | arrowOffsetLeft = _props.arrowOffsetLeft,
|
67 | className = _props.className,
|
68 | style = _props.style,
|
69 | children = _props.children,
|
70 | props = _objectWithoutProperties(_props, ['placement', 'positionTop', 'positionLeft', 'arrowOffsetTop', 'arrowOffsetLeft', 'className', 'style', 'children']);
|
71 |
|
72 | var _splitBsProps = splitBsProps(props),
|
73 | bsProps = _splitBsProps[0],
|
74 | elementProps = _splitBsProps[1];
|
75 |
|
76 | var classes = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[placement] = true, _extends2));
|
77 |
|
78 | var outerStyle = _extends({
|
79 | top: positionTop,
|
80 | left: positionLeft
|
81 | }, style);
|
82 |
|
83 | var arrowStyle = {
|
84 | top: arrowOffsetTop,
|
85 | left: arrowOffsetLeft
|
86 | };
|
87 |
|
88 | return React.createElement(
|
89 | 'div',
|
90 | _extends({}, elementProps, {
|
91 | role: 'tooltip',
|
92 | className: classNames(className, classes),
|
93 | style: outerStyle
|
94 | }),
|
95 | React.createElement('div', { className: prefix(bsProps, 'arrow'), style: arrowStyle }),
|
96 | React.createElement(
|
97 | 'div',
|
98 | { className: prefix(bsProps, 'inner') },
|
99 | children
|
100 | )
|
101 | );
|
102 | };
|
103 |
|
104 | return Tooltip;
|
105 | }(React.Component);
|
106 |
|
107 | Tooltip.propTypes = propTypes;
|
108 | Tooltip.defaultProps = defaultProps;
|
109 |
|
110 | export default bsClass('tooltip', Tooltip); |
\ | No newline at end of file |