Skip to content

Commit

Permalink
Merge pull request #54 from yjose/V1.3.1
Browse files Browse the repository at this point in the history
V1.3.1
  • Loading branch information
yjose committed Oct 31, 2018
2 parents fa675cd + 2069e3b commit f790386
Show file tree
Hide file tree
Showing 24 changed files with 642 additions and 106 deletions.
6 changes: 3 additions & 3 deletions .babelrc
@@ -1,9 +1,9 @@
{
"presets": [
"env",
"react"
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"transform-class-properties"
"@babel/plugin-proposal-class-properties"
]
}
4 changes: 2 additions & 2 deletions build.js
Expand Up @@ -21,8 +21,8 @@ const babelBiliConfig = {
plugins: ["@babel/plugin-proposal-class-properties"]
};
const babelParcelConfig = {
presets: ["env", "react"],
plugins: ["transform-class-properties"]
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["@babel/plugin-proposal-class-properties"]
};

// Copy package.json, LICENSE,README and npmignore files
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/BoundedTooltip.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'

const BoundedTooltip = () => (
<div
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/ControlledPopup.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

class ControlledPopup extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/CustomModal.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const contentStyle = {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/Demo.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const contentStyle = {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/Example.js
@@ -1,5 +1,5 @@
import React from 'react'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

export default () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/InputFocus.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const InputFocus = () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/NestedToolTip.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const NestedToolTip = () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/SimpleMenu.js
@@ -1,5 +1,5 @@
import React from 'react'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const SimpleMenu = () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/SimpleModal.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const SimpleModal = () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/SimpleTooltip.js
@@ -1,6 +1,6 @@
import React from 'react'
import Warper from './Warper'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const SimpleTooltip = () => (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/ToolTipPositions.js
@@ -1,5 +1,5 @@
import React from 'react'
import Popup from './reactjs-popup.es'
import Popup from '../../../src/index'
//

const ToolTipPositions = () => (
Expand Down
4 changes: 2 additions & 2 deletions lib/README.md
Expand Up @@ -5,7 +5,7 @@
[![downloads][downloads-badge]][npmtrends]
[![MIT License][license-badge]][license]

[![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]
[![Code of Conduct][coc-badge]][coc]

Expand Down Expand Up @@ -132,7 +132,7 @@ That's all, thank you for your attention, please [![Star on GitHub][github-star-
[build]: https://travis-ci.org/yjose/reactjs-popup
[version-badge]: https://img.shields.io/npm/v/reactjs-popup.svg?style=flat-square
[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
[license-badge]: https://img.shields.io/npm/l/reactjs-popup.svg?style=flat-square
[license]: https://github.com/yjose/reactjs-popup/blob/master/LICENSE
Expand Down
1 change: 1 addition & 0 deletions lib/index.d.ts
Expand Up @@ -7,6 +7,7 @@ declare module 'reactjs-popup' {
interface Props {
trigger?: JSX.Element | ((isOpen: boolean) => JSX.Element);
open?: boolean;
disabled?: boolean;
defaultOpen?: boolean;
on?: EventType | EventType[];
children: JSX.Element | ((close: () => void, isOpen: boolean) => JSX.Element);
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
@@ -1,6 +1,6 @@
{
"name": "reactjs-popup",
"version": "1.3.0",
"version": "1.3.1",
"description": "React Popup Component - Modals,Tooltips and Menus —  All in one",
"main": "reactjs-popup.cjs.js",
"module": "reactjs-popup.es.js",
Expand Down
89 changes: 63 additions & 26 deletions lib/reactjs-popup.cjs.js
@@ -1,5 +1,5 @@
/*!
* reactjs-popup v1.3.0
* reactjs-popup v1.3.1
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>
* Released under the MIT License.
*/
Expand Down Expand Up @@ -70,16 +70,20 @@ function _inherits(subClass, superClass) {
throw new TypeError("Super expression must either be null or a function");
}

_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);
}

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);
}

Expand Down Expand Up @@ -307,25 +311,35 @@ var POSITION_TYPES = ["top left", "top center", "top right", "right top", "right
var Popup =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(Popup, _React$PureComponent);

function Popup(props) {
var _this;

_classCallCheck(this, Popup);

_this = _possibleConstructorReturn(this, _getPrototypeOf(Popup).call(this, props));

_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({
isOpen: true
Expand All @@ -336,7 +350,9 @@ function (_React$PureComponent) {

_this.lockScroll();
});
}), "closePopup", function () {
});

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

_this.props.onClose();
Expand All @@ -346,19 +362,25 @@ function (_React$PureComponent) {
}, function () {
_this.resetScroll();
});
}), "onMouseEnter", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseEnter", function () {
clearTimeout(_this.timeOut);
var mouseEnterDelay = _this.props.mouseEnterDelay;
_this.timeOut = setTimeout(function () {
return _this.openPopup();
}, mouseEnterDelay);
}), "onMouseLeave", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseLeave", function () {
clearTimeout(_this.timeOut);
var mouseLeaveDelay = _this.props.mouseLeaveDelay;
_this.timeOut = setTimeout(function () {
return _this.closePopup();
}, mouseLeaveDelay);
}), "getTooltipBoundary", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTooltipBoundary", function () {
var keepTooltipInside = _this.props.keepTooltipInside;
var boundingBox = {
top: 0,
Expand All @@ -378,7 +400,9 @@ function (_React$PureComponent) {
}

return boundingBox;
}), "setPosition", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setPosition", function () {
var _this$props = _this.props,
arrow = _this$props.arrow,
position = _this$props.position,
Expand Down Expand Up @@ -416,7 +440,9 @@ function (_React$PureComponent) {
}

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,
contentStyle = _this$props2.contentStyle,
className = _this$props2.className,
Expand All @@ -438,7 +464,9 @@ function (_React$PureComponent) {
}

return childrenElementProps;
}), "renderTrigger", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTrigger", function () {
var triggerProps = {
key: "T"
};
Expand Down Expand Up @@ -466,7 +494,9 @@ function (_React$PureComponent) {

if (typeof trigger === "function") return React.cloneElement(trigger(_this.state.isOpen), triggerProps);
return React.cloneElement(trigger, triggerProps);
}), "renderContent", function () {
});

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderContent", function () {
var _this$props4 = _this.props,
arrow = _this$props4.arrow,
arrowStyle = _this$props4.arrowStyle;
Expand Down Expand Up @@ -521,6 +551,13 @@ function (_React$PureComponent) {
if (this.props.open === nextProps.open) return;
if (nextProps.open) this.openPopup();else this.closePopup();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.disabled !== this.props.disabled && this.props.disabled && this.state.isOpen) {
this.closePopup();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
Expand Down Expand Up @@ -557,8 +594,6 @@ function (_React$PureComponent) {
}
}]);

_inherits(Popup, _React$PureComponent);

return Popup;
}(React.PureComponent);

Expand All @@ -571,6 +606,7 @@ _defineProperty(Popup, "defaultProps", {
onClose: function onClose() {},
defaultOpen: false,
open: false,
disabled: false,
closeOnDocumentClick: true,
closeOnEscape: true,
on: ["click"],
Expand Down Expand Up @@ -600,6 +636,7 @@ if (process.env.NODE_ENV !== "production") {
className: PropTypes.string,
modal: PropTypes.bool,
closeOnDocumentClick: PropTypes.bool,
disabled: PropTypes.bool,
lockScroll: PropTypes.bool,
offsetX: PropTypes.number,
offsetY: PropTypes.number,
Expand All @@ -621,10 +658,12 @@ if (process.env.NODE_ENV !== "production") {
var Ref =
/*#__PURE__*/
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));
}

_createClass(Ref, [{
Expand All @@ -641,8 +680,6 @@ function (_React$PureComponent2) {
}
}]);

_inherits(Ref, _React$PureComponent2);

return Ref;
}(React.PureComponent);

Expand Down

0 comments on commit f790386

Please sign in to comment.