1 line
7.0 KiB
JSON
1 line
7.0 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\n/* eslint-disable max-classes-per-file */\n\nimport contains from 'dom-helpers/contains';\nimport React, { cloneElement } from 'react';\nimport ReactDOM from 'react-dom';\nimport warning from 'warning';\nimport Overlay from './Overlay';\n\nvar RefHolder = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(RefHolder, _React$Component);\n\n function RefHolder() {\n return _React$Component.apply(this, arguments) || this;\n }\n\n var _proto = RefHolder.prototype;\n\n _proto.render = function render() {\n return this.props.children;\n };\n\n return RefHolder;\n}(React.Component);\n\nvar normalizeDelay = function normalizeDelay(delay) {\n return delay && typeof delay === 'object' ? delay : {\n show: delay,\n hide: delay\n };\n};\n\nvar defaultProps = {\n defaultOverlayShown: false,\n trigger: ['hover', 'focus']\n}; // eslint-disable-next-line react/no-multi-comp\n\nvar OverlayTrigger = /*#__PURE__*/function (_React$Component2) {\n _inheritsLoose(OverlayTrigger, _React$Component2);\n\n function OverlayTrigger(props, context) {\n var _this;\n\n _this = _React$Component2.call(this, props, context) || this;\n\n _this.getTarget = function () {\n return ReactDOM.findDOMNode(_this.trigger.current);\n };\n\n _this.handleShow = function () {\n clearTimeout(_this._timeout);\n _this._hoverState = 'show';\n var delay = normalizeDelay(_this.props.delay);\n\n if (!delay.show) {\n _this.show();\n\n return;\n }\n\n _this._timeout = setTimeout(function () {\n if (_this._hoverState === 'show') _this.show();\n }, delay.show);\n };\n\n _this.handleHide = function () {\n clearTimeout(_this._timeout);\n _this._hoverState = 'hide';\n var delay = normalizeDelay(_this.props.delay);\n\n if (!delay.hide) {\n _this.hide();\n\n return;\n }\n\n _this._timeout = setTimeout(function () {\n if (_this._hoverState === 'hide') _this.hide();\n }, delay.hide);\n };\n\n _this.handleFocus = function (e) {\n var _this$getChildProps = _this.getChildProps(),\n onFocus = _this$getChildProps.onFocus;\n\n _this.handleShow(e);\n\n if (onFocus) onFocus(e);\n };\n\n _this.handleBlur = function (e) {\n var _this$getChildProps2 = _this.getChildProps(),\n onBlur = _this$getChildProps2.onBlur;\n\n _this.handleHide(e);\n\n if (onBlur) onBlur(e);\n };\n\n _this.handleClick = function (e) {\n var _this$getChildProps3 = _this.getChildProps(),\n onClick = _this$getChildProps3.onClick;\n\n if (_this.state.show) _this.hide();else _this.show();\n if (onClick) onClick(e);\n };\n\n _this.handleMouseOver = function (e) {\n _this.handleMouseOverOut(_this.handleShow, e, 'fromElement');\n };\n\n _this.handleMouseOut = function (e) {\n return _this.handleMouseOverOut(_this.handleHide, e, 'toElement');\n };\n\n _this.trigger = React.createRef();\n _this.state = {\n show: !!props.defaultShow\n }; // We add aria-describedby in the case where the overlay is a role=\"tooltip\"\n // for other cases describedby isn't appropriate (e.g. a popover with inputs) so we don't add it.\n\n _this.ariaModifier = {\n enabled: true,\n order: 900,\n fn: function fn(data) {\n var popper = data.instance.popper;\n\n var target = _this.getTarget();\n\n if (!_this.state.show || !target) return data;\n var role = popper.getAttribute('role') || '';\n\n if (popper.id && role.toLowerCase() === 'tooltip') {\n target.setAttribute('aria-describedby', popper.id);\n }\n\n return data;\n }\n };\n return _this;\n }\n\n var _proto2 = OverlayTrigger.prototype;\n\n _proto2.componentWillUnmo
|