2 lines
5.7 KiB
JavaScript
2 lines
5.7 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("create-react-context"),require("deep-equal"),require("popper.js"),require("warning")):"function"==typeof define&&define.amd?define(["exports","react","create-react-context","deep-equal","popper.js","warning"],t):t(e.ReactPopper={},e.React,null,null,e.Popper,null)}(this,function(e,r,t,n,p,a){"use strict";function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n,p=p&&p.hasOwnProperty("default")?p.default:p,a=a&&a.hasOwnProperty("default")?a.default:a;var l=t(),d=t(),o=function(o){function e(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return i(u(t=o.call.apply(o,[this].concat(n))||this),"referenceNode",void 0),i(u(t),"setReferenceNode",function(e){e&&t.referenceNode!==e&&(t.referenceNode=e,t.forceUpdate())}),t}c(e,o);var t=e.prototype;return t.componentWillUnmount=function(){this.referenceNode=null},t.render=function(){return r.createElement(l.Provider,{value:this.referenceNode},r.createElement(d.Provider,{value:this.setReferenceNode},this.props.children))},e}(r.Component),f=function(e){return Array.isArray(e)?e[0]:e},h=function(e){if("function"==typeof e){for(var t=arguments.length,n=new Array(1<t?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.apply(void 0,n)}},m=function(e,t){if("function"==typeof e)return h(e,t);null!=e&&(e.current=t)},y={position:"absolute",top:0,left:0,opacity:0,pointerEvents:"none"},v={},w=function(o){function e(){for(var n,e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i(u(n=o.call.apply(o,[this].concat(t))||this),"state",{data:void 0,placement:void 0}),i(u(n),"popperInstance",void 0),i(u(n),"popperNode",null),i(u(n),"arrowNode",null),i(u(n),"setPopperNode",function(e){e&&n.popperNode!==e&&(m(n.props.innerRef,e),n.popperNode=e,n.updatePopperInstance())}),i(u(n),"setArrowNode",function(e){n.arrowNode=e}),i(u(n),"updateStateModifier",{enabled:!0,order:900,fn:function(e){var t=e.placement;return n.setState({data:e,placement:t}),e}}),i(u(n),"getOptions",function(){return{placement:n.props.placement,eventsEnabled:n.props.eventsEnabled,positionFixed:n.props.positionFixed,modifiers:s({},n.props.modifiers,{arrow:s({},n.props.modifiers&&n.props.modifiers.arrow,{enabled:!!n.arrowNode,element:n.arrowNode}),applyStyle:{enabled:!1},updateStateModifier:n.updateStateModifier})}}),i(u(n),"getPopperStyle",function(){return n.popperNode&&n.state.data?s({position:n.state.data.offsets.popper.position},n.state.data.styles):y}),i(u(n),"getPopperPlacement",function(){return n.state.data?n.state.placement:void 0}),i(u(n),"getArrowStyle",function(){return n.arrowNode&&n.state.data?n.state.data.arrowStyles:v}),i(u(n),"getOutOfBoundariesState",function(){return n.state.data?n.state.data.hide:void 0}),i(u(n),"destroyPopperInstance",function(){n.popperInstance&&(n.popperInstance.destroy(),n.popperInstance=null)}),i(u(n),"updatePopperInstance",function(){n.destroyPopperInstance();var e=u(n).popperNode,t=n.props.referenceElement;t&&e&&(n.popperInstance=new p(t,e,n.getOptions()))}),i(u(n),"scheduleUpdate",function(){n.popperInstance&&n.popperInstance.scheduleUpdate()}),n}c(e,o);var t=e.prototype;return t.componentDidUpdate=function(e,t){this.props.placement===e.placement&&this.props.referenceElement===e.referenceElement&&this.props.positionFixed===e.positionFixed&&n(this.props.modifiers,e.modifiers,{strict:!0})?this.props.eventsEnabled!==e.eventsEnabled&&this.popperInstance&&(this.props.eventsEnabled?this.popperInstance.enableEventListeners():this.popperInstance.disableEventListeners()):this.updatePopperInstance(),t.placement!==this.state.placement&&this.scheduleUpdate()},t.componentWillUnmount=function(){m(this.props.innerRef,null),this.destroyPopperInstance()},t.render=function(){return f(this.props.children)({ref:this.setPopperNode,style:this.getPopperStyle(),placement:this.getPopperPlacement(),outOfBoundaries:this.getOutOfBoundariesState(),scheduleUpdate:this.scheduleUpdate,arrowProps:{ref:this.setArrowNode,style:this.getArrowStyle()}})},e}(r.Component);i(w,"defaultProps",{placement:"bottom",eventsEnabled:!0,referenceElement:void 0,positionFixed:!1});var P=p.placements;var b=function(o){function e(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return i(u(t=o.call.apply(o,[this].concat(n))||this),"refHandler",function(e){m(t.props.innerRef,e),h(t.props.setReferenceNode,e)}),t}c(e,o);var t=e.prototype;return t.componentWillUnmount=function(){m(this.props.innerRef,null)},t.render=function(){return a(Boolean(this.props.setReferenceNode),"`Reference` should not be used outside of a `Manager` component."),f(this.props.children)({ref:this.refHandler})},e}(r.Component);e.Popper=function(e){var t=e.referenceElement,n=function(e,t){if(null==e)return{};var n,r,o={},p=Object.keys(e);for(r=0;r<p.length;r++)n=p[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,["referenceElement"]);return r.createElement(l.Consumer,null,function(e){return r.createElement(w,s({referenceElement:void 0!==t?t:e},n))})},e.placements=P,e.Manager=o,e.Reference=function(t){return r.createElement(d.Consumer,null,function(e){return r.createElement(b,s({setReferenceNode:e},t))})},Object.defineProperty(e,"__esModule",{value:!0})});
|