Build 543408stable
Module 289726
4,452 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.r(t),n.d(t,{IGNORE_CLASS_NAME:()=>h,default:()=>E});var i,r,s=n(64700),a=n(340287);function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var u=function(){if("u">typeof window&&"function"==typeof window.addEventListener){var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}}),n=function(){};return window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t),e}},c=(void 0===i&&(i=0),function(){return++i}),d={},_={},f=["touchstart","touchmove"],h="ignore-react-onclickoutside";function p(e,t){var n={};return -1!==f.indexOf(t)&&r&&(n.passive=!e.props.preventDefault),n}let E=function(e,t){var n,i,f=e.displayName||e.name||"Component";return i=n=function(n){function i(e){var i;return(i=n.call(this,e)||this).__outsideClickHandler=function(e){if("function"==typeof i.__clickOutsideHandlerProp)return void i.__clickOutsideHandlerProp(e);var t=i.getInstance();if("function"==typeof t.props.handleClickOutside)return void t.props.handleClickOutside(e);if("function"==typeof t.handleClickOutside)return void t.handleClickOutside(e);throw Error("WrappedComponent: "+f+" lacks a handleClickOutside(event) function for processing outside click events.")},i.__getComponentNode=function(){var e=i.getInstance();return t&&"function"==typeof t.setClickOutsideRef?t.setClickOutsideRef()(e):"function"==typeof e.setClickOutsideRef?e.setClickOutsideRef():(0,a.findDOMNode)(e)},i.enableOnClickOutside=function(){if("u">typeof document&&!_[i._uid]){void 0===r&&(r=u()),_[i._uid]=!0;var e=i.props.eventTypes;e.forEach||(e=[e]),d[i._uid]=function(e){null!==i.componentNode&&!(i.initTimeStamp>e.timeStamp)&&(i.props.preventDefault&&e.preventDefault(),i.props.stopPropagation&&e.stopPropagation(),i.props.excludeScrollbar&&(document.documentElement.clientWidth<=e.clientX||document.documentElement.clientHeight<=e.clientY)||function(e,t,n){if(e===t)return!0;for(;e.parentNode||e.host;){var i;if(e.parentNode&&((i=e)===t||(i.correspondingElement?i.correspondingElement.classList.contains(n):i.classList.contains(n))))return!0;e=e.parentNode||e.host}return e}(e.composed&&e.composedPath&&e.composedPath().shift()||e.target,i.componentNode,i.props.outsideClickIgnoreClass)===document&&i.__outsideClickHandler(e))},e.forEach(function(e){document.addEventListener(e,d[i._uid],p(l(i),e))})}},i.disableOnClickOutside=function(){delete _[i._uid];var e=d[i._uid];if(e&&"u">typeof document){var t=i.props.eventTypes;t.forEach||(t=[t]),t.forEach(function(t){return document.removeEventListener(t,e,p(l(i),t))}),delete d[i._uid]}},i.getRef=function(e){return i.instanceRef=e},i._uid=c(),i.initTimeStamp=performance.now(),i}i.prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=i.prototype;return h.getInstance=function(){if(e.prototype&&!e.prototype.isReactComponent)return this;var t=this.instanceRef;return t.getInstance?t.getInstance():t},h.componentDidMount=function(){if(!("u"<typeof document)&&document.createElement){var e=this.getInstance();if(t&&"function"==typeof t.handleClickOutside&&(this.__clickOutsideHandlerProp=t.handleClickOutside(e),"function"!=typeof this.__clickOutsideHandlerProp))throw Error("WrappedComponent: "+f+" lacks a function for processing outside click events specified by the handleClickOutside config option.");this.componentNode=this.__getComponentNode(),this.props.disableOnClickOutside||this.enableOnClickOutside()}},h.componentDidUpdate=function(){this.componentNode=this.__getComponentNode()},h.componentWillUnmount=function(){this.disableOnClickOutside()},h.render=function(){var t=this.props;t.excludeScrollbar;var n=function(e,t){if(null==e)return{};var n,i,r={},s=Object.keys(e);for(i=0;i<s.length;i++)t.indexOf(n=s[i])>=0||(r[n]=e[n]);return r}(t,["excludeScrollbar"]);return e.prototype&&e.prototype.isReactComponent?n.ref=this.getRef:n.wrappedRef=this.getRef,n.disableOnClickOutside=this.disableOnClickOutside,n.enableOnClickOutside=this.enableOnClickOutside,(0,s.createElement)(e,n)},i}(s.Component),n.displayName="OnClickOutside("+f+")",n.defaultProps={eventTypes:["mousedown","touchstart"],excludeScrollbar:t&&t.excludeScrollbar||!1,outsideClickIgnoreClass:h,preventDefault:!1,stopPropagation:!1},n.getClass=function(){return e.getClass?e.getClass():e},i}}