UNPKG

@talend/react-bootstrap

Version:

Bootstrap 3 components built with React

83 lines 2.4 kB
import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import isRequiredForA11y from 'prop-types-extra/lib/isRequiredForA11y'; import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const propTypes = { /** * An html id attribute, necessary for accessibility * @type {string|number} * @required */ id: isRequiredForA11y(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), /** * Sets the direction the Tooltip is positioned towards. */ placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']), /** * The "top" position value for the Tooltip. */ positionTop: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** * The "left" position value for the Tooltip. */ positionLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** * The "top" position value for the Tooltip arrow. */ arrowOffsetTop: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** * The "left" position value for the Tooltip arrow. */ arrowOffsetLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }; const defaultProps = { placement: 'right' }; class Tooltip extends React.Component { render() { const { placement, positionTop, positionLeft, arrowOffsetTop, arrowOffsetLeft, className, style, children, ...props } = this.props; const [bsProps, elementProps] = splitBsProps(props); const classes = { ...getClassSet(bsProps), [placement]: true }; const outerStyle = { top: positionTop, left: positionLeft, ...style }; const arrowStyle = { top: arrowOffsetTop, left: arrowOffsetLeft }; return /*#__PURE__*/_jsxs("div", { ...elementProps, role: "tooltip", className: classNames(className, classes), style: outerStyle, children: [/*#__PURE__*/_jsx("div", { className: prefix(bsProps, 'arrow'), style: arrowStyle }), /*#__PURE__*/_jsx("div", { className: prefix(bsProps, 'inner'), children: children })] }); } } Tooltip.propTypes = propTypes; Tooltip.defaultProps = defaultProps; export default bsClass('tooltip', Tooltip); //# sourceMappingURL=Tooltip.js.map