1
1
/*!
2
- * reactjs-popup v1.3.0
2
+ * reactjs-popup v1.3.1
3
3
* (c) 2018-present Youssouf EL AZIZI <youssoufelazizi@gmail.com>
4
4
* Released under the MIT License.
5
5
*/
@@ -70,16 +70,20 @@ function _inherits(subClass, superClass) {
70
70
throw new TypeError ( "Super expression must either be null or a function" ) ;
71
71
}
72
72
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
+ } ) ;
75
80
if ( superClass ) _setPrototypeOf ( subClass , superClass ) ;
76
81
}
77
82
78
83
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 ) ;
81
86
} ;
82
-
83
87
return _getPrototypeOf ( o ) ;
84
88
}
85
89
@@ -307,25 +311,35 @@ var POSITION_TYPES = ["top left", "top center", "top right", "right top", "right
307
311
var Popup =
308
312
/*#__PURE__*/
309
313
function ( _React$PureComponent ) {
314
+ _inherits ( Popup , _React$PureComponent ) ;
315
+
310
316
function Popup ( props ) {
311
317
var _this ;
312
318
313
319
_classCallCheck ( this , Popup ) ;
314
320
315
321
_this = _possibleConstructorReturn ( this , _getPrototypeOf ( Popup ) . call ( this , props ) ) ;
316
322
317
- _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "state" , {
323
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "state" , {
318
324
isOpen : _this . props . open || _this . props . defaultOpen ,
319
325
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
320
326
321
- } ) , "lockScroll" , function ( ) {
327
+ } ) ;
328
+
329
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "lockScroll" , function ( ) {
322
330
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 ( ) {
324
334
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 ( ) {
326
338
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 ;
329
343
330
344
_this . setState ( {
331
345
isOpen : true
@@ -336,7 +350,9 @@ function (_React$PureComponent) {
336
350
337
351
_this . lockScroll ( ) ;
338
352
} ) ;
339
- } ) , "closePopup" , function ( ) {
353
+ } ) ;
354
+
355
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "closePopup" , function ( ) {
340
356
if ( ! _this . state . isOpen ) return ;
341
357
342
358
_this . props . onClose ( ) ;
@@ -346,19 +362,25 @@ function (_React$PureComponent) {
346
362
} , function ( ) {
347
363
_this . resetScroll ( ) ;
348
364
} ) ;
349
- } ) , "onMouseEnter" , function ( ) {
365
+ } ) ;
366
+
367
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "onMouseEnter" , function ( ) {
350
368
clearTimeout ( _this . timeOut ) ;
351
369
var mouseEnterDelay = _this . props . mouseEnterDelay ;
352
370
_this . timeOut = setTimeout ( function ( ) {
353
371
return _this . openPopup ( ) ;
354
372
} , mouseEnterDelay ) ;
355
- } ) , "onMouseLeave" , function ( ) {
373
+ } ) ;
374
+
375
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "onMouseLeave" , function ( ) {
356
376
clearTimeout ( _this . timeOut ) ;
357
377
var mouseLeaveDelay = _this . props . mouseLeaveDelay ;
358
378
_this . timeOut = setTimeout ( function ( ) {
359
379
return _this . closePopup ( ) ;
360
380
} , mouseLeaveDelay ) ;
361
- } ) , "getTooltipBoundary" , function ( ) {
381
+ } ) ;
382
+
383
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "getTooltipBoundary" , function ( ) {
362
384
var keepTooltipInside = _this . props . keepTooltipInside ;
363
385
var boundingBox = {
364
386
top : 0 ,
@@ -378,7 +400,9 @@ function (_React$PureComponent) {
378
400
}
379
401
380
402
return boundingBox ;
381
- } ) , "setPosition" , function ( ) {
403
+ } ) ;
404
+
405
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "setPosition" , function ( ) {
382
406
var _this$props = _this . props ,
383
407
arrow = _this$props . arrow ,
384
408
position = _this$props . position ,
@@ -416,7 +440,9 @@ function (_React$PureComponent) {
416
440
}
417
441
418
442
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 ( ) {
420
446
var _this$props2 = _this . props ,
421
447
contentStyle = _this$props2 . contentStyle ,
422
448
className = _this$props2 . className ,
@@ -438,7 +464,9 @@ function (_React$PureComponent) {
438
464
}
439
465
440
466
return childrenElementProps ;
441
- } ) , "renderTrigger" , function ( ) {
467
+ } ) ;
468
+
469
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "renderTrigger" , function ( ) {
442
470
var triggerProps = {
443
471
key : "T"
444
472
} ;
@@ -466,7 +494,9 @@ function (_React$PureComponent) {
466
494
467
495
if ( typeof trigger === "function" ) return React . cloneElement ( trigger ( _this . state . isOpen ) , triggerProps ) ;
468
496
return React . cloneElement ( trigger , triggerProps ) ;
469
- } ) , "renderContent" , function ( ) {
497
+ } ) ;
498
+
499
+ _defineProperty ( _assertThisInitialized ( _assertThisInitialized ( _this ) ) , "renderContent" , function ( ) {
470
500
var _this$props4 = _this . props ,
471
501
arrow = _this$props4 . arrow ,
472
502
arrowStyle = _this$props4 . arrowStyle ;
@@ -521,6 +551,13 @@ function (_React$PureComponent) {
521
551
if ( this . props . open === nextProps . open ) return ;
522
552
if ( nextProps . open ) this . openPopup ( ) ; else this . closePopup ( ) ;
523
553
}
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
+ }
524
561
} , {
525
562
key : "componentWillUnmount" ,
526
563
value : function componentWillUnmount ( ) {
@@ -557,8 +594,6 @@ function (_React$PureComponent) {
557
594
}
558
595
} ] ) ;
559
596
560
- _inherits ( Popup , _React$PureComponent ) ;
561
-
562
597
return Popup ;
563
598
} ( React . PureComponent ) ;
564
599
@@ -571,6 +606,7 @@ _defineProperty(Popup, "defaultProps", {
571
606
onClose : function onClose ( ) { } ,
572
607
defaultOpen : false ,
573
608
open : false ,
609
+ disabled : false ,
574
610
closeOnDocumentClick : true ,
575
611
closeOnEscape : true ,
576
612
on : [ "click" ] ,
@@ -600,6 +636,7 @@ if (process.env.NODE_ENV !== "production") {
600
636
className : PropTypes . string ,
601
637
modal : PropTypes . bool ,
602
638
closeOnDocumentClick : PropTypes . bool ,
639
+ disabled : PropTypes . bool ,
603
640
lockScroll : PropTypes . bool ,
604
641
offsetX : PropTypes . number ,
605
642
offsetY : PropTypes . number ,
@@ -621,10 +658,12 @@ if (process.env.NODE_ENV !== "production") {
621
658
var Ref =
622
659
/*#__PURE__*/
623
660
function ( _React$PureComponent2 ) {
624
- function Ref ( props ) {
661
+ _inherits ( Ref , _React$PureComponent2 ) ;
662
+
663
+ function Ref ( ) {
625
664
_classCallCheck ( this , Ref ) ;
626
665
627
- return _possibleConstructorReturn ( this , _getPrototypeOf ( Ref ) . call ( this , props ) ) ;
666
+ return _possibleConstructorReturn ( this , _getPrototypeOf ( Ref ) . apply ( this , arguments ) ) ;
628
667
}
629
668
630
669
_createClass ( Ref , [ {
@@ -641,8 +680,6 @@ function (_React$PureComponent2) {
641
680
}
642
681
} ] ) ;
643
682
644
- _inherits ( Ref , _React$PureComponent2 ) ;
645
-
646
683
return Ref ;
647
684
} ( React . PureComponent ) ;
648
685
0 commit comments