1+ "use strict" ;
2+
3+ Object . defineProperty ( exports , "__esModule" , {
4+ value : true
5+ } ) ;
6+ exports . default = void 0 ;
7+
8+ var _react = _interopRequireDefault ( require ( "react" ) ) ;
9+
10+ var _propTypes = _interopRequireDefault ( require ( "prop-types" ) ) ;
11+
12+ var _reactDom = require ( "react-dom" ) ;
13+
14+ var _reactTransitionGroup = require ( "react-transition-group" ) ;
15+
16+ var _classnames = _interopRequireDefault ( require ( "classnames" ) ) ;
17+
18+ var _Backdrop = _interopRequireDefault ( require ( "../Backdrop/Backdrop" ) ) ;
19+
20+ var _components = require ( "igz-controls/components" ) ;
21+
22+ var _constants = require ( "../../constants" ) ;
23+
24+ var _types = require ( "../../types" ) ;
25+
26+ var _close = require ( "igz-controls/images/close.svg" ) ;
27+
28+ require ( "./Modal.scss" ) ;
29+
30+ var _jsxRuntime = require ( "react/jsx-runtime" ) ;
31+
32+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
33+
34+ function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; enumerableOnly && ( symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ) , keys . push . apply ( keys , symbols ) ; } return keys ; }
35+
36+ function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = null != arguments [ i ] ? arguments [ i ] : { } ; i % 2 ? ownKeys ( Object ( source ) , ! 0 ) . forEach ( function ( key ) { _defineProperty ( target , key , source [ key ] ) ; } ) : Object . getOwnPropertyDescriptors ? Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) : ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } return target ; }
37+
38+ function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
39+
40+ var JSX_MODAL = /*#__PURE__*/ _react . default . forwardRef ( function ( _ref , ref ) {
41+ var actions = _ref . actions ,
42+ children = _ref . children ,
43+ className = _ref . className ,
44+ onClose = _ref . onClose ,
45+ size = _ref . size ,
46+ show = _ref . show ,
47+ title = _ref . title ;
48+ var modalClassNames = ( 0 , _classnames . default ) ( 'modal' , className , size && "modal-" . concat ( size ) ) ;
49+ return /*#__PURE__*/ ( 0 , _jsxRuntime . jsxs ) ( _jsxRuntime . Fragment , {
50+ children : [ /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( _Backdrop . default , {
51+ onClose : onClose ,
52+ show : show
53+ } ) , /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( _reactTransitionGroup . CSSTransition , {
54+ in : show ,
55+ timeout : 300 ,
56+ classNames : "modal-transition" ,
57+ unmountOnExit : true ,
58+ children : /*#__PURE__*/ ( 0 , _jsxRuntime . jsxs ) ( "div" , {
59+ className : modalClassNames ,
60+ "data-testid" : "modal" ,
61+ children : [ /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
62+ className : "modal__header-button" ,
63+ children : /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( _components . RoundedIcon , {
64+ onClick : onClose ,
65+ tooltipText : "Close" ,
66+ "data-testid" : "pop-up-close-btn" ,
67+ ref : ref ,
68+ children : /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( _close . ReactComponent , { } )
69+ } )
70+ } ) , /*#__PURE__*/ ( 0 , _jsxRuntime . jsxs ) ( "div" , {
71+ className : "modal__content" ,
72+ children : [ /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
73+ className : "modal__header" ,
74+ children : /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "h5" , {
75+ className : "modal__header-title" ,
76+ children : title
77+ } )
78+ } ) , /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
79+ className : "modal__body" ,
80+ children : children
81+ } ) , actions && actions . length > 0 && /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
82+ className : "modal__footer" ,
83+ children : /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
84+ className : "modal__footer-actions" ,
85+ children : actions . map ( function ( action , idx ) {
86+ return /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( "div" , {
87+ children : action
88+ } , idx ) ;
89+ } )
90+ } )
91+ } ) ]
92+ } ) ]
93+ } )
94+ } ) ]
95+ } ) ;
96+ } ) ;
97+
98+ var Modal = /*#__PURE__*/ _react . default . forwardRef ( function ( props , ref ) {
99+ return /*#__PURE__*/ ( 0 , _reactDom . createPortal ) ( /*#__PURE__*/ ( 0 , _jsxRuntime . jsx ) ( JSX_MODAL , _objectSpread ( _objectSpread ( { } , props ) , { } , {
100+ ref : ref
101+ } ) ) , document . getElementById ( 'overlay_container' ) ) ;
102+ } ) ;
103+
104+ Modal . defaultProps = {
105+ actions : [ ] ,
106+ show : false ,
107+ size : _constants . MODAL_MD ,
108+ title : ''
109+ } ;
110+ Modal . propTypes = {
111+ actions : _propTypes . default . array ,
112+ children : _propTypes . default . oneOfType ( [ _propTypes . default . element , _propTypes . default . object , _propTypes . default . node , _propTypes . default . string ] ) . isRequired ,
113+ onClose : _propTypes . default . func . isRequired ,
114+ show : _propTypes . default . bool . isRequired ,
115+ size : _types . MODAL_SIZES ,
116+ title : _propTypes . default . string
117+ } ;
118+ var _default = Modal ;
119+ exports . default = _default ;
0 commit comments