-
Notifications
You must be signed in to change notification settings - Fork 1
/
4112-63c1a9255eacd4d811bd.js
1 lines (1 loc) · 48.3 KB
/
4112-63c1a9255eacd4d811bd.js
1
(self.webpackChunkzent_docs=self.webpackChunkzent_docs||[]).push([[4112],{44112:(n,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>j});var t=a(73450),o=a(27378),e=a(57318),p=a(11497),c=a(3454),l=a(23476),r=a(24246);function i(n,s){var a=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);s&&(t=t.filter((function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable}))),a.push.apply(a,t)}return a}function u(n){for(var s=1;s<arguments.length;s++){var a=null!=arguments[s]?arguments[s]:{};s%2?i(Object(a),!0).forEach((function(s){(0,t.Z)(n,s,a[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(a)):i(Object(a)).forEach((function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(a,s))}))}return n}var k=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"showAlertInfo",(()=>{p.Hj.alert({content:"这个是具体内容",parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.showAlertInfo,children:"消息对话框"})}}return(0,r.jsx)(n,{})},d=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"onConfirm",(()=>{l.g.success("我真的知道了")})),(0,t.Z)(this,"onCancel",(()=>{l.g.error("我真的取消了")})),(0,t.Z)(this,"showAlertConfirm",(()=>{p.Hj.confirm({content:(0,r.jsx)("p",{children:"这个是内容"}),onConfirm:this.onConfirm,onCancel:this.onCancel,parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.showAlertConfirm,children:"消息对话框"})}}return(0,r.jsx)(n,{})},m=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"autoCloseConfirm",(()=>{var n=p.Hj.confirm({content:(0,r.jsx)("p",{children:"一秒后自动关闭"}),parentComponent:this});setTimeout(n,1e3)}))}render(){return(0,r.jsx)(c.z,{onClick:this.autoCloseConfirm,children:"自动关闭对话框"})}}return(0,r.jsx)(n,{})},f=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"promiseConfirm",(()=>{p.Hj.confirm({content:"点击确定后三秒自动关闭",title:"onConfirm返回Promise",onConfirm:()=>new Promise((n=>{setTimeout((()=>{n()}),3e3)})),parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.promiseConfirm,children:"自动关闭对话框(Promise)"})}}return(0,r.jsx)(n,{})},h=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"showAlertInfo",(()=>{p.Hj.alert({type:"info",content:"这个是具体内容",title:"这是一个消息标题",parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.showAlertInfo,children:"含有图标消息对话框"})}}return(0,r.jsx)(n,{})},y=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"showAlertConfirm",(()=>{p.Hj.alert({confirmType:"default",confirmText:"删除",content:"确认删除吗?",title:"请确认",parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.showAlertConfirm,children:"删除"})}}return(0,r.jsx)(n,{})},g=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"showAlertInfo",(()=>{p.Hj.alert({closeBtn:!0,maskClosable:!0,content:"这个是具体内容",parentComponent:this})}))}render(){return(0,r.jsx)(c.z,{onClick:this.showAlertInfo,children:"带有关闭按钮"})}}return(0,r.jsx)(n,{})};function v(n){return(0,r.jsx)(n.tag,u(u({},n.attributes),{},{dangerouslySetInnerHTML:{__html:n.html}}))}function C(n){return(0,r.jsx)(v,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function w(n){return(0,r.jsx)(v,{tag:"style",html:n.style})}function b(n,s){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(s+=n.offsetTop),b(n.parentNode,s);return s}class x extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"state",{showCode:!1}),(0,t.Z)(this,"toggle",(()=>{this.setState({showCode:!this.state.showCode})}))}render(){var n=this.state.showCode,s=this.props,a=s.title,t=s.src,o=s.children;return(0,r.jsxs)("div",{className:"zandoc-react-demo",children:[(0,r.jsx)("div",{className:"zandoc-react-demo__preview",children:o}),(0,r.jsxs)("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle,children:[(0,r.jsx)("div",{className:"zandoc-react-demo__title",children:(0,r.jsx)("p",{children:a||""})}),(0,r.jsx)("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle ".concat(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})]}),n&&(0,r.jsx)("pre",{className:"zandoc-react-demo__code",children:(0,r.jsx)(v,{tag:"code",html:t,attributes:{className:"language-jsx"}})})]})}}class j extends o.Component{componentDidMount(){var n=location.hash;if(n){var s=document.querySelector('a[href="'.concat(n,'"]'));s&&(0,e.l)(document.documentElement,0,b(s,-9))}}render(){return o.createElement("div",{className:"zandoc-react-container"},o.createElement(w,{style:""}),o.createElement(C,{html:'<h2 class="anchor-heading"><a href="#sweetalert-kuai-jie-dui-hua-kuang">¶</a><a href="javascript:void(0)" id="sweetalert-kuai-jie-dui-hua-kuang" class="anchor-point"></a>Sweetalert 快捷对话框</h2>\n<p>快速唤起 Dialog 组件</p>\n<h3 class="anchor-heading"><a href="#shi-yong-zhi-nan">¶</a><a href="javascript:void(0)" id="shi-yong-zhi-nan" class="anchor-point"></a>使用指南</h3>\n<ul>\n<li>组件不提供个性化选项,如有需要请使用 Dialog 组件。</li>\n</ul>\n<h3 class="anchor-heading"><a href="#dai-ma-yan-shi">¶</a><a href="javascript:void(0)" id="dai-ma-yan-shi" class="anchor-point"></a>代码演示</h3>'}),o.createElement(x,{title:"基础用法",id:"Demobasic",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">showAlertInfo</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(k)),o.createElement(x,{title:"带有确认和取消按钮",id:"Demowithbuttons",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Notify</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">onConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Notify</span><span class="token punctuation">.</span><span class="token method function property-access">success</span><span class="token punctuation">(</span><span class="token string">\'我真的知道了\'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">onCancel</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Notify</span><span class="token punctuation">.</span><span class="token method function property-access">error</span><span class="token punctuation">(</span><span class="token string">\'我真的取消了\'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">showAlertConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>这个是内容<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span><span class="token punctuation">,</span>\n <span class="token literal-property property">onConfirm</span><span class="token operator">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">onConfirm</span><span class="token punctuation">,</span>\n <span class="token literal-property property">onCancel</span><span class="token operator">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">onCancel</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">showAlertConfirm</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(d)),o.createElement(x,{title:"自动关闭",id:"Democlosedexternal",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">autoCloseConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">const</span> close <span class="token operator">=</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>一秒后自动关闭<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\n <span class="token function">setTimeout</span><span class="token punctuation">(</span>close<span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">autoCloseConfirm</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>自动关闭对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(m)),o.createElement(x,{title:"回调返回 Promise",id:"Demoreturnpromise",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">promiseConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">\'点击确定后三秒自动关闭\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">title</span><span class="token operator">:</span> <span class="token string">\'onConfirm返回Promise\'</span><span class="token punctuation">,</span>\n <span class="token function-variable function">onConfirm</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">promiseConfirm</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token function">自动关闭对话框</span><span class="token punctuation">(</span><span class="token known-class-name class-name">Promise</span><span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(f)),o.createElement(x,{title:"标题旁带有 icon 的 Dialog",id:"Demowithicon",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">type</span><span class="token operator">:</span> <span class="token string">\'info\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">title</span><span class="token operator">:</span> <span class="token string">\'这是一个消息标题\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">showAlertInfo</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>含有图标消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(h)),o.createElement(x,{title:"支持设置 Dialog 中的 button 类型",id:"Demobuttontype",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">confirmType</span><span class="token operator">:</span> <span class="token string">\'default\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">confirmText</span><span class="token operator">:</span> <span class="token string">\'删除\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">\'确认删除吗?\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">title</span><span class="token operator">:</span> <span class="token string">\'请确认\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">showAlertConfirm</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>删除<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(y)),o.createElement(x,{title:"带有右上角的关闭按钮",id:"Demowithclosebtn",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">,</span> <span class="token maybe-class-name">Button</span> <span class="token punctuation">}</span></span> <span class="token keyword module">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token maybe-class-name">Sweetalert</span><span class="token punctuation">.</span><span class="token method function property-access">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n <span class="token literal-property property">closeBtn</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>\n <span class="token literal-property property">maskClosable</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>\n <span class="token literal-property property">content</span><span class="token operator">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n <span class="token literal-property property">parentComponent</span><span class="token operator">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token property-access">showAlertInfo</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>带有关闭按钮<span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\n<span class="token maybe-class-name">ReactDOM</span><span class="token punctuation">.</span><span class="token method function property-access">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Wrapper</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(g)),o.createElement(C,{html:"<h3 class=\"anchor-heading\"><a href=\"#api\">¶</a><a href=\"javascript:void(0)\" id=\"api\" class=\"anchor-point\"></a>API</h3>\n<h4 class=\"anchor-heading\"><a href=\"#alert\">¶</a><a href=\"javascript:void(0)\" id=\"alert\" class=\"anchor-point\"></a>alert</h4>\n<table class=\"table\">\n<thead>\n<tr>\n<th>参数</th>\n<th>说明</th>\n<th>类型</th>\n<th>默认值</th>\n<th>备选值</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>content</td>\n<td>弹窗中的内容</td>\n<td>node</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>type</td>\n<td>弹窗的类型, 设置会在 title 左边显示一个小图标, 不传不会显示图标</td>\n<td>string</td>\n<td>-</td>\n<td><code>'info'</code>\n, \n<code>'success'</code>\n, \n<code>'error'</code>\n, \n<code>'warning'</code></td>\n</tr>\n<tr>\n<td>title</td>\n<td>弹窗的标题</td>\n<td>node</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onConfirm</td>\n<td>确定操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmText</td>\n<td>确定按钮文案</td>\n<td>string</td>\n<td><code>'我知道了'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmType</td>\n<td>确定按钮的类型</td>\n<td>string</td>\n<td><code>'primary'</code></td>\n<td><code>'default'</code>\n、\n<code>'primary'</code></td>\n</tr>\n<tr>\n<td>closeBtn</td>\n<td>是否显示右上角关闭按钮</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maskClosable</td>\n<td>点击遮罩是否可以关闭</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>parentComponent</td>\n<td>父级组件实例,i18n 需要通过这个传递 context</td>\n<td>ReactInstance</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>className</td>\n<td>额外的 className</td>\n<td>string</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<h4 class=\"anchor-heading\"><a href=\"#confirm\">¶</a><a href=\"javascript:void(0)\" id=\"confirm\" class=\"anchor-point\"></a>confirm</h4>\n<table class=\"table\">\n<thead>\n<tr>\n<th>参数</th>\n<th>说明</th>\n<th>类型</th>\n<th>默认值</th>\n<th>备选值</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>content</td>\n<td>弹窗中的内容</td>\n<td>node</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>type</td>\n<td>弹窗的类型, 设置会在 title 左边显示一个小图标, 不传不会显示图标</td>\n<td>string</td>\n<td>-</td>\n<td><code>'info'</code>\n, \n<code>'success'</code>\n, \n<code>'error'</code>\n, \n<code>'warning'</code></td>\n</tr>\n<tr>\n<td>title</td>\n<td>弹窗的标题</td>\n<td>node</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onCancel</td>\n<td>取消操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onConfirm</td>\n<td>确定操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>cancelText</td>\n<td>取消按钮文案</td>\n<td>string</td>\n<td><code>'取消'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmText</td>\n<td>确定按钮文案</td>\n<td>string</td>\n<td><code>'确定'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmType</td>\n<td>确定按钮的类型</td>\n<td>string</td>\n<td><code>'primary'</code></td>\n<td><code>'default'</code>\n、\n<code>'primary'</code></td>\n</tr>\n<tr>\n<td>closeBtn</td>\n<td>是否显示右上角关闭按钮</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maskClosable</td>\n<td>点击遮罩是否可以关闭</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>className</td>\n<td>额外的 className</td>\n<td>string</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li><code>Sweetalert.alert</code> 和 <code>Sweetalert.confirm</code> 的返回值是可以用来手动关闭对话框的函数。</li>\n<li>如果 <code>onConfirm</code> 的返回值是 <code>Promise</code>, 对应的按钮会在 <code>Promise</code> pending 时保持在 loading 状态;如果 <code>Promise</code> reject,对话框不会关闭,如果 <code>Promise</code> resolve 对话框关闭。</li>\n<li>如果 <code>onConfirm</code> 没有参数并且返回值是 <code>false</code> 对话框不会关闭。</li>\n<li>如果 <code>onConfirm</code> 有一个参数的话,需要手动调用 <code>close</code> 这个参数来关闭对话框。</li>\n</ul>"}))}}},97701:(n,s,a)=>{"use strict";a.d(s,{V:()=>N,Z:()=>O});var t=a(59312),o=a(24246),e=a(27378),p=a(14623),c=a(53552),l=a(79352),r=a(60042),i=a.n(r),u=a(58801),k=a(27036),d=function(n){function s(){var s=null!==n&&n.apply(this,arguments)||this;return s.dialogEl=null,s.onClickClose=function(n){var a=s.props.onClose;a&&a(n)},s}return(0,t.ZT)(s,n),s.prototype.componentDidMount=function(){this.resetTransformOrigin()},s.prototype.componentDidUpdate=function(){this.resetTransformOrigin()},s.prototype.setTransformOrigin=function(n,s){["Webkit","Moz","Ms","ms"].forEach((function(a){n[a+"TransformOrigin"]=s})),n.transformOrigin=s},s.prototype.resetTransformOrigin=function(n){void 0===n&&(n=this.props);var s=n.mousePosition,a=function(n,s){switch(n){case"center":return"center center 0";case"auto":default:return}}(n.position,this.dialogEl);if(void 0===a&&s&&s.x>=0&&s.y>=0&&this.dialogEl&&this.dialogEl.getBoundingClientRect){var t=this.dialogEl.getBoundingClientRect(),o=t.left,e=t.top;a=s.x-o+"px "+(s.y-e)+"px 0"}a&&this.dialogEl&&this.setTransformOrigin(this.dialogEl.style,a)},s.prototype.renderHeader=function(){var n=this.props.title;return n?(n="number"==typeof n||"string"==typeof n?(0,o.jsx)("span",(0,t.pi)({className:"zent-dialog-r-title-text","data-zv":"10.0.10"},{children:n}),void 0):n,(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-header","data-zv":"10.0.10"},{children:(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-title","data-zv":"10.0.10"},{children:n}),void 0)}),void 0)):null},s.prototype.render=function(){var n=this,s=this.props,a=s.className,e=s.closeBtn,p=s.footer,c=s.style,l=s.children,r=this.renderHeader(),u=i()("zent-dialog-r-close",{"zent-dialog-r-has-title":!!r}),d=e&&(0,o.jsx)("button",(0,t.pi)({type:"button",className:u,onClick:this.onClickClose,"data-zv":"10.0.10"},{children:(0,o.jsx)(k.Z,{type:"close"},void 0)}),void 0),m=p&&(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-footer","data-zv":"10.0.10"},{children:p}),void 0);return(0,o.jsxs)("div",(0,t.pi)({className:i()("zent-dialog-r",a,{"zent-dialog-r--has-header":!!r,"zent-dialog-r--has-footer":!!m,"zent-dialog-r--no-close-btn":!d}),style:c,ref:function(s){return n.dialogEl=s},"data-zv":"10.0.10"},{children:[d,r,(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-body","data-zv":"10.0.10"},{children:(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-body-content","data-zv":"10.0.10"},{children:l}),void 0)}),void 0),m]}),void 0)},s}(e.Component),m=function(n){function s(){var s=null!==n&&n.apply(this,arguments)||this;return s.rootRef=(0,e.createRef)(),s.onMaskClick=function(n){n.target===n.currentTarget&&s.props.mask&&s.props.maskClosable&&s.props.onClose(n)},s}return(0,t.ZT)(s,n),s.prototype.componentDidMount=function(){var n=document.activeElement,s=this.rootRef.current;s!==n&&s&&!s.contains(n)&&function(n){if(n){var s=(0,u.Z)();n.focus(),window.scroll(s.x,s.y)}}(s)},s.prototype.render=function(){var n=this.props,s=n.mask,a=n.visible,e=n.children;return(0,o.jsxs)("div",(0,t.pi)({ref:this.rootRef,tabIndex:-1,className:"zent-dialog-r-root","data-zv":"10.0.10"},{children:[a&&s&&(0,o.jsx)("div",{className:"zent-dialog-r-backdrop","data-zv":"10.0.10"},void 0),(0,o.jsx)("div",(0,t.pi)({className:"zent-dialog-r-wrap",onClick:this.onMaskClick,"data-zv":"10.0.10"},{children:e}),void 0)]}),void 0)},s}(e.Component),f=a(31542),h=a.t(f,2),y=a(70453),g=a(42690),v=a(14805),C=new Map,w=function(n){function s(){var s=null!==n&&n.apply(this,arguments)||this;return s.state={visible:!0},s.closeOptions={},s.onClosed=function(){var n=s.props,a=n.options.onClose,t=n.container,o=s.closeOptions.triggerOnClose;(void 0===o||o)&&a&&a(),f.unmountComponentAtNode(t)},s.onClose=function(n){s.close({triggerOnClose:!1!==n})},s}return(0,t.ZT)(s,n),s.prototype.close=function(n){void 0===n&&(n={}),this.closeOptions=n,this.setState({visible:!1})},s.prototype.componentWillUnmount=function(){var n=this.props.options.dialogId;C.delete(n)},s.prototype.render=function(){var n=this.props.options,s=this.state.visible;return(0,o.jsx)(O,(0,t.pi)({},n,{onClose:this.onClose,onClosed:this.onClosed,visible:s}),void 0)},s}(e.Component);function b(n,s){void 0===s&&(s={});var a=C.get(n);if(a){var t=a.current;t&&t.close(s)}}function x(n){if(void 0===n&&(n={}),!l.Z)return g.Z;var s=n.dialogId,a=void 0===s?(0,y.Z)("__zent-dialog__"):s,p=n.parentComponent;!function(n){if(C.has(n))throw new Error("Duplicate dialog id found: "+n)}(a);var c=(0,v.Z)("div"),r=p?f.unstable_renderSubtreeIntoContainer.bind(h,p):f.render,i=(0,e.createRef)();return r((0,o.jsx)(w,{ref:i,options:(0,t.pi)((0,t.pi)({},n),{dialogId:a}),container:c},void 0),c),function(n,s){C.set(n,s)}(a,i),function(n){void 0===n&&(n=!0),b(a,{triggerOnClose:!1!==n})}}var j=a(49744),z=null;l.Z&&(0,j.Oo)(document.documentElement,"click",(function(n){0!==n.clientX&&0!==n.clientY&&(z={x:n.clientX,y:n.clientY})}),{capture:!0});var N=function(n){function s(s){var a=n.call(this,s)||this;return a.lastMousePosition=null,a.onClose=function(n){var s=a.props.onClose;s&&s(n)},a.onExited=function(){var n=a.props.onClosed;a.setState({exiting:!1}),n&&n()},a.state={prevOpen:s.visible,exiting:!1},a}return(0,t.ZT)(s,n),s.getDerivedStateFromProps=function(n,s){var a=s.prevOpen;return n.visible===a?null:n.visible?{prevOpen:n.visible,exiting:!1}:{prevOpen:n.visible,exiting:!0}},s.prototype.render=function(){var n=this.props,s=n.visible,a=n.closeBtn,e=n.style,l=n.position,r=n.onOpened,i=(n.onClosed,n.mask),u=n.maskClosable,k=n.children,f=(0,t._T)(n,["visible","closeBtn","style","position","onOpened","onClosed","mask","maskClosable","children"]),h=this.state.exiting;return this.lastMousePosition=s?this.lastMousePosition||z:null,(0,o.jsx)(c.ZP,(0,t.pi)({visible:s||h,onClose:this.onClose,className:"zent-dialog-r-anchor",closeOnESC:a,blockPageScroll:!0},{children:(0,o.jsx)(m,(0,t.pi)({mask:i,maskClosable:u,visible:s,onClose:this.onClose},{children:(0,o.jsx)(p.Z,(0,t.pi)({appear:!0,mountOnEnter:!0,unmountOnExit:!0,in:s,timeout:300,classNames:"zent-zoom",onEntered:r,onExited:this.onExited},{children:(0,o.jsx)(d,(0,t.pi)({},f,{style:e,closeBtn:a,position:l,mousePosition:this.lastMousePosition},{children:k}),void 0)}),void 0)}),void 0)}),void 0)},s.defaultProps={onClose:function(){},visible:!1,className:"",style:{},position:"auto",title:"",closeBtn:!0,mask:!0,maskClosable:!0,footer:null},s.openDialog=x,s.closeDialog=b,s}(e.Component),O=N},11497:(n,s,a)=>{"use strict";a.d(s,{Hj:()=>g});var t=a(59312),o=a(24246),e=a(60042),p=a.n(e),c=a(52074),l=a(97701).Z,r=a(27036),i=a(27378),u=a(90347),k=a(65436),d=function(n){function s(){var s=null!==n&&n.apply(this,arguments)||this;return s.state={loading:!1},s.onClick=function(){var n=s.props,a=n.onClick,t=(0,n.getClose)();if(!a)return t();var o=a.length>0,e=o?a(t):a();if((0,k.Z)(e))return s.setState({loading:!0}),void e.then((function(){t()}),(function(){s.setState({loading:!1})}));o||!1===e||t()},s}return(0,t.ZT)(s,n),s.prototype.render=function(){var n=this.props,s=n.className,a=n.type,e=n.text,p=this.state.loading;return(0,o.jsx)(u.ZP,(0,t.pi)({type:a,className:s,loading:p,onClick:this.onClick},{children:e}),void 0)},s}(i.Component),m={info:"info-circle-o",success:"check-circle-o",error:"close-circle-o",warning:"warning-o"},f=l.openDialog;function h(n,s){var a,e=n.className,l=void 0===e?"":e,i=n.confirmType,u=void 0===i?"primary":i,k=n.closeBtn,h=void 0!==k&&k,y=n.maskClosable,g=void 0!==y&&y,v=n.title,C=n.type,w=n.content,b=n.onConfirm,x=n.onCancel,j=n.confirmText,z=n.cancelText,N=n.parentComponent,O=n.onClose,E=null;return E=f({closeBtn:h,maskClosable:g,className:p()("zent-sweetalert-"+s,(a={},a[l]=!!l,a)),title:(0,o.jsx)(c.Z,(0,t.pi)({componentName:"Sweetalert"},{children:function(n){var s=m[C];return(0,o.jsxs)("div",(0,t.pi)({className:"zent-sweetalert-"+(C?"icon-":"")+"title","data-zv":"10.0.10"},{children:[C&&(0,o.jsx)(r.Z,{className:"zent-sweetalert-type-icon",type:s},void 0),v||n.title]}),void 0)}}),void 0),children:w,footer:(0,o.jsx)(c.Z,(0,t.pi)({componentName:"Sweetalert"},{children:function(n){var a="alert"===s;return(0,o.jsxs)("div",(0,t.pi)({className:"sweet-"+s+"-actions","data-zv":"10.0.10"},{children:[!a&&(0,o.jsx)(d,{type:"default",className:"zent-sweetalert-"+s+"-btn-cancel",getClose:function(){return E},onClick:x,text:z||n.cancel},"sweetalert-cancel"),(0,o.jsx)(d,{type:u,className:"zent-sweetalert-"+s+"-btn-confirm",getClose:function(){return E},onClick:b,text:j||(a?n.ok:n.confirm)},"sweetalert-confirm")]}),void 0)}}),void 0),parentComponent:N,onClose:O})}function y(n){return void 0===n&&(n={}),h(n,"alert")}var g={alert:y,info:y,confirm:function(n){return void 0===n&&(n={}),h(n,"confirm")}}},58801:(n,s,a)=>{"use strict";function t(){var n=window.pageXOffset,s=window.pageYOffset;return{x:void 0!==n?n:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==s?s:(document.documentElement||document.body.parentNode||document.body).scrollTop}}a.d(s,{Z:()=>t})}}]);