UNPKG

1.26 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import { useBootstrapPrefix, useIsRTL } from './ThemeProvider';
4import { getOverlayDirection } from './helpers';
5import { jsx as _jsx } from "react/jsx-runtime";
6import { jsxs as _jsxs } from "react/jsx-runtime";
7const defaultProps = {
8 placement: 'right'
9};
10const Tooltip = /*#__PURE__*/React.forwardRef(({
11 bsPrefix,
12 placement,
13 className,
14 style,
15 children,
16 arrowProps,
17 popper: _,
18 show: _2,
19 ...props
20}, ref) => {
21 bsPrefix = useBootstrapPrefix(bsPrefix, 'tooltip');
22 const isRTL = useIsRTL();
23 const [primaryPlacement] = (placement == null ? void 0 : placement.split('-')) || [];
24 const bsDirection = getOverlayDirection(primaryPlacement, isRTL);
25 return /*#__PURE__*/_jsxs("div", {
26 ref: ref,
27 style: style,
28 role: "tooltip",
29 "x-placement": primaryPlacement,
30 className: classNames(className, bsPrefix, `bs-tooltip-${bsDirection}`),
31 ...props,
32 children: [/*#__PURE__*/_jsx("div", {
33 className: "tooltip-arrow",
34 ...arrowProps
35 }), /*#__PURE__*/_jsx("div", {
36 className: `${bsPrefix}-inner`,
37 children: children
38 })]
39 });
40});
41Tooltip.defaultProps = defaultProps;
42Tooltip.displayName = 'Tooltip';
43export default Tooltip;
\No newline at end of file