import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isOpen","onClose","onOpen","hasOverlay","onOverlayClick","onClickOutside","onEsc","className","width","position","children","container","refsForExcludeClickOutside","rootClassName","afterClose","style"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./Modal.css";import React,{useEffect,useRef}from"react";import{Transition}from"react-transition-group";import{PortalWithTheme,PortalWithThemeConsumer}from"../PortalWithTheme";import{useTheme}from"../Theme/Theme";import{useGlobalKeys}from"../../hooks/useGlobalKeys";import{animateTimeout,cnMixPopoverAnimate}from"../../mixs/MixPopoverAnimate";import{cnMixScrollBar}from"../../mixs/MixScrollBar";import{cn}from"../../utils/bem";var modalPropWidth=["auto"],modalPropWidthDefault=modalPropWidth[0],modalPropPosition=["center","top"],modalPropPositionDefault=modalPropPosition[0],cnModal=cn("Modal");export var Modal=function(a){var b=a.isOpen,c=a.onClose,d=a.onOpen,e=a.hasOverlay,f=void 0===e||e,g=a.onOverlayClick,h=a.onClickOutside,i=a.onEsc,j=a.className,k=a.width,l=void 0===k?modalPropWidthDefault:k,m=a.position,n=void 0===m?modalPropPositionDefault:m,o=a.children,p=a.container,q=void 0===p?window.document.body:p,r=a.refsForExcludeClickOutside,s=a.rootClassName,t=a.afterClose,u=a.style,v=_objectWithoutProperties(a,_excluded),w=useRef(null),x=useRef(null),y=useTheme(),z=y.theme;return useEffect(function(){b?null===d||void 0===d?void 0:d():null===c||void 0===c?void 0:c()},[b]),useGlobalKeys({Escape:function Escape(a){return b&&i&&i(a)}}),React.createElement(Transition,{in:b,unmountOnExit:!0,nodeRef:x,timeout:animateTimeout,onExited:t},function(a){return React.createElement(PortalWithTheme,{preset:z,container:q,className:cnModal({hasOverlay:f},[s]),ref:x,style:"number"==typeof(null===u||void 0===u?void 0:u.zIndex)?{zIndex:u.zIndex}:void 0},f&&React.createElement("div",{className:cnModal("Overlay",{animate:a}),"aria-label":"Overlay"}),React.createElement("div",Object.assign({},v,{style:_objectSpread(_objectSpread({},u),{},{zIndex:void 0}),className:cnModal("Window",{width:l,position:n},[cnMixPopoverAnimate({animate:a}),j,cnMixScrollBar()]),ref:w}),React.createElement(PortalWithThemeConsumer,{onClickOutside:h||g,ignoreClicksInsideRefs:[].concat(_toConsumableArray(r||[]),[w])},o)))})};
//# sourceMappingURL=Modal.js.map