import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","children"],_excluded2=["className","children"],_excluded3=["isOpen","onClose","onOpen","hasOverlay","onClickOutside","onEsc","position","size","className","children","container","style","rootClassName","afterClose"];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"./Sidebar.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{cnMixScrollBar}from"../../mixs/MixScrollBar";import{cn}from"../../utils/bem";var sidebarPropPosition=["right","bottom","left","top"],sidebarPropPositionDefault=sidebarPropPosition[0];export var sidebarPropSize=["s","m","l","full","1/2","1/3","1/4","2/3","3/4"];var sidebarPropSizeDefault=sidebarPropSize[1];export var cnSidebar=cn("Sidebar");var SidebarContent=function(a){var b=a.className,c=a.children,d=_objectWithoutProperties(a,_excluded);return React.createElement("div",Object.assign({className:cnSidebar("Content",[b,cnMixScrollBar()])},d),c)},SidebarActions=function(a){var b=a.className,c=a.children,d=_objectWithoutProperties(a,_excluded2);return React.createElement("div",Object.assign({className:cnSidebar("Actions",[b])},d),c)};export var Sidebar=function(a){var b=a.isOpen,c=a.onClose,d=a.onOpen,e=a.hasOverlay,f=void 0===e||e,g=a.onClickOutside,h=a.onEsc,i=a.position,j=void 0===i?sidebarPropPositionDefault:i,k=a.size,l=void 0===k?sidebarPropSizeDefault:k,m=a.className,n=a.children,o=a.container,p=void 0===o?window.document.body:o,q=a.style,r=a.rootClassName,s=a.afterClose,t=_objectWithoutProperties(a,_excluded3),u=useRef(null),v=useRef(null),w=useTheme(),x=w.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&&h&&h(a)}}),React.createElement(Transition,{in:b,unmountOnExit:!0,timeout:240,nodeRef:v,onExiting:s},function(a){return React.createElement(PortalWithTheme,{preset:x,ref:v,container:p,className:cnSidebar({position:j,hasOverlay:f},[r]),style:"number"==typeof(null===q||void 0===q?void 0:q.zIndex)?{zIndex:q.zIndex}:void 0},f&&React.createElement("div",{className:cnSidebar("Overlay",{animate:a}),"aria-label":"Overlay"}),React.createElement("div",Object.assign({},t,{style:_objectSpread(_objectSpread({},q),{},{zIndex:void 0}),className:cnSidebar("Window",{size:l,position:j,animate:a},[m]),ref:u}),React.createElement(PortalWithThemeConsumer,{onClickOutside:g,ignoreClicksInsideRefs:[u]},n)))})};Sidebar.Content=SidebarContent,Sidebar.Actions=SidebarActions;
//# sourceMappingURL=Sidebar.js.map