You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2 rivejä
4.4 KiB

  1. !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";function o(e,t,n){return e===t||(e.correspondingElement?e.correspondingElement.classList.contains(n):e.classList.contains(n))}function i(e,t){var n=null;return-1!==l.indexOf(t)&&r&&(n={passive:!e.props.preventDefault}),n}var r,c=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}},s=function(e){return void 0===e&&(e=0),function(){return++e}}(),u={},d={},l=["touchstart","touchmove"],a="ignore-react-onclickoutside";e.IGNORE_CLASS_NAME=a,e.default=function(e,l){var p,f,O=e.displayName||e.name||"Component";return f=p=function(a){function p(e){var t;return t=a.call(this,e)||this,t.__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: "+O+" lacks a handleClickOutside(event) function for processing outside click events.");n.handleClickOutside(e)}else n.props.handleClickOutside(e)}else t.__clickOutsideHandlerProp(e)},t.__getComponentNode=function(){var e=t.getInstance();return l&&"function"==typeof l.setClickOutsideRef?l.setClickOutsideRef()(e):"function"==typeof e.setClickOutsideRef?e.setClickOutsideRef():n.findDOMNode(e)},t.enableOnClickOutside=function(){if("undefined"!=typeof document&&!d[t._uid]){void 0===r&&(r=c()),d[t._uid]=!0;var e=t.props.eventTypes;e.forEach||(e=[e]),u[t._uid]=function(e){null===t.componentNode||(t.props.preventDefault&&e.preventDefault(),t.props.stopPropagation&&e.stopPropagation(),t.props.excludeScrollbar&&function(e){return document.documentElement.clientWidth<=e.clientX||document.documentElement.clientHeight<=e.clientY}(e))||function(e,t,n){if(e===t)return!0;for(;e.parentNode;){if(o(e,t,n))return!0;e=e.parentNode}return e}(e.target,t.componentNode,t.props.outsideClickIgnoreClass)===document&&t.__outsideClickHandler(e)},e.forEach(function(e){document.addEventListener(e,u[t._uid],i(t,e))})}},t.disableOnClickOutside=function(){delete d[t._uid];var e=u[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,i(t,n))}),delete u[t._uid]}},t.getRef=function(e){return t.instanceRef=e},t._uid=s(),t}!function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}(p,a);var f=p.prototype;return f.getInstance=function(){if(!e.prototype.isReactComponent)return this;var t=this.instanceRef;return t.getInstance?t.getInstance():t},f.componentDidMount=function(){if("undefined"!=typeof document&&document.createElement){var e=this.getInstance();if(l&&"function"==typeof l.handleClickOutside&&(this.__clickOutsideHandlerProp=l.handleClickOutside(e),"function"!=typeof this.__clickOutsideHandlerProp))throw Error("WrappedComponent: "+O+" lacks a function for processing outside click events specified by the handleClickOutside config option.");this.componentNode=this.__getComponentNode(),this.props.disableOnClickOutside||this.enableOnClickOutside()}},f.componentDidUpdate=function(){this.componentNode=this.__getComponentNode()},f.componentWillUnmount=function(){this.disableOnClickOutside()},f.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)},p}(t.Component),p.displayName="OnClickOutside("+O+")",p.defaultProps={eventTypes:["mousedown","touchstart"],excludeScrollbar:l&&l.excludeScrollbar||!1,outsideClickIgnoreClass:a,preventDefault:!1,stopPropagation:!1},p.getClass=function(){return e.getClass?e.getClass():e},f},Object.defineProperty(e,"__esModule",{value:!0})});