pbplus-member-ui
Version:
User interface of PBPlus member plugin.
2 lines (1 loc) • 4.29 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t(e.onClickOutside={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";var o=function(){if("undefined"!=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}};var i,r,c=(void 0===i&&(i=0),function(){return++i}),s={},d={},u=["touchstart","touchmove"],a="ignore-react-onclickoutside";function l(e,t){var n=null;return-1!==u.indexOf(t)&&r&&(n={passive:!e.props.preventDefault}),n}e.IGNORE_CLASS_NAME=a,e.default=function(e,i){var u,p;return p=u=function(u){var a,p;function f(e){var t;return(t=u.call(this,e)||this).__outsideClickHandler=function(e){if("function"!=typeof t.__clickOutsideHandlerProp){var n=t.getInstance();if("function"!=typeof n.props.handleClickOutside){if("function"!=typeof n.handleClickOutside)throw Error("WrappedComponent lacks a handleClickOutside(event) function for processing outside click events.");n.handleClickOutside(e)}else n.props.handleClickOutside(e)}else t.__clickOutsideHandlerProp(e)},t.enableOnClickOutside=function(){if("undefined"!=typeof document&&!d[t._uid]){void 0===r&&(r=o()),d[t._uid]=!0;var e=t.props.eventTypes;e.forEach||(e=[e]),s[t._uid]=function(e){var n;t.props.disableOnClickOutside||null!==t.componentNode&&(t.props.preventDefault&&e.preventDefault(),t.props.stopPropagation&&e.stopPropagation(),(!t.props.excludeScrollbar||(n=e,document.documentElement.clientWidth>n.clientX&&document.documentElement.clientHeight>n.clientY))&&function(e,t,n){if(e===t)return!0;for(;e.parentNode;){if(i=n,(o=e)===t||(o.correspondingElement?o.correspondingElement.classList.contains(i):o.classList.contains(i)))return!0;e=e.parentNode}var o,i;return e}(e.target,t.componentNode,t.props.outsideClickIgnoreClass)===document&&t.__outsideClickHandler(e))},e.forEach(function(e){document.addEventListener(e,s[t._uid],l(t,e))})}},t.disableOnClickOutside=function(){delete d[t._uid];var e=s[t._uid];if(e&&"undefined"!=typeof document){var n=t.props.eventTypes;n.forEach||(n=[n]),n.forEach(function(n){return document.removeEventListener(n,e,l(t,n))}),delete s[t._uid]}},t.getRef=function(e){return t.instanceRef=e},t._uid=c(),t}(a=f).prototype=Object.create((p=u).prototype),a.prototype.constructor=a,a.__proto__=p;var O=f.prototype;return O.getInstance=function(){if(!e.prototype.isReactComponent)return this;var t=this.instanceRef;return t.getInstance?t.getInstance():t},O.componentDidMount=function(){if("undefined"!=typeof document&&document.createElement){var e=this.getInstance();if(i&&"function"==typeof i.handleClickOutside&&(this.__clickOutsideHandlerProp=i.handleClickOutside(e),"function"!=typeof this.__clickOutsideHandlerProp))throw Error("WrappedComponent lacks a function for processing outside click events specified by the handleClickOutside config option.");this.componentNode=n.findDOMNode(this.getInstance()),this.enableOnClickOutside()}},O.componentDidUpdate=function(){this.componentNode=n.findDOMNode(this.getInstance())},O.componentWillUnmount=function(){this.disableOnClickOutside()},O.render=function(){var n=this.props,o=function(e,t){if(null==e)return{};var n,o,i={},r=Object.keys(e);for(o=0;r.length>o;o++)0>t.indexOf(n=r[o])&&(i[n]=e[n]);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(o=0;c.length>o;o++)0>t.indexOf(n=c[o])&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(n,["excludeScrollbar"]);return e.prototype.isReactComponent?o.ref=this.getRef:o.wrappedRef=this.getRef,o.disableOnClickOutside=this.disableOnClickOutside,o.enableOnClickOutside=this.enableOnClickOutside,t.createElement(e,o)},f}(t.Component),u.displayName="OnClickOutside("+(e.displayName||e.name||"Component")+")",u.defaultProps={eventTypes:["mousedown","touchstart"],excludeScrollbar:i&&i.excludeScrollbar||!1,outsideClickIgnoreClass:a,preventDefault:!1,stopPropagation:!1},u.getClass=function(){return e.getClass?e.getClass():e},p},Object.defineProperty(e,"__esModule",{value:!0})});