Socket
Socket
Sign inDemoInstall

reactjs-popup

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-popup - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

1

index.d.ts

@@ -10,2 +10,3 @@ declare module 'reactjs-popup' {

open?: boolean;
disabled?: boolean;
defaultOpen?: boolean;

@@ -12,0 +13,0 @@ on?: EventType | EventType[];

2

package.json
{
"name": "reactjs-popup",
"version": "1.3.0",
"version": "1.3.1",
"description": "React Popup Component - Modals,Tooltips and Menus —  All in one",

@@ -5,0 +5,0 @@ "main": "reactjs-popup.cjs.js",

/*!
* reactjs-popup v1.3.0
* reactjs-popup v1.3.1
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>

@@ -73,4 +73,9 @@ * Released under the MIT License.

_setPrototypeOf(subClass.prototype, superClass && superClass.prototype);
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);

@@ -80,6 +85,5 @@ }

function _getPrototypeOf(o) {
_getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) {
return o.__proto__;
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);

@@ -312,2 +316,4 @@ }

function (_React$PureComponent) {
_inherits(Popup, _React$PureComponent);
function Popup(props) {

@@ -320,15 +326,23 @@ var _this;

_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
isOpen: _this.props.open || _this.props.defaultOpen,
modal: _this.props.modal ? true : !_this.props.trigger // we create this modal state because the popup can't be a tooltip if the trigger prop doesn't exist
}), "lockScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lockScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "hidden";
}), "resetScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "resetScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "auto";
}), "togglePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "togglePopup", function () {
if (_this.state.isOpen) _this.closePopup();else _this.openPopup();
}), "openPopup", function () {
if (_this.state.isOpen) return;
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openPopup", function () {
if (_this.state.isOpen || _this.props.disabled) return;
_this.setState({

@@ -343,3 +357,5 @@ isOpen: true

});
}), "closePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closePopup", function () {
if (!_this.state.isOpen) return;

@@ -354,3 +370,5 @@

});
}), "onMouseEnter", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseEnter", function () {
clearTimeout(_this.timeOut);

@@ -361,3 +379,5 @@ var mouseEnterDelay = _this.props.mouseEnterDelay;

}, mouseEnterDelay);
}), "onMouseLeave", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseLeave", function () {
clearTimeout(_this.timeOut);

@@ -368,3 +388,5 @@ var mouseLeaveDelay = _this.props.mouseLeaveDelay;

}, mouseLeaveDelay);
}), "getTooltipBoundary", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTooltipBoundary", function () {
var keepTooltipInside = _this.props.keepTooltipInside;

@@ -389,3 +411,5 @@ var boundingBox = {

return boundingBox;
}), "setPosition", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setPosition", function () {
var _this$props = _this.props,

@@ -428,3 +452,5 @@ arrow = _this$props.arrow,

if (window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "static" || window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "") _this.TriggerEl.style.position = "relative";
}), "addWarperAction", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addWarperAction", function () {
var _this$props2 = _this.props,

@@ -451,3 +477,5 @@ contentStyle = _this$props2.contentStyle,

return childrenElementProps;
}), "renderTrigger", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTrigger", function () {
var triggerProps = {

@@ -480,3 +508,5 @@ key: "T"

return React.cloneElement(trigger, triggerProps);
}), "renderContent", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderContent", function () {
var _this$props4 = _this.props,

@@ -537,2 +567,9 @@ arrow = _this$props4.arrow,

}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.disabled !== this.props.disabled && this.props.disabled && this.state.isOpen) {
this.closePopup();
}
}
}, {
key: "componentWillUnmount",

@@ -573,4 +610,2 @@ value: function componentWillUnmount() {

_inherits(Popup, _React$PureComponent);
return Popup;

@@ -588,2 +623,3 @@ }(React.PureComponent);

open: false,
disabled: false,
closeOnDocumentClick: true,

@@ -618,2 +654,3 @@ closeOnEscape: true,

closeOnDocumentClick: PropTypes.bool,
disabled: PropTypes.bool,
lockScroll: PropTypes.bool,

@@ -640,6 +677,8 @@ offsetX: PropTypes.number,

function (_React$PureComponent2) {
function Ref(props) {
_inherits(Ref, _React$PureComponent2);
function Ref() {
_classCallCheck(this, Ref);
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, props));
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).apply(this, arguments));
}

@@ -661,4 +700,2 @@

_inherits(Ref, _React$PureComponent2);
return Ref;

@@ -665,0 +702,0 @@ }(React.PureComponent);

/*!
* reactjs-popup v1.3.0
* reactjs-popup v1.3.1
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>

@@ -69,4 +69,9 @@ * Released under the MIT License.

_setPrototypeOf(subClass.prototype, superClass && superClass.prototype);
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);

@@ -76,6 +81,5 @@ }

function _getPrototypeOf(o) {
_getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) {
return o.__proto__;
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);

@@ -308,2 +312,4 @@ }

function (_React$PureComponent) {
_inherits(Popup, _React$PureComponent);
function Popup(props) {

@@ -316,15 +322,23 @@ var _this;

_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
isOpen: _this.props.open || _this.props.defaultOpen,
modal: _this.props.modal ? true : !_this.props.trigger // we create this modal state because the popup can't be a tooltip if the trigger prop doesn't exist
}), "lockScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lockScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "hidden";
}), "resetScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "resetScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "auto";
}), "togglePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "togglePopup", function () {
if (_this.state.isOpen) _this.closePopup();else _this.openPopup();
}), "openPopup", function () {
if (_this.state.isOpen) return;
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openPopup", function () {
if (_this.state.isOpen || _this.props.disabled) return;
_this.setState({

@@ -339,3 +353,5 @@ isOpen: true

});
}), "closePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closePopup", function () {
if (!_this.state.isOpen) return;

@@ -350,3 +366,5 @@

});
}), "onMouseEnter", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseEnter", function () {
clearTimeout(_this.timeOut);

@@ -357,3 +375,5 @@ var mouseEnterDelay = _this.props.mouseEnterDelay;

}, mouseEnterDelay);
}), "onMouseLeave", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseLeave", function () {
clearTimeout(_this.timeOut);

@@ -364,3 +384,5 @@ var mouseLeaveDelay = _this.props.mouseLeaveDelay;

}, mouseLeaveDelay);
}), "getTooltipBoundary", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTooltipBoundary", function () {
var keepTooltipInside = _this.props.keepTooltipInside;

@@ -385,3 +407,5 @@ var boundingBox = {

return boundingBox;
}), "setPosition", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setPosition", function () {
var _this$props = _this.props,

@@ -424,3 +448,5 @@ arrow = _this$props.arrow,

if (window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "static" || window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "") _this.TriggerEl.style.position = "relative";
}), "addWarperAction", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addWarperAction", function () {
var _this$props2 = _this.props,

@@ -447,3 +473,5 @@ contentStyle = _this$props2.contentStyle,

return childrenElementProps;
}), "renderTrigger", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTrigger", function () {
var triggerProps = {

@@ -476,3 +504,5 @@ key: "T"

return React.cloneElement(trigger, triggerProps);
}), "renderContent", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderContent", function () {
var _this$props4 = _this.props,

@@ -533,2 +563,9 @@ arrow = _this$props4.arrow,

}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.disabled !== this.props.disabled && this.props.disabled && this.state.isOpen) {
this.closePopup();
}
}
}, {
key: "componentWillUnmount",

@@ -569,4 +606,2 @@ value: function componentWillUnmount() {

_inherits(Popup, _React$PureComponent);
return Popup;

@@ -584,2 +619,3 @@ }(React.PureComponent);

open: false,
disabled: false,
closeOnDocumentClick: true,

@@ -614,2 +650,3 @@ closeOnEscape: true,

closeOnDocumentClick: PropTypes.bool,
disabled: PropTypes.bool,
lockScroll: PropTypes.bool,

@@ -636,6 +673,8 @@ offsetX: PropTypes.number,

function (_React$PureComponent2) {
function Ref(props) {
_inherits(Ref, _React$PureComponent2);
function Ref() {
_classCallCheck(this, Ref);
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, props));
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).apply(this, arguments));
}

@@ -657,4 +696,2 @@

_inherits(Ref, _React$PureComponent2);
return Ref;

@@ -661,0 +698,0 @@ }(React.PureComponent);

/*!
* reactjs-popup v1.3.0
* reactjs-popup v1.3.1
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>

@@ -74,4 +74,9 @@ * Released under the MIT License.

_setPrototypeOf(subClass.prototype, superClass && superClass.prototype);
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);

@@ -81,6 +86,5 @@ }

function _getPrototypeOf(o) {
_getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) {
return o.__proto__;
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);

@@ -313,2 +317,4 @@ }

function (_React$PureComponent) {
_inherits(Popup, _React$PureComponent);
function Popup(props) {

@@ -321,15 +327,23 @@ var _this;

_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
isOpen: _this.props.open || _this.props.defaultOpen,
modal: _this.props.modal ? true : !_this.props.trigger // we create this modal state because the popup can't be a tooltip if the trigger prop doesn't exist
}), "lockScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lockScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "hidden";
}), "resetScroll", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "resetScroll", function () {
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "auto";
}), "togglePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "togglePopup", function () {
if (_this.state.isOpen) _this.closePopup();else _this.openPopup();
}), "openPopup", function () {
if (_this.state.isOpen) return;
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openPopup", function () {
if (_this.state.isOpen || _this.props.disabled) return;
_this.setState({

@@ -344,3 +358,5 @@ isOpen: true

});
}), "closePopup", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closePopup", function () {
if (!_this.state.isOpen) return;

@@ -355,3 +371,5 @@

});
}), "onMouseEnter", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseEnter", function () {
clearTimeout(_this.timeOut);

@@ -362,3 +380,5 @@ var mouseEnterDelay = _this.props.mouseEnterDelay;

}, mouseEnterDelay);
}), "onMouseLeave", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseLeave", function () {
clearTimeout(_this.timeOut);

@@ -369,3 +389,5 @@ var mouseLeaveDelay = _this.props.mouseLeaveDelay;

}, mouseLeaveDelay);
}), "getTooltipBoundary", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTooltipBoundary", function () {
var keepTooltipInside = _this.props.keepTooltipInside;

@@ -390,3 +412,5 @@ var boundingBox = {

return boundingBox;
}), "setPosition", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setPosition", function () {
var _this$props = _this.props,

@@ -429,3 +453,5 @@ arrow = _this$props.arrow,

if (window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "static" || window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "") _this.TriggerEl.style.position = "relative";
}), "addWarperAction", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addWarperAction", function () {
var _this$props2 = _this.props,

@@ -452,3 +478,5 @@ contentStyle = _this$props2.contentStyle,

return childrenElementProps;
}), "renderTrigger", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTrigger", function () {
var triggerProps = {

@@ -481,3 +509,5 @@ key: "T"

return React.cloneElement(trigger, triggerProps);
}), "renderContent", function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderContent", function () {
var _this$props4 = _this.props,

@@ -538,2 +568,9 @@ arrow = _this$props4.arrow,

}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.disabled !== this.props.disabled && this.props.disabled && this.state.isOpen) {
this.closePopup();
}
}
}, {
key: "componentWillUnmount",

@@ -574,4 +611,2 @@ value: function componentWillUnmount() {

_inherits(Popup, _React$PureComponent);
return Popup;

@@ -589,2 +624,3 @@ }(React.PureComponent);

open: false,
disabled: false,
closeOnDocumentClick: true,

@@ -619,2 +655,3 @@ closeOnEscape: true,

closeOnDocumentClick: PropTypes.bool,
disabled: PropTypes.bool,
lockScroll: PropTypes.bool,

@@ -641,6 +678,8 @@ offsetX: PropTypes.number,

function (_React$PureComponent2) {
function Ref(props) {
_inherits(Ref, _React$PureComponent2);
function Ref() {
_classCallCheck(this, Ref);
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, props));
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).apply(this, arguments));
}

@@ -662,4 +701,2 @@

_inherits(Ref, _React$PureComponent2);
return Ref;

@@ -666,0 +703,0 @@ }(React.PureComponent);

/*!
* reactjs-popup v1.3.0
* reactjs-popup v1.3.1
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.reactjsPopup=t(e.React,e.reactDom)}(this,function(e,t){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function i(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");a(e.prototype,t&&t.prototype),t&&a(e,t)}function l(e){return(l=Object.getPrototypeOf||function(e){return e.__proto__})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function f(e){return function(e){if(Array.isArray(e)){for(var t=0,o=new Array(e.length);t<e.length;t++)o[t]=e[t];return o}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function d(e,t,o,n,r){var i=r.offsetX,p=r.offsetY,s=n?8:0,l=o.split(" "),a=e.top+e.height/2,u=e.left+e.width/2,c=t.height,f=t.width,d=a-c/2,h=u-f/2,g="",m="0%",y="0%";switch(l[0]){case"top":d-=c/2+e.height/2+s,g="rotate(45deg)",m="100%",y="50%";break;case"bottom":d+=c/2+e.height/2+s,g="rotate(225deg)",y="50%";break;case"left":h-=f/2+e.width/2+s,g=" rotate(-45deg)",y="100%",m="50%";break;case"right":h+=f/2+e.width/2+s,g="rotate(135deg)",m="50%"}switch(l[1]){case"top":d=e.top,m=e.height/2+"px";break;case"bottom":d=e.top-c+e.height,m=c-e.height/2+"px";break;case"left":h=e.left,y=e.width/2+"px";break;case"right":h=e.left-f+e.width,y=f-e.width/2+"px"}return{top:d="top"===l[0]?d-p:d+p,left:h="left"===l[0]?h-i:h+i,transform:g,arrowLeft:y,arrowTop:m}}var h={popupContent:{tooltip:{position:"absolute",zIndex:"2",width:"200px",background:"rgb(255, 255, 255)",border:"1px solid rgb(187, 187, 187)",boxShadow:"rgba(0, 0, 0, 0.2) 0px 1px 3px",padding:"5px"},modal:{position:"relative",background:"rgb(255, 255, 255)",width:"50%",margin:"auto",border:"1px solid rgb(187, 187, 187)",padding:"5px"}},popupArrow:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(45deg)",margin:"-5px",zIndex:"-1",boxShadow:"rgba(0, 0, 0, 0.2) 1px 1px 1px"},overlay:{tooltip:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0"},modal:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",background:"rgba(0, 0, 0,0.5)",display:"flex",zIndex:"999"}}},g=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],m=function(t){function n(t){var r;return o(this,n),i(i(i(i(i(i(i(i(i(i(i(i(i(u(u(r=c(this,l(n).call(this,t)))),"state",{isOpen:r.props.open||r.props.defaultOpen,modal:!!r.props.modal||!r.props.trigger}),"lockScroll",function(){r.state.modal&&r.props.lockScroll&&(document.getElementsByTagName("body")[0].style.overflow="hidden")}),"resetScroll",function(){r.state.modal&&r.props.lockScroll&&(document.getElementsByTagName("body")[0].style.overflow="auto")}),"togglePopup",function(){r.state.isOpen?r.closePopup():r.openPopup()}),"openPopup",function(){r.state.isOpen||r.setState({isOpen:!0},function(){r.setPosition(),r.props.onOpen(),r.lockScroll()})}),"closePopup",function(){r.state.isOpen&&(r.props.onClose(),r.setState({isOpen:!1},function(){r.resetScroll()}))}),"onMouseEnter",function(){clearTimeout(r.timeOut);var e=r.props.mouseEnterDelay;r.timeOut=setTimeout(function(){return r.openPopup()},e)}),"onMouseLeave",function(){clearTimeout(r.timeOut);var e=r.props.mouseLeaveDelay;r.timeOut=setTimeout(function(){return r.closePopup()},e)}),"getTooltipBoundary",function(){var e=r.props.keepTooltipInside,t={top:0,left:0,width:window.innerWidth,height:window.innerHeight};"string"==typeof e&&(t=document.querySelector(e).getBoundingClientRect());return t}),"setPosition",function(){var e=r.props,t=e.arrow,o=e.position,n=e.offsetX,i=e.offsetY,p=e.keepTooltipInside,s=e.arrowStyle;if(!r.state.modal){var l=r.HelperEl.getBoundingClientRect(),a=r.TriggerEl.getBoundingClientRect(),u=r.ContentEl.getBoundingClientRect(),c=r.getTooltipBoundary(),h=Array.isArray(o)?o:[o];(p||Array.isArray(o))&&(h=f(h).concat(g));var m=function(e,t,o,n,r,i){for(var p,s=r.offsetX,l=r.offsetY,a=0;a<o.length;){var u={top:(p=d(e,t,o[a],n,{offsetX:s,offsetY:l})).top,left:p.left,width:t.width,height:t.height};if(!(u.top<=i.top||u.left<=i.left||u.top+u.height>=i.top+i.height||u.left+u.width>=i.left+i.width))break;a++}return p}(a,u,h,t,{offsetX:n,offsetY:i},c);r.ContentEl.style.top=m.top-l.top+"px",r.ContentEl.style.left=m.left-l.left+"px",t&&(r.ArrowEl.style.transform=m.transform,r.ArrowEl.style["-ms-transform"]=m.transform,r.ArrowEl.style["-webkit-transform"]=m.transform,r.ArrowEl.style.top=s.top||m.arrowTop,r.ArrowEl.style.left=s.left||m.arrowLeft),"static"!=window.getComputedStyle(r.TriggerEl,null).getPropertyValue("position")&&""!=window.getComputedStyle(r.TriggerEl,null).getPropertyValue("position")||(r.TriggerEl.style.position="relative")}}),"addWarperAction",function(){var e=r.props,t=e.contentStyle,o=e.className,n=e.on,i=r.state.modal,p=i?h.popupContent.modal:h.popupContent.tooltip,s={className:"popup-content ".concat(o),style:Object.assign({},p,t),ref:r.setContentRef,onClick:function(e){e.stopPropagation()}};return!i&&n.indexOf("hover")>=0&&(s.onMouseEnter=r.onMouseEnter,s.onMouseLeave=r.onMouseLeave),s}),"renderTrigger",function(){for(var t={key:"T"},o=r.props,n=o.on,i=o.trigger,p=Array.isArray(n)?n:[n],s=0,l=p.length;s<l;s++)switch(p[s]){case"click":t.onClick=r.togglePopup;break;case"hover":t.onMouseEnter=r.onMouseEnter,t.onMouseLeave=r.onMouseLeave;break;case"focus":t.onFocus=r.onMouseEnter}return"function"==typeof i?e.cloneElement(i(r.state.isOpen),t):e.cloneElement(i,t)}),"renderContent",function(){var t=r.props,o=t.arrow,n=t.arrowStyle,i=r.state.modal;return e.createElement("div",p({},r.addWarperAction(),{key:"C"}),o&&!i&&e.createElement("div",{ref:r.setArrowRef,style:Object.assign({},h.popupArrow,n)}),"function"==typeof r.props.children?r.props.children(r.closePopup,r.state.isOpen):r.props.children)}),r.setTriggerRef=function(e){return r.TriggerEl=e},r.setContentRef=function(e){return r.ContentEl=e},r.setArrowRef=function(e){return r.ArrowEl=e},r.setHelperRef=function(e){return r.HelperEl=e},r.timeOut=0,r}return r(n,[{key:"componentDidMount",value:function(){var e=this,t=this.props,o=t.closeOnEscape;t.defaultOpen&&this.setPosition(),o&&window.addEventListener("keyup",function(t){"Escape"===t.key&&e.closePopup()})}},{key:"componentWillReceiveProps",value:function(e){this.props.open!==e.open&&(e.open?this.openPopup():this.closePopup())}},{key:"componentWillUnmount",value:function(){clearTimeout(this.timeOut)}},{key:"render",value:function(){var t=this.props,o=t.overlayStyle,n=t.closeOnDocumentClick,r=t.on,i=this.state.modal,p=this.state.isOpen&&!(r.indexOf("hover")>=0),s=i?h.overlay.modal:h.overlay.tooltip;return[!!this.props.trigger&&e.createElement(y,{innerRef:this.setTriggerRef,key:"R"},this.renderTrigger()),this.state.isOpen&&e.createElement("div",{key:"H",style:{position:"absolute",top:"0px",left:"0px"},ref:this.setHelperRef}),p&&e.createElement("div",{key:"O",className:"popup-overlay",style:Object.assign({},s,o),onClick:n?this.closePopup:void 0},i&&this.renderContent()),this.state.isOpen&&!i&&this.renderContent()]}}]),s(n,t),n}((e=e&&e.hasOwnProperty("default")?e.default:e).PureComponent);i(m,"defaultProps",{children:function(){return e.createElement("span",null," Your Content Here !!")},trigger:null,onOpen:function(){},onClose:function(){},defaultOpen:!1,open:!1,closeOnDocumentClick:!0,closeOnEscape:!0,on:["click"],contentStyle:{},arrowStyle:{},overlayStyle:{},className:"",position:"bottom center",modal:!1,lockScroll:!1,arrow:!0,offsetX:0,offsetY:0,mouseEnterDelay:100,mouseLeaveDelay:100,keepTooltipInside:!1});var y=function(n){function i(e){return o(this,i),c(this,l(i).call(this,e))}return r(i,[{key:"componentDidMount",value:function(){var e=this.props.innerRef;e&&e(t.findDOMNode(this))}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),s(i,n),i}(e.PureComponent);return m});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.reactjsPopup=t(e.React,e.reactDom)}(this,function(e,t){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function i(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function f(e){return function(e){if(Array.isArray(e)){for(var t=0,o=new Array(e.length);t<e.length;t++)o[t]=e[t];return o}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function d(e,t,o,n,r){var i=r.offsetX,p=r.offsetY,s=n?8:0,l=o.split(" "),a=e.top+e.height/2,u=e.left+e.width/2,c=t.height,f=t.width,d=a-c/2,h=u-f/2,g="",y="0%",m="0%";switch(l[0]){case"top":d-=c/2+e.height/2+s,g="rotate(45deg)",y="100%",m="50%";break;case"bottom":d+=c/2+e.height/2+s,g="rotate(225deg)",m="50%";break;case"left":h-=f/2+e.width/2+s,g=" rotate(-45deg)",m="100%",y="50%";break;case"right":h+=f/2+e.width/2+s,g="rotate(135deg)",y="50%"}switch(l[1]){case"top":d=e.top,y=e.height/2+"px";break;case"bottom":d=e.top-c+e.height,y=c-e.height/2+"px";break;case"left":h=e.left,m=e.width/2+"px";break;case"right":h=e.left-f+e.width,m=f-e.width/2+"px"}return{top:d="top"===l[0]?d-p:d+p,left:h="left"===l[0]?h-i:h+i,transform:g,arrowLeft:m,arrowTop:y}}e=e&&e.hasOwnProperty("default")?e.default:e;var h={popupContent:{tooltip:{position:"absolute",zIndex:"2",width:"200px",background:"rgb(255, 255, 255)",border:"1px solid rgb(187, 187, 187)",boxShadow:"rgba(0, 0, 0, 0.2) 0px 1px 3px",padding:"5px"},modal:{position:"relative",background:"rgb(255, 255, 255)",width:"50%",margin:"auto",border:"1px solid rgb(187, 187, 187)",padding:"5px"}},popupArrow:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(45deg)",margin:"-5px",zIndex:"-1",boxShadow:"rgba(0, 0, 0, 0.2) 1px 1px 1px"},overlay:{tooltip:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0"},modal:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",background:"rgba(0, 0, 0,0.5)",display:"flex",zIndex:"999"}}},g=["top left","top center","top right","right top","right center","right bottom","bottom left","bottom center","bottom right","left top","left center","left bottom"],y=function(t){function n(t){var r;return o(this,n),i(u(u(r=c(this,l(n).call(this,t)))),"state",{isOpen:r.props.open||r.props.defaultOpen,modal:!!r.props.modal||!r.props.trigger}),i(u(u(r)),"lockScroll",function(){r.state.modal&&r.props.lockScroll&&(document.getElementsByTagName("body")[0].style.overflow="hidden")}),i(u(u(r)),"resetScroll",function(){r.state.modal&&r.props.lockScroll&&(document.getElementsByTagName("body")[0].style.overflow="auto")}),i(u(u(r)),"togglePopup",function(){r.state.isOpen?r.closePopup():r.openPopup()}),i(u(u(r)),"openPopup",function(){r.state.isOpen||r.props.disabled||r.setState({isOpen:!0},function(){r.setPosition(),r.props.onOpen(),r.lockScroll()})}),i(u(u(r)),"closePopup",function(){r.state.isOpen&&(r.props.onClose(),r.setState({isOpen:!1},function(){r.resetScroll()}))}),i(u(u(r)),"onMouseEnter",function(){clearTimeout(r.timeOut);var e=r.props.mouseEnterDelay;r.timeOut=setTimeout(function(){return r.openPopup()},e)}),i(u(u(r)),"onMouseLeave",function(){clearTimeout(r.timeOut);var e=r.props.mouseLeaveDelay;r.timeOut=setTimeout(function(){return r.closePopup()},e)}),i(u(u(r)),"getTooltipBoundary",function(){var e=r.props.keepTooltipInside,t={top:0,left:0,width:window.innerWidth,height:window.innerHeight};"string"==typeof e&&(t=document.querySelector(e).getBoundingClientRect());return t}),i(u(u(r)),"setPosition",function(){var e=r.props,t=e.arrow,o=e.position,n=e.offsetX,i=e.offsetY,p=e.keepTooltipInside,s=e.arrowStyle;if(!r.state.modal){var l=r.HelperEl.getBoundingClientRect(),a=r.TriggerEl.getBoundingClientRect(),u=r.ContentEl.getBoundingClientRect(),c=r.getTooltipBoundary(),h=Array.isArray(o)?o:[o];(p||Array.isArray(o))&&(h=f(h).concat(g));var y=function(e,t,o,n,r,i){for(var p,s=r.offsetX,l=r.offsetY,a=0;a<o.length;){var u={top:(p=d(e,t,o[a],n,{offsetX:s,offsetY:l})).top,left:p.left,width:t.width,height:t.height};if(!(u.top<=i.top||u.left<=i.left||u.top+u.height>=i.top+i.height||u.left+u.width>=i.left+i.width))break;a++}return p}(a,u,h,t,{offsetX:n,offsetY:i},c);r.ContentEl.style.top=y.top-l.top+"px",r.ContentEl.style.left=y.left-l.left+"px",t&&(r.ArrowEl.style.transform=y.transform,r.ArrowEl.style["-ms-transform"]=y.transform,r.ArrowEl.style["-webkit-transform"]=y.transform,r.ArrowEl.style.top=s.top||y.arrowTop,r.ArrowEl.style.left=s.left||y.arrowLeft),"static"!=window.getComputedStyle(r.TriggerEl,null).getPropertyValue("position")&&""!=window.getComputedStyle(r.TriggerEl,null).getPropertyValue("position")||(r.TriggerEl.style.position="relative")}}),i(u(u(r)),"addWarperAction",function(){var e=r.props,t=e.contentStyle,o=e.className,n=e.on,i=r.state.modal,p=i?h.popupContent.modal:h.popupContent.tooltip,s={className:"popup-content ".concat(o),style:Object.assign({},p,t),ref:r.setContentRef,onClick:function(e){e.stopPropagation()}};return!i&&n.indexOf("hover")>=0&&(s.onMouseEnter=r.onMouseEnter,s.onMouseLeave=r.onMouseLeave),s}),i(u(u(r)),"renderTrigger",function(){for(var t={key:"T"},o=r.props,n=o.on,i=o.trigger,p=Array.isArray(n)?n:[n],s=0,l=p.length;s<l;s++)switch(p[s]){case"click":t.onClick=r.togglePopup;break;case"hover":t.onMouseEnter=r.onMouseEnter,t.onMouseLeave=r.onMouseLeave;break;case"focus":t.onFocus=r.onMouseEnter}return"function"==typeof i?e.cloneElement(i(r.state.isOpen),t):e.cloneElement(i,t)}),i(u(u(r)),"renderContent",function(){var t=r.props,o=t.arrow,n=t.arrowStyle,i=r.state.modal;return e.createElement("div",p({},r.addWarperAction(),{key:"C"}),o&&!i&&e.createElement("div",{ref:r.setArrowRef,style:Object.assign({},h.popupArrow,n)}),"function"==typeof r.props.children?r.props.children(r.closePopup,r.state.isOpen):r.props.children)}),r.setTriggerRef=function(e){return r.TriggerEl=e},r.setContentRef=function(e){return r.ContentEl=e},r.setArrowRef=function(e){return r.ArrowEl=e},r.setHelperRef=function(e){return r.HelperEl=e},r.timeOut=0,r}return s(n,e.PureComponent),r(n,[{key:"componentDidMount",value:function(){var e=this,t=this.props,o=t.closeOnEscape;t.defaultOpen&&this.setPosition(),o&&window.addEventListener("keyup",function(t){"Escape"===t.key&&e.closePopup()})}},{key:"componentWillReceiveProps",value:function(e){this.props.open!==e.open&&(e.open?this.openPopup():this.closePopup())}},{key:"componentDidUpdate",value:function(e){e.disabled!==this.props.disabled&&this.props.disabled&&this.state.isOpen&&this.closePopup()}},{key:"componentWillUnmount",value:function(){clearTimeout(this.timeOut)}},{key:"render",value:function(){var t=this.props,o=t.overlayStyle,n=t.closeOnDocumentClick,r=t.on,i=this.state.modal,p=this.state.isOpen&&!(r.indexOf("hover")>=0),s=i?h.overlay.modal:h.overlay.tooltip;return[!!this.props.trigger&&e.createElement(m,{innerRef:this.setTriggerRef,key:"R"},this.renderTrigger()),this.state.isOpen&&e.createElement("div",{key:"H",style:{position:"absolute",top:"0px",left:"0px"},ref:this.setHelperRef}),p&&e.createElement("div",{key:"O",className:"popup-overlay",style:Object.assign({},s,o),onClick:n?this.closePopup:void 0},i&&this.renderContent()),this.state.isOpen&&!i&&this.renderContent()]}}]),n}();i(y,"defaultProps",{children:function(){return e.createElement("span",null," Your Content Here !!")},trigger:null,onOpen:function(){},onClose:function(){},defaultOpen:!1,open:!1,disabled:!1,closeOnDocumentClick:!0,closeOnEscape:!0,on:["click"],contentStyle:{},arrowStyle:{},overlayStyle:{},className:"",position:"bottom center",modal:!1,lockScroll:!1,arrow:!0,offsetX:0,offsetY:0,mouseEnterDelay:100,mouseLeaveDelay:100,keepTooltipInside:!1});var m=function(n){function i(){return o(this,i),c(this,l(i).apply(this,arguments))}return s(i,e.PureComponent),r(i,[{key:"componentDidMount",value:function(){var e=this.props.innerRef;e&&e(t.findDOMNode(this))}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),i}();return y});
//# sourceMappingURL=reactjs-popup.min.js.map

@@ -8,3 +8,3 @@ # Reactjs-popup

[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]

@@ -136,3 +136,3 @@ [![Code of Conduct][coc-badge]][coc]

[package]: https://www.npmjs.com/package/reactjs-popup
[downloads-badge]: https://img.shields.io/npm/dm/reactjs-popup.svg?style=flat-square
[downloads-badge]: https://img.shields.io/npm/dt/reactjs-popup.svg?style=flat-square
[npmtrends]: http://www.npmtrends.com/reactjs-popup

@@ -139,0 +139,0 @@ [license-badge]: https://img.shields.io/npm/l/reactjs-popup.svg?style=flat-square

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc