Skip to content

Commit f790386

Browse files
authored
Merge pull request #54 from yjose/V1.3.1
V1.3.1
2 parents fa675cd + 2069e3b commit f790386

24 files changed

+642
-106
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"presets": [
3-
"env",
4-
"react"
3+
"@babel/preset-env",
4+
"@babel/preset-react"
55
],
66
"plugins": [
7-
"transform-class-properties"
7+
"@babel/plugin-proposal-class-properties"
88
]
99
}

build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const babelBiliConfig = {
2121
plugins: ["@babel/plugin-proposal-class-properties"]
2222
};
2323
const babelParcelConfig = {
24-
presets: ["env", "react"],
25-
plugins: ["transform-class-properties"]
24+
presets: ["@babel/preset-env", "@babel/preset-react"],
25+
plugins: ["@babel/plugin-proposal-class-properties"]
2626
};
2727

2828
// Copy package.json, LICENSE,README and npmignore files

docs/src/examples/BoundedTooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44

55
const BoundedTooltip = () => (
66
<div

docs/src/examples/ControlledPopup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
class ControlledPopup extends React.Component {

docs/src/examples/CustomModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const contentStyle = {

docs/src/examples/Demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const contentStyle = {

docs/src/examples/Example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import Popup from './reactjs-popup.es'
2+
import Popup from '../../../src/index'
33
//
44

55
export default () => (

docs/src/examples/InputFocus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const InputFocus = () => (

docs/src/examples/NestedToolTip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const NestedToolTip = () => (

docs/src/examples/SimpleMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import Popup from './reactjs-popup.es'
2+
import Popup from '../../../src/index'
33
//
44

55
const SimpleMenu = () => (

docs/src/examples/SimpleModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const SimpleModal = () => (

docs/src/examples/SimpleTooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import Warper from './Warper'
3-
import Popup from './reactjs-popup.es'
3+
import Popup from '../../../src/index'
44
//
55

66
const SimpleTooltip = () => (

docs/src/examples/ToolTipPositions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import Popup from './reactjs-popup.es'
2+
import Popup from '../../../src/index'
33
//
44

55
const ToolTipPositions = () => (

lib/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![downloads][downloads-badge]][npmtrends]
66
[![MIT License][license-badge]][license]
77

8-
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)
8+
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors)
99
[![PRs Welcome][prs-badge]][prs]
1010
[![Code of Conduct][coc-badge]][coc]
1111

@@ -132,7 +132,7 @@ That's all, thank you for your attention, please [![Star on GitHub][github-star-
132132
[build]: https://travis-ci.org/yjose/reactjs-popup
133133
[version-badge]: https://img.shields.io/npm/v/reactjs-popup.svg?style=flat-square
134134
[package]: https://www.npmjs.com/package/reactjs-popup
135-
[downloads-badge]: https://img.shields.io/npm/dm/reactjs-popup.svg?style=flat-square
135+
[downloads-badge]: https://img.shields.io/npm/dt/reactjs-popup.svg?style=flat-square
136136
[npmtrends]: http://www.npmtrends.com/reactjs-popup
137137
[license-badge]: https://img.shields.io/npm/l/reactjs-popup.svg?style=flat-square
138138
[license]: https://github.com/yjose/reactjs-popup/blob/master/LICENSE

lib/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare module 'reactjs-popup' {
77
interface Props {
88
trigger?: JSX.Element | ((isOpen: boolean) => JSX.Element);
99
open?: boolean;
10+
disabled?: boolean;
1011
defaultOpen?: boolean;
1112
on?: EventType | EventType[];
1213
children: JSX.Element | ((close: () => void, isOpen: boolean) => JSX.Element);

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactjs-popup",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "React Popup Component - Modals,Tooltips and Menus —  All in one",
55
"main": "reactjs-popup.cjs.js",
66
"module": "reactjs-popup.es.js",

lib/reactjs-popup.cjs.js

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* reactjs-popup v1.3.0
2+
* reactjs-popup v1.3.1
33
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>
44
* Released under the MIT License.
55
*/
@@ -70,16 +70,20 @@ function _inherits(subClass, superClass) {
7070
throw new TypeError("Super expression must either be null or a function");
7171
}
7272

73-
_setPrototypeOf(subClass.prototype, superClass && superClass.prototype);
74-
73+
subClass.prototype = Object.create(superClass && superClass.prototype, {
74+
constructor: {
75+
value: subClass,
76+
writable: true,
77+
configurable: true
78+
}
79+
});
7580
if (superClass) _setPrototypeOf(subClass, superClass);
7681
}
7782

7883
function _getPrototypeOf(o) {
79-
_getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) {
80-
return o.__proto__;
84+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
85+
return o.__proto__ || Object.getPrototypeOf(o);
8186
};
82-
8387
return _getPrototypeOf(o);
8488
}
8589

@@ -307,25 +311,35 @@ var POSITION_TYPES = ["top left", "top center", "top right", "right top", "right
307311
var Popup =
308312
/*#__PURE__*/
309313
function (_React$PureComponent) {
314+
_inherits(Popup, _React$PureComponent);
315+
310316
function Popup(props) {
311317
var _this;
312318

313319
_classCallCheck(this, Popup);
314320

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

317-
_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
323+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
318324
isOpen: _this.props.open || _this.props.defaultOpen,
319325
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
320326

321-
}), "lockScroll", function () {
327+
});
328+
329+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "lockScroll", function () {
322330
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "hidden";
323-
}), "resetScroll", function () {
331+
});
332+
333+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "resetScroll", function () {
324334
if (_this.state.modal && _this.props.lockScroll) document.getElementsByTagName("body")[0].style.overflow = "auto";
325-
}), "togglePopup", function () {
335+
});
336+
337+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "togglePopup", function () {
326338
if (_this.state.isOpen) _this.closePopup();else _this.openPopup();
327-
}), "openPopup", function () {
328-
if (_this.state.isOpen) return;
339+
});
340+
341+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openPopup", function () {
342+
if (_this.state.isOpen || _this.props.disabled) return;
329343

330344
_this.setState({
331345
isOpen: true
@@ -336,7 +350,9 @@ function (_React$PureComponent) {
336350

337351
_this.lockScroll();
338352
});
339-
}), "closePopup", function () {
353+
});
354+
355+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "closePopup", function () {
340356
if (!_this.state.isOpen) return;
341357

342358
_this.props.onClose();
@@ -346,19 +362,25 @@ function (_React$PureComponent) {
346362
}, function () {
347363
_this.resetScroll();
348364
});
349-
}), "onMouseEnter", function () {
365+
});
366+
367+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseEnter", function () {
350368
clearTimeout(_this.timeOut);
351369
var mouseEnterDelay = _this.props.mouseEnterDelay;
352370
_this.timeOut = setTimeout(function () {
353371
return _this.openPopup();
354372
}, mouseEnterDelay);
355-
}), "onMouseLeave", function () {
373+
});
374+
375+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onMouseLeave", function () {
356376
clearTimeout(_this.timeOut);
357377
var mouseLeaveDelay = _this.props.mouseLeaveDelay;
358378
_this.timeOut = setTimeout(function () {
359379
return _this.closePopup();
360380
}, mouseLeaveDelay);
361-
}), "getTooltipBoundary", function () {
381+
});
382+
383+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTooltipBoundary", function () {
362384
var keepTooltipInside = _this.props.keepTooltipInside;
363385
var boundingBox = {
364386
top: 0,
@@ -378,7 +400,9 @@ function (_React$PureComponent) {
378400
}
379401

380402
return boundingBox;
381-
}), "setPosition", function () {
403+
});
404+
405+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setPosition", function () {
382406
var _this$props = _this.props,
383407
arrow = _this$props.arrow,
384408
position = _this$props.position,
@@ -416,7 +440,9 @@ function (_React$PureComponent) {
416440
}
417441

418442
if (window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "static" || window.getComputedStyle(_this.TriggerEl, null).getPropertyValue("position") == "") _this.TriggerEl.style.position = "relative";
419-
}), "addWarperAction", function () {
443+
});
444+
445+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "addWarperAction", function () {
420446
var _this$props2 = _this.props,
421447
contentStyle = _this$props2.contentStyle,
422448
className = _this$props2.className,
@@ -438,7 +464,9 @@ function (_React$PureComponent) {
438464
}
439465

440466
return childrenElementProps;
441-
}), "renderTrigger", function () {
467+
});
468+
469+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderTrigger", function () {
442470
var triggerProps = {
443471
key: "T"
444472
};
@@ -466,7 +494,9 @@ function (_React$PureComponent) {
466494

467495
if (typeof trigger === "function") return React.cloneElement(trigger(_this.state.isOpen), triggerProps);
468496
return React.cloneElement(trigger, triggerProps);
469-
}), "renderContent", function () {
497+
});
498+
499+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderContent", function () {
470500
var _this$props4 = _this.props,
471501
arrow = _this$props4.arrow,
472502
arrowStyle = _this$props4.arrowStyle;
@@ -521,6 +551,13 @@ function (_React$PureComponent) {
521551
if (this.props.open === nextProps.open) return;
522552
if (nextProps.open) this.openPopup();else this.closePopup();
523553
}
554+
}, {
555+
key: "componentDidUpdate",
556+
value: function componentDidUpdate(prevProps) {
557+
if (prevProps.disabled !== this.props.disabled && this.props.disabled && this.state.isOpen) {
558+
this.closePopup();
559+
}
560+
}
524561
}, {
525562
key: "componentWillUnmount",
526563
value: function componentWillUnmount() {
@@ -557,8 +594,6 @@ function (_React$PureComponent) {
557594
}
558595
}]);
559596

560-
_inherits(Popup, _React$PureComponent);
561-
562597
return Popup;
563598
}(React.PureComponent);
564599

@@ -571,6 +606,7 @@ _defineProperty(Popup, "defaultProps", {
571606
onClose: function onClose() {},
572607
defaultOpen: false,
573608
open: false,
609+
disabled: false,
574610
closeOnDocumentClick: true,
575611
closeOnEscape: true,
576612
on: ["click"],
@@ -600,6 +636,7 @@ if (process.env.NODE_ENV !== "production") {
600636
className: PropTypes.string,
601637
modal: PropTypes.bool,
602638
closeOnDocumentClick: PropTypes.bool,
639+
disabled: PropTypes.bool,
603640
lockScroll: PropTypes.bool,
604641
offsetX: PropTypes.number,
605642
offsetY: PropTypes.number,
@@ -621,10 +658,12 @@ if (process.env.NODE_ENV !== "production") {
621658
var Ref =
622659
/*#__PURE__*/
623660
function (_React$PureComponent2) {
624-
function Ref(props) {
661+
_inherits(Ref, _React$PureComponent2);
662+
663+
function Ref() {
625664
_classCallCheck(this, Ref);
626665

627-
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, props));
666+
return _possibleConstructorReturn(this, _getPrototypeOf(Ref).apply(this, arguments));
628667
}
629668

630669
_createClass(Ref, [{
@@ -641,8 +680,6 @@ function (_React$PureComponent2) {
641680
}
642681
}]);
643682

644-
_inherits(Ref, _React$PureComponent2);
645-
646683
return Ref;
647684
}(React.PureComponent);
648685

0 commit comments

Comments
 (0)