UNPKG

@uiw/react-popover

Version:

Popover component

66 lines 2.4 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; var _excluded = ["prefixCls", "className", "content", "visibleArrow"]; import React from 'react'; import OverlayTrigger from '@uiw/react-overlay-trigger'; import Confirm from './Confirm'; import "./style/index.css"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export default class Popover extends React.Component { constructor() { super(...arguments); this.renderArrow = () => { var { prefixCls } = this.props; return /*#__PURE__*/_jsx("div", { className: prefixCls + "-arrow", children: /*#__PURE__*/_jsxs("svg", { viewBox: "0 0 30 30", children: [/*#__PURE__*/_jsx("path", { fillOpacity: "0.2", d: "M8.11 6.302c1.015-.936 1.887-2.922 1.887-4.297v26c0-1.378-.868-3.357-1.888-4.297L.925 17.09c-1.237-1.14-1.233-3.034 0-4.17L8.11 6.302z" }), /*#__PURE__*/_jsx("path", { fill: "#fff", d: "M8.787 7.036c1.22-1.125 2.21-3.376 2.21-5.03V0v30-2.005c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z" })] }) }); }; } render() { var _this$props = this.props, { prefixCls, className, visibleArrow } = _this$props, other = _objectWithoutPropertiesLoose(_this$props, _excluded); var cls = [prefixCls, className, !visibleArrow ? 'no-arrow' : null].filter(Boolean).join(' ').trim(); return /*#__PURE__*/_jsx(OverlayTrigger, _extends({}, other, { overlay: /*#__PURE__*/_jsxs("div", { className: cls, children: [visibleArrow && this.renderArrow(), /*#__PURE__*/_jsx("div", { className: prefixCls + "-inner", children: this.props.content })] }), children: typeof this.props.children === 'object' && this.props.children.type.name !== 'Icon' ? this.props.children : /*#__PURE__*/_jsx("span", { style: { display: 'block', writingMode: 'vertical-rl' }, children: this.props.children }) })); } } Popover.Confirm = Confirm; Popover.defaultProps = { prefixCls: 'w-popover', placement: 'top', usePortal: true, isOpen: false, visibleArrow: true };