码桶

发现社区成员的开源项目

geekssl /

wstats

公开
main
wstats/public/assets/Modal-08QhW3n9.js
Modal-08QhW3n9.js21.9 KB
import{E as te,r as E,Y as ne,Z,aP as B,a3 as oe,ag as se,bq as ie,br as ae,bd as le,ac as q,a5 as m,R as a,bb as re,T as ce,an as G,as as de,aV as ue,av as he,a8 as i,aa as D,aA as fe,bs as me,bp as pe,bt as be,a6 as ge,B as K,bk as z,bl as ye,bj as ve,a9 as Oe}from"./index-GWuvg2UH.js";import{_ as Ce}from"./_baseDifference-DopHgqVv.js";import{b as Ee,c as ke,I as De,a as we}from"./IconTickCircle-BYgwCdAe.js";function Se(s){return E.createElement("svg",Object.assign({viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",focusable:!1,"aria-hidden":!0},s),E.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 23a11 11 0 1 0 0-22 11 11 0 0 0 0 22Zm-.17-8.4c-.86 0-1.3-.53-1.3-1.23 0-1.05.53-1.72 1.74-2.64l.06-.05c.83-.62 1.4-1.06 1.4-1.85 0-.9-.83-1.4-1.76-1.4-.76 0-1.34.28-1.8.87-.33.34-.6.53-1.05.53C8.38 8.83 8 8.3 8 7.7c0-.6.34-1.22.88-1.68A5.15 5.15 0 0 1 12.28 5c2.71 0 4.62 1.34 4.62 3.64 0 1.68-1 2.5-2.2 3.31-.8.59-1.17.93-1.48 1.62-.33.6-.58 1.04-1.4 1.04Zm-.02 4.17c-.94 0-1.71-.6-1.71-1.54 0-.94.77-1.55 1.7-1.55.95 0 1.7.6 1.7 1.55 0 .93-.75 1.54-1.7 1.54Z",fill:"currentColor"}))}const _e=te(Se,"help_circle"),d={DIALOG:`${ne}-modal`},U={SIZE:["small","medium","large","full-width"],directions:["ltr","rtl"]};function Le(s){return s!==null&&typeof s=="object"}function H(s){return Le(s)&&typeof s.then=="function"}class Ie extends Z{constructor(n){super(Object.assign({},n)),this._debouncedOk=B(e=>{this._invokeOk(e)},100,{leading:!0,trailing:!1}),this._debouncedCancel=B(e=>{this._invokeCancel(e)},100,{leading:!0,trailing:!1}),this._lastCancelTarget=null,this._lastOkTarget=null,this.toggleDisplayNone=(e,t)=>{this._adapter.toggleDisplayNone(e,t)}}destroy(){this._debouncedOk.cancel(),this._debouncedCancel.cancel(),this.afterHide()}handleCancel(n){var e,t;const o=(t=(e=n==null?void 0:n.currentTarget)!==null&&e!==void 0?e:n==null?void 0:n.target)!==null&&t!==void 0?t:null;o!==this._lastCancelTarget&&this._debouncedCancel.cancel(),this._lastCancelTarget=o,this._debouncedCancel(n)}handleOk(n){var e,t;const o=(t=(e=n==null?void 0:n.currentTarget)!==null&&e!==void 0?e:n==null?void 0:n.target)!==null&&t!==void 0?t:null;o!==this._lastOkTarget&&this._debouncedOk.cancel(),this._lastOkTarget=o,this._debouncedOk(n)}_invokeCancel(n){var e;const t=this._adapter.notifyCancel(n);H(t)&&(this._adapter.setState({onCancelReturnPromiseStatus:"pending"}),(e=t==null?void 0:t.then(()=>{this._adapter.setState({onCancelReturnPromiseStatus:"fulfilled"})}))===null||e===void 0||e.catch(o=>{throw this._adapter.setState({onCancelReturnPromiseStatus:"rejected"}),o}))}_invokeOk(n){var e;const t=this._adapter.notifyOk(n);H(t)&&(this._adapter.setState({onOKReturnPromiseStatus:"pending"}),(e=t==null?void 0:t.then(()=>{this._adapter.setState({onOKReturnPromiseStatus:"fulfilled"})}))===null||e===void 0||e.catch(o=>{throw this._adapter.setState({onOKReturnPromiseStatus:"rejected"}),o}))}beforeShow(){this._adapter.disabledBodyScroll()}afterHide(){this._adapter.enabledBodyScroll(),this._adapter.notifyClose()}enabledBodyScroll(){this._adapter.enabledBodyScroll()}}class T extends Z{constructor(n){super(Object.assign(Object.assign({},T.defaultAdapter),n)),this.handleKeyDown=e=>{const{closeOnEsc:t}=this.getProps();if(t&&e.keyCode===oe.ESC){e.stopPropagation(),this.close(e);return}}}destroy(){this.handleKeyDownEventListenerUnmount(),this.modalDialogBlur(),this.prevFocusElementReFocus()}handleDialogMouseDown(){this._adapter.notifyDialogMouseDown()}handleMaskMouseUp(){this._adapter.notifyDialogMouseUp()}handleKeyDownEventListenerMount(){this._adapter.addKeyDownEventListener()}handleKeyDownEventListenerUnmount(){this._adapter.removeKeyDownEventListener()}getMouseState(){this._adapter.getMouseState()}handleMaskClick(n){const{dialogMouseDown:e}=this.getStates();n.target===n.currentTarget&&!e&&this.close(n)}close(n){this._adapter.notifyClose(n)}modalDialogFocus(){this._adapter.modalDialogFocus()}modalDialogBlur(){this._adapter.modalDialogBlur()}prevFocusElementReFocus(){this._adapter.prevFocusElementReFocus()}}var xe=Ce,je=ie,Ne=ae,Fe=je(function(s,n){return Ne(s)?xe(s,n):[]}),Ae=Fe;const Pe=se(Ae);class C{constructor(n,e){var t;this.addFocusRedirectListener=o=>(this.focusRedirectListenerList.push(o),()=>this.removeFocusRedirectListener(o)),this.removeFocusRedirectListener=o=>{this.focusRedirectListenerList=Pe(this.focusRedirectListenerList,o)},this.destroy=()=>{var o;(o=this.container)===null||o===void 0||o.removeEventListener("keydown",this.onKeyPress)},this.shouldFocusRedirect=o=>{if(!this.enable)return!1;for(const l of this.focusRedirectListenerList)if(!l(o))return!1;return!0},this.focusElement=(o,l)=>{const{preventScroll:c}=this.options;o==null||o.focus({preventScroll:c}),l.preventDefault()},this.onKeyPress=o=>{if(o&&o.key==="Tab"){const l=C.getFocusableElements(this.container);l.length&&(o.shiftKey?this.handleContainerShiftTabKeyDown(l,o):this.handleContainerTabKeyDown(l,o))}},this.handleContainerTabKeyDown=(o,l)=>{const c=C.getActiveElement(),r=o[o.length-1]===c,u=o[0];r&&this.shouldFocusRedirect(u)&&this.focusElement(u,l)},this.handleContainerShiftTabKeyDown=(o,l)=>{const c=C.getActiveElement(),r=o[0]===c,u=o[o.length-1];r&&this.shouldFocusRedirect(u)&&this.focusElement(u,l)},Object.freeze(e),this.container=n,this.options=e,this.enable=(t=e==null?void 0:e.enable)!==null&&t!==void 0?t:!0,this.focusRedirectListenerList=e!=null&&e.onFocusRedirectListener?Array.isArray(e.onFocusRedirectListener)?[...e.onFocusRedirectListener]:[e.onFocusRedirectListener]:[],this.container.addEventListener("keydown",this.onKeyPress)}get enable(){return this._enable}set enable(n){this._enable=n}static getFocusableElements(n){if(!le(n))return[];const t=["input:not([disabled]):not([tabindex='-1'])","textarea:not([disabled]):not([tabindex='-1'])","button:not([disabled]):not([tabindex='-1'])","a[href]:not([tabindex='-1'])","select:not([disabled]):not([tabindex='-1'])","area[href]:not([tabindex='-1'])","iframe:not([tabindex='-1'])","object:not([tabindex='-1'])","*[tabindex]:not([tabindex='-1'])","*[contenteditable]:not([tabindex='-1'])"].join(",");return Array.from(n.querySelectorAll(t))}static getActiveElement(){return document?document.activeElement:null}}var M=function(s,n){var e={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&n.indexOf(t)<0&&(e[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(s);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(s,t[o])&&(e[t[o]]=s[t[o]]);return e};let Re=0;class L extends q{constructor(n){super(n),this.onKeyDown=e=>{this.foundation.handleKeyDown(e)},this.onDialogMouseDown=()=>{this.foundation.handleDialogMouseDown()},this.onMaskMouseUp=()=>{this.foundation.handleMaskMouseUp()},this.onMaskClick=e=>{this.foundation.handleMaskClick(e)},this.close=e=>{this.foundation.close(e)},this.getMaskElement=()=>{const e=M(this.props,[]),{mask:t,maskClassName:o}=e;if(t){const l=m(`${d.DIALOG}-mask`,{});return a.createElement("div",Object.assign({key:"mask"},this.props.maskExtraProps,{className:m(l,o),style:e.maskStyle}))}return null},this.renderCloseBtn=()=>{const{closable:e,closeIcon:t}=this.props;let o;if(e){const l=t||a.createElement(ue,{"x-semi-prop":"closeIcon"});o=a.createElement(re,{"aria-label":"close",className:`${d.DIALOG}-close`,key:"close-btn",onClick:this.close,type:"tertiary",icon:l,theme:"borderless",size:"small"})}return o},this.renderIcon=()=>{const{icon:e}=this.props;return e?a.createElement("span",{className:`${d.DIALOG}-icon-wrapper`,"x-semi-prop":"icon"},e):null},this.renderHeader=()=>{if("header"in this.props)return this.props.header;const{title:e}=this.props,t=this.renderCloseBtn(),o=this.renderIcon();return e==null?null:a.createElement("div",{className:`${d.DIALOG}-header`},o,a.createElement(ce.Title,{heading:5,className:`${d.DIALOG}-title`,id:`${d.DIALOG}-title`,"x-semi-prop":"title"},e),t)},this.renderBody=()=>{const{bodyStyle:e,children:t,title:o}=this.props,l=m(`${d.DIALOG}-body`,{[`${d.DIALOG}-withIcon`]:this.props.icon}),c=this.renderCloseBtn(),r=this.renderIcon();return o!=null||"header"in this.props?a.createElement("div",{className:l,id:`${d.DIALOG}-body`,style:e,"x-semi-prop":"children"},t):a.createElement("div",{className:`${d.DIALOG}-body-wrapper`},r,a.createElement("div",{className:l,style:e,"x-semi-prop":"children"},t),c)},this.getDialogElement=()=>{const e=M(this.props,[]),t={},o=m(`${d.DIALOG}`,{[`${d.DIALOG}-centered`]:e.centered,[`${d.DIALOG}-${e.size}`]:e.size});e.width&&(t.width=e.width),e.height&&(t.height=e.height),e.isFullScreen&&(t.width="100%",t.height="100%",t.margin="unset");const l=this.renderBody(),c=this.renderHeader(),r=e.footer?a.createElement("div",{className:`${d.DIALOG}-footer`,"x-semi-prop":"footer"},e.footer):null,u=a.createElement("div",{role:"dialog",ref:this.modalDialogRef,"aria-modal":"true","aria-labelledby":`${d.DIALOG}-title`,"aria-describedby":`${d.DIALOG}-body`,onAnimationEnd:e.onAnimationEnd,className:m([`${d.DIALOG}-content`,e.contentClassName,{[`${d.DIALOG}-content-fullScreen`]:e.isFullScreen,[`${d.DIALOG}-content-height-set`]:e.height||G(e.style,"height")}])},c,l,r);return a.createElement("div",{key:"dialog-element",className:o,onMouseDown:this.onDialogMouseDown,style:Object.assign(Object.assign({},e.style),t),id:this.dialogId},e!=null&&e.modalRender?e==null?void 0:e.modalRender(u):u)},this.state={dialogMouseDown:!1,prevFocusElement:C.getActiveElement()},this.foundation=new T(this.adapter),this.dialogId=`dialog-${Re++}`,this.modalDialogRef=a.createRef()}get adapter(){return Object.assign(Object.assign({},super.adapter),{notifyClose:n=>{this.props.onClose(n)},notifyDialogMouseDown:()=>{this.setState({dialogMouseDown:!0})},notifyDialogMouseUp:()=>{this.state.dialogMouseDown&&(this.timeoutId=setTimeout(()=>{this.setState({dialogMouseDown:!1})},0))},addKeyDownEventListener:()=>{this.props.closeOnEsc&&document.addEventListener("keydown",this.foundation.handleKeyDown)},removeKeyDownEventListener:()=>{this.props.closeOnEsc&&document.removeEventListener("keydown",this.foundation.handleKeyDown)},getMouseState:()=>this.state.dialogMouseDown,modalDialogFocus:()=>{var n,e,t;const{preventScroll:o}=this.props;let l;if(this.modalDialogRef){const c=C.getActiveElement();l=this.modalDialogRef.current.contains(c),(n=this.focusTrapHandle)===null||n===void 0||n.destroy(),this.focusTrapHandle=new C(this.modalDialogRef.current,{preventScroll:o})}l||(t=(e=this.modalDialogRef)===null||e===void 0?void 0:e.current)===null||t===void 0||t.focus({preventScroll:o})},modalDialogBlur:()=>{var n,e;(n=this.modalDialogRef)===null||n===void 0||n.current.blur(),(e=this.focusTrapHandle)===null||e===void 0||e.destroy()},prevFocusElementReFocus:()=>{const{prevFocusElement:n}=this.state,{preventScroll:e}=this.props,t=G(n,"focus");de(t)&&n.focus({preventScroll:e})}})}componentDidMount(){var n;this.foundation.handleKeyDownEventListenerMount(),this.foundation.modalDialogFocus();const e=C.getFocusableElements(this.modalDialogRef.current);this.modalDialogRef.current.contains(document.activeElement)||(n=e[0])===null||n===void 0||n.focus()}componentWillUnmount(){clearTimeout(this.timeoutId),this.foundation.destroy()}render(){var n;const e=this.props,{maskClosable:t,className:o,getPopupContainer:l,maskFixed:c,getContainerContext:r}=e,u=M(e,["maskClosable","className","getPopupContainer","maskFixed","getContainerContext"]),{direction:b}=this.context,f=m(o,{[`${d.DIALOG}-popup`]:l&&l()!==((n=globalThis==null?void 0:globalThis.document)===null||n===void 0?void 0:n.body)&&!c,[`${d.DIALOG}-fixed`]:c,[`${d.DIALOG}-rtl`]:b==="rtl"}),h=r(),g=this.getDataAttr(u),O=a.createElement("div",Object.assign({className:f},g),this.getMaskElement(),a.createElement("div",Object.assign({role:"none",className:m({[`${d.DIALOG}-wrap`]:!0,[`${d.DIALOG}-wrap-center`]:this.props.centered}),onClick:t?this.onMaskClick:null,onMouseUp:t?this.onMaskMouseUp:null},this.props.contentExtraProps),this.getDialogElement()));return h&&h.Provider?a.createElement(h.Provider,{value:h.value},O):O}}L.contextType=he;L.propTypes={close:i.func,getContainerContext:i.func,contentClassName:i.string,maskClassName:i.string,onAnimationEnd:i.func,preventScroll:i.bool};L.defaultProps={close:D,getContainerContext:D,contentClassName:"",maskClassName:""};var $e=function(s,n){var e={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&n.indexOf(t)<0&&(e[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(s);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(s,t[o])&&(e[t[o]]=s[t[o]]);return e};const V=s=>{const[n,e]=E.useState(!0),[t,o]=E.useState(),[l,c]=E.useState(),{direction:r}=s,{title:u,content:b,icon:f,type:h,onCancel:g,onOk:O,className:I}=s,x=$e(s,["title","content","icon","type","onCancel","onOk","className"]),j=E.useCallback(w=>{const v=O&&O(w);v&&v.then?(o(!0),v.then(function(){e(!1),o(!1)},$=>{o(!1)})):e(!1)},[O]),N=E.useCallback(w=>{const v=g&&g(w);v&&v.then?(c(!0),v.then(function(){e(!1),c(!1)},$=>{c(!1)})):e(!1)},[g]),y=`${d.DIALOG}-confirm`,F=m(I,y,{[`${y}-rtl`]:r==="rtl"}),_=m(`${d.DIALOG}-${h}`),A=fe(f)?a.cloneElement(f,{className:`${y}-icon ${_}-icon`,size:"extra-large"}):f,P=u==null?null:a.createElement("span",{className:`${y}-title-text`},u),R=m(`${y}-content`,{[`${y}-content-withIcon`]:s.icon});return a.createElement(p,Object.assign({className:F,title:P,confirmLoading:t,cancelLoading:l,onOk:j,onCancel:N,icon:A,visible:n},x),a.createElement("div",{className:R,"x-semi-prop":"content"},b))};function S(s){const n=document.createElement("div");document.body.appendChild(n);let e=Object.assign({},s);const t=()=>{be(n),n.parentNode&&n.parentNode.removeChild(n);for(let r=0;r<k.length;r++)if(k[r]===l){k.splice(r,1);break}};function o(r){const{afterClose:u}=r;me(a.createElement(V,Object.assign({},r,{afterClose:()=>{u==null||u(),t()},motion:s.motion})),n)}function l(){e=Object.assign(Object.assign({},e),{visible:!1}),o(e)}function c(r){e=Object.assign(Object.assign({},e),r),o(e)}return o(e),k.push(l),{destroy:l,update:c}}function X(s){return Object.assign({type:"info",icon:a.createElement(Ee,null)},s)}function Y(s){return Object.assign({type:"success",icon:a.createElement(ke,null)},s)}function J(s){return Object.assign({type:"warning",icon:a.createElement(we,null)},s)}function Q(s){return Object.assign({type:"error",icon:a.createElement(De,null),okButtonProps:Object.assign({type:"danger"},s.okButtonProps)},pe(s,["okButtonProps"]))}function ee(s){return Object.assign({type:"confirm",icon:a.createElement(_e,null)},s)}var Me=function(s,n){var e={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&n.indexOf(t)<0&&(e[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(s);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(s,t[o])&&(e[t[o]]=s[t[o]]);return e};const Te=(s,n)=>{var{afterClose:e,config:t}=s;Me(s,["afterClose","config"]);const[o,l]=a.useState(t);a.useImperativeHandle(n,()=>({destroy:()=>{l(r=>Object.assign(Object.assign({},r),{visible:!1}))},update:r=>{l(u=>Object.assign(Object.assign({},u),r))}}));const c=()=>{var r;(r=t==null?void 0:t.afterClose)===null||r===void 0||r.call(t),e()};return a.createElement(V,Object.assign({},o,{afterClose:c}))},Be=a.forwardRef(Te);let W=0;function Ge(){const[s,n]=a.useState([]);function e(t){return n(o=>[...o,t]),()=>{n(o=>o.filter(l=>l!==t))}}return[s,e]}function Ke(){const[s,n]=Ge();function e(t){return function(l){W+=1;const c=a.createRef();let r;const u=a.createElement(Be,{key:`semi-modal-${W}`,config:t(l),ref:c,afterClose:()=>{r()}});return r=n(u),{destroy:()=>{c.current&&c.current.destroy()},update:b=>{c.current&&c.current.update(b)}}}}return[{info:e(X),success:e(Y),error:e(Q),warning:e(J),confirm:e(ee)},a.createElement(a.Fragment,null,s)]}var ze=function(s,n){var e={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&n.indexOf(t)<0&&(e[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(s);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(s,t[o])&&(e[t[o]]=s[t[o]]);return e};let k=[];class p extends q{constructor(n){super(n),this.bodyOverflow=null,this.handleCancel=e=>{this.foundation.handleCancel(e)},this.handleOk=e=>{this.foundation.handleOk(e)},this.updateState=()=>{const{visible:e}=this.props;this.foundation.toggleDisplayNone(!e)},this.renderFooter=()=>{const{okText:e,okType:t,cancelText:o,confirmLoading:l,cancelLoading:c,hasCancel:r,footerFill:u}=this.props,b=f=>{var h;return r?a.createElement(K,Object.assign({"aria-label":"cancel",onClick:this.handleCancel,loading:c===void 0?this.state.onCancelReturnPromiseStatus==="pending":c,type:"tertiary",block:u,autoFocus:!0},this.props.cancelButtonProps,{style:Object.assign(Object.assign({},u?{marginLeft:"unset"}:{}),(h=this.props.cancelButtonProps)===null||h===void 0?void 0:h.style),"x-semi-children-alias":"cancelText"}),o||f.cancel):null};return a.createElement(ge,{componentName:"Modal"},(f,h)=>a.createElement("div",{className:m({[`${d.DIALOG}-footerfill`]:u})},b(f),a.createElement(K,Object.assign({"aria-label":"confirm",type:t,theme:"solid",block:u,loading:l===void 0?this.state.onOKReturnPromiseStatus==="pending":l,onClick:this.handleOk},this.props.okButtonProps,{"x-semi-children-alias":"okText"}),e||f.confirm)))},this.renderDialog=()=>{var e;let t=this.props,{footer:o,className:l,motion:c,maskStyle:r,keepDOM:u,style:b,zIndex:f,getPopupContainer:h,visible:g,modalContentClass:O}=t,I=ze(t,["footer","className","motion","maskStyle","keepDOM","style","zIndex","getPopupContainer","visible","modalContentClass"]),x=b;const j=r,N="footer"in this.props?o:this.renderFooter();let y={zIndex:f};h&&h()!==((e=globalThis==null?void 0:globalThis.document)===null||e===void 0?void 0:e.body)&&(y={zIndex:f,position:"static"});const F=m(l,{[`${d.DIALOG}-displayNone`]:u&&this.state.displayNone}),_=this.props.visible||this.props.keepDOM&&(!this.props.lazyRender||this._haveRendered)||this.props.motion&&!this.state.displayNone;return _&&(this._haveRendered=!0),a.createElement(z,{motion:this.props.motion,animationState:g?"enter":"leave",startClassName:g?`${d.DIALOG}-content-animate-show`:`${d.DIALOG}-content-animate-hide`,onAnimationEnd:()=>{this.updateState()}},A=>{let{animationClassName:P,animationEventsNeedBind:R}=A;return a.createElement(z,{motion:this.props.motion,animationState:g?"enter":"leave",startClassName:g?`${d.DIALOG}-mask-animate-show`:`${d.DIALOG}-mask-animate-hide`,onAnimationEnd:()=>{this.updateState()}},w=>{let{animationClassName:v,animationEventsNeedBind:$}=w;return _?a.createElement(ye,{style:y,getPopupContainer:h}," ",a.createElement(L,Object.assign({},I,{contentExtraProps:R,maskExtraProps:$,isFullScreen:this.state.isFullScreen,contentClassName:`${P} ${O}`,maskClassName:v,className:F,getPopupContainer:h,maskStyle:j,style:x,ref:this.modalRef,footer:N,onClose:this.handleCancel}))):a.createElement(a.Fragment,null)})})},this.state={displayNone:!n.visible,isFullScreen:n.fullScreen},this.foundation=new Ie(this.adapter),this.modalRef=a.createRef(),this.scrollBarWidth=0,this.originBodyWidth="100%"}get adapter(){return Object.assign(Object.assign({},super.adapter),{getProps:()=>this.props,disabledBodyScroll:()=>{var n;const{getPopupContainer:e}=this.props;this.bodyOverflow=document.body.style.overflow||"",(!e||e()===((n=globalThis==null?void 0:globalThis.document)===null||n===void 0?void 0:n.body))&&this.bodyOverflow!=="hidden"&&(document.body.style.overflow="hidden",document.body.style.width=`calc(${this.originBodyWidth||"100%"} - ${this.scrollBarWidth}px)`)},enabledBodyScroll:()=>{var n;const{getPopupContainer:e}=this.props;(!e||e()===((n=globalThis==null?void 0:globalThis.document)===null||n===void 0?void 0:n.body))&&this.bodyOverflow!==null&&this.bodyOverflow!=="hidden"&&(document.body.style.overflow=this.bodyOverflow,document.body.style.width=this.originBodyWidth)},notifyCancel:n=>this.props.onCancel(n),notifyOk:n=>this.props.onOk(n),notifyClose:()=>{this.props.afterClose()},toggleDisplayNone:(n,e)=>{n!==this.state.displayNone&&this.setState({displayNone:n},e||D)},notifyFullScreen:n=>{n!==this.state.isFullScreen&&this.setState({isFullScreen:n})}})}static getDerivedStateFromProps(n,e){const t={};return n.fullScreen!==e.isFullScreen&&(t.isFullScreen=n.fullScreen),n.visible&&e.displayNone&&(t.displayNone=!1),t}componentDidMount(){this.scrollBarWidth=ve(),this.originBodyWidth=document.body.style.width,this.props.visible&&this.foundation.beforeShow()}componentDidUpdate(n,e,t){!n.visible&&this.props.visible&&this.foundation.beforeShow(),!e.displayNone&&this.state.displayNone&&this.foundation.afterHide()}componentWillUnmount(){this.props.visible?this.foundation.destroy():this.foundation.enabledBodyScroll()}render(){const{visible:n,keepDOM:e,lazyRender:t}=this.props;return this.renderDialog()}}p.propTypes={mask:i.bool,closable:i.bool,centered:i.bool,visible:i.bool,width:i.oneOfType([i.string,i.number]),height:i.oneOfType([i.string,i.number]),confirmLoading:i.bool,cancelLoading:i.bool,okText:i.string,okType:i.string,cancelText:i.string,maskClosable:i.bool,onCancel:i.func,onOk:i.func,modalRender:i.func,afterClose:i.func,okButtonProps:i.object,cancelButtonProps:i.object,style:i.object,className:i.string,maskStyle:i.object,bodyStyle:i.object,zIndex:i.number,title:i.node,icon:i.node,header:i.node,footer:i.node,hasCancel:i.bool,motion:i.bool,children:i.node,getPopupContainer:i.func,getContainerContext:i.func,maskFixed:i.bool,closeIcon:i.node,closeOnEsc:i.bool,size:i.oneOf(U.SIZE),keepDOM:i.bool,lazyRender:i.bool,direction:i.oneOf(U.directions),fullScreen:i.bool,footerFill:i.bool};p.__SemiComponentName__="Modal";p.defaultProps=Oe(p.__SemiComponentName__,{zIndex:1e3,motion:!0,mask:!0,centered:!1,closable:!0,visible:!1,okType:"primary",maskClosable:!0,hasCancel:!0,onCancel:D,onOk:D,afterClose:D,maskFixed:!1,closeOnEsc:!0,size:"small",keepDOM:!1,lazyRender:!0,fullScreen:!1});p.useModal=Ke;p.info=function(s){return S(X(s))};p.success=function(s){return S(Y(s))};p.error=function(s){return S(Q(s))};p.warning=function(s){return S(J(s))};p.confirm=function(s){return S(ee(s))};p.destroyAll=function(){for(let n=0,e=k.length;n<e;n++){const t=k[n];t&&t()}k=[]};export{p as M,H as i};