-
Notifications
You must be signed in to change notification settings - Fork 1
/
3051-78e75e12884e6def2821.js
1 lines (1 loc) · 49.2 KB
/
3051-78e75e12884e6def2821.js
1
(self.webpackChunkzent_docs=self.webpackChunkzent_docs||[]).push([[3051],{63051:(n,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>f});var t=a(73450),o=a(27378),p=a(57318),e=a(81044),c=a(3454),l=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 r=function(){return(0,l.jsxs)(e.J,{className:"zent-doc-popover",position:e.J.Position.BottomLeft,cushion:5,children:[(0,l.jsx)(e.J.Trigger.Click,{children:(0,l.jsx)(c.z,{type:"primary",children:"Click to Open"})}),(0,l.jsxs)(e.J.Content,{children:[(0,l.jsx)("div",{children:"Popover content"}),(0,l.jsx)("div",{children:"You can add anything here"})]})]})},k=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"state",{visible:!1})}render(){return(0,l.jsxs)("div",{className:"zent-doc-popover-container",children:[(0,l.jsxs)(e.J,{className:"zent-doc-popover",visible:this.state.visible,onVisibleChange:n=>this.setState({visible:n}),position:e.J.Position.BottomLeft,cushion:5,children:[(0,l.jsx)(e.J.Trigger.Base,{children:(0,l.jsx)(c.z,{type:"primary",onClick:()=>this.setState({visible:!0}),children:"Click to Open"})}),(0,l.jsxs)(e.J.Content,{children:[(0,l.jsx)("div",{children:"Popover content"}),(0,l.jsx)("div",{children:"You can add anything here"})]})]}),(0,l.jsx)(c.z,{onClick:()=>this.setState({visible:!1}),children:"Close"})]})}}return(0,l.jsx)(n,{})},d=function(){class n extends o.Component{constructor(...n){super(...n),(0,t.Z)(this,"state",{visible:!0}),(0,t.Z)(this,"onVisibleChange",(n=>{this.setState({visible:n})}))}render(){return(0,l.jsxs)(e.J,{className:"zent-doc-popover",position:e.J.Position.BottomLeft,cushion:5,children:[(0,l.jsx)(e.J.Trigger.Click,{children:(0,l.jsx)(c.z,{type:"primary",children:"Click to Open"})}),(0,l.jsxs)(e.J.Content,{children:[(0,l.jsx)("div",{children:"Popover content"}),(0,l.jsxs)(e.J,{className:"zent-doc-popover",position:e.J.Position.BottomLeft,cushion:5,visible:this.state.visible,onVisibleChange:this.onVisibleChange,children:[(0,l.jsx)(e.J.Trigger.Click,{children:(0,l.jsx)(c.z,{type:"primary",children:"Click to Open"})}),(0,l.jsx)(e.J.Content,{children:(0,l.jsx)("div",{children:"Nested popover content"})})]})]})]})}}return(0,l.jsx)(n,{})},m=function(){var n=e.J.withPopover((function({popover:n}){return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{children:"Popover content"}),(0,l.jsx)(c.z,{onClick:n.close,children:"Close"})]})}));return(0,l.jsxs)(e.J,{className:"zent-doc-popover",position:e.J.Position.BottomLeft,cushion:5,children:[(0,l.jsx)(e.J.Trigger.Click,{children:(0,l.jsx)(c.z,{type:"primary",children:"Click to Open"})}),(0,l.jsx)(e.J.Content,{children:(0,l.jsx)(n,{})})]})};function h(n){return(0,l.jsx)(n.tag,u(u({},n.attributes),{},{dangerouslySetInnerHTML:{__html:n.html}}))}function g(n){return(0,l.jsx)(h,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function v(n){return(0,l.jsx)(h,{tag:"style",html:n.style})}function y(n,s){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(s+=n.offsetTop),y(n.parentNode,s);return s}class b 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,l.jsxs)("div",{className:"zandoc-react-demo",children:[(0,l.jsx)("div",{className:"zandoc-react-demo__preview",children:o}),(0,l.jsxs)("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle,children:[(0,l.jsx)("div",{className:"zandoc-react-demo__title",children:(0,l.jsx)("p",{children:a||""})}),(0,l.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,l.jsx)("pre",{className:"zandoc-react-demo__code",children:(0,l.jsx)(h,{tag:"code",html:t,attributes:{className:"language-jsx"}})})]})}}class f extends o.Component{componentDidMount(){var n=location.hash;if(n){var s=document.querySelector('a[href="'.concat(n,'"]'));s&&(0,p.l)(document.documentElement,0,y(s,-9))}}render(){return o.createElement("div",{className:"zandoc-react-container"},o.createElement(v,{style:".zent-doc-popover {\n\tborder: 1px solid #e5e5e5;\n\tpadding: 10px;\n\tborder-radius: 4px;\n\tbackground: #fff;\n\tfont-size: 14px;\n}\n\n.zent-doc-popover-container .zent-popover-wrapper {\n\t\tmargin-right: 10px;\n\t}"}),o.createElement(g,{html:'<h2 class="anchor-heading"><a href="#popover">¶</a><a href="javascript:void(0)" id="popover" class="anchor-point"></a>Popover</h2>\n<p>Common trigger pop widget, you can customize postion、trigger method、display style.</p>\n<p>The widget supports nested pop</p>\n<p><strong>The widget do not support style, if you need bubble-like tips component, please use <code>Pop</code>.</strong></p>\n<h3 class="anchor-heading"><a href="#guides">¶</a><a href="javascript:void(0)" id="guides" class="anchor-point"></a>Guides</h3>\n<ul>\n<li>If <code>Pop</code> widget do not meet your needs, you can achieve custom trigger pop by using <code>Popover</code></li>\n<li>Can be used as <code>Dropdown</code></li>\n</ul>\n<h3 class="anchor-heading"><a href="#demos">¶</a><a href="javascript:void(0)" id="demos" class="anchor-point"></a>Demos</h3>'}),o.createElement(b,{title:"Basic usage",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">Popover</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 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">Popover</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover<span class="token punctuation">"</span></span>\n <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">Position</span></span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">BottomLeft</span></span><span class="token punctuation">}</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span></span>\n <span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <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">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Click</span> to <span class="token maybe-class-name">Open</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">Popover</span> content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">You</span> can add anything here<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover</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(r)),o.createElement(b,{title:"Controlled open/close",id:"Democontrolled",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Popover</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">PopoverDemo</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>\n state <span class="token operator">=</span> <span class="token punctuation">{</span>\n <span class="token literal-property property">visible</span><span class="token operator">:</span> <span class="token boolean">false</span>\n <span class="token punctuation">}</span><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 punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover-container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover<span class="token punctuation">"</span></span>\n <span class="token attr-name">visible</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">state</span><span class="token punctuation">.</span><span class="token property-access">visible</span><span class="token punctuation">}</span></span>\n <span class="token attr-name">onVisibleChange</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token parameter">v</span> <span class="token arrow operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token method function property-access">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">visible</span><span class="token operator">:</span> v <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span>\n <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">Position</span></span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">BottomLeft</span></span><span class="token punctuation">}</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Trigger.Base</span></span><span class="token punctuation">></span></span>\n <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">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</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 punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token method function property-access">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">visible</span><span class="token operator">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Click</span> to <span class="token maybe-class-name">Open</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Trigger.Base</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">Popover</span> content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">You</span> can add anything here<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover</span></span><span class="token punctuation">></span></span>\n\n <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 punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token method function property-access">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">visible</span><span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Close</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</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">PopoverDemo</span></span> <span class="token punctuation">/></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(k)),o.createElement(b,{title:"Nested",id:"Demonested",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Popover</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">Demo</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 state <span class="token operator">=</span> <span class="token punctuation">{</span>\n <span class="token literal-property property">visible</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">;</span>\n\n <span class="token function-variable function">onVisibleChange</span> <span class="token operator">=</span> <span class="token parameter">visible</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token method function property-access">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n visible<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 punctuation">}</span><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 punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover<span class="token punctuation">"</span></span>\n <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">Position</span></span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">BottomLeft</span></span><span class="token punctuation">}</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span></span>\n <span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <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">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Click</span> to <span class="token maybe-class-name">Open</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">Popover</span> content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover<span class="token punctuation">"</span></span>\n <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">Position</span></span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">BottomLeft</span></span><span class="token punctuation">}</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span></span>\n <span class="token attr-name">visible</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">state</span><span class="token punctuation">.</span><span class="token property-access">visible</span><span class="token punctuation">}</span></span>\n <span class="token attr-name">onVisibleChange</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">onVisibleChange</span><span class="token punctuation">}</span></span>\n <span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <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">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Click</span> to <span class="token maybe-class-name">Open</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">Nested</span> popover content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover</span></span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</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><span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Demo</span></span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(d)),o.createElement(b,{title:"withPopover HOC",id:"Demohoc",src:'<span class="token keyword module">import</span> <span class="token imports"><span class="token punctuation">{</span> <span class="token maybe-class-name">Popover</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">const</span> <span class="token maybe-class-name">Content</span> <span class="token operator">=</span> <span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token method function property-access">withPopover</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token function"><span class="token maybe-class-name">Content</span></span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> popover <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword control-flow">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span><span class="token maybe-class-name">Popover</span> content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <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>popover<span class="token punctuation">.</span><span class="token property-access">close</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Close</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <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\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">Popover</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>zent-doc-popover<span class="token punctuation">"</span></span>\n <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token maybe-class-name">Popover</span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">Position</span></span><span class="token punctuation">.</span><span class="token property-access"><span class="token maybe-class-name">BottomLeft</span></span><span class="token punctuation">}</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <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">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token maybe-class-name">Click</span> to <span class="token maybe-class-name">Open</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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Trigger.Click</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span><span class="token class-name">Content</span></span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover.Content</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span><span class="token class-name">Popover</span></span><span class="token punctuation">></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},o.createElement(m)),o.createElement(g,{html:'<h3 class="anchor-heading"><a href="#api">¶</a><a href="javascript:void(0)" id="api" class="anchor-point"></a>API</h3>\n<table class="table">\n<thead>\n<tr>\n<th>Property</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n<th>Alternative</th>\n<th>Required</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>position</td>\n<td>Position way, refer to \n<code>Popover.Positon</code></td>\n<td>Positon</td>\n<td></td>\n<td></td>\n<td>Yes</td>\n</tr>\n<tr>\n<td>cushion</td>\n<td>Position offset, generally it reserves a space for some icon like arrow</td>\n<td>number</td>\n<td><code>0</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onShow</td>\n<td>Callback after pop shows</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onClose</td>\n<td>Callback after pop closes</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onBeforeShow</td>\n<td>Callback before pop opens, only triggered by user\'s operation, setting \n<code>visible</code>\n outside will not call</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onBeforeClose</td>\n<td>Callback after pop closes, only triggered by user\'s operation, setting \n<code>visible</code>\n outside will not call</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n<td></td>\n</tr>\n<tr>\n<td>containerSelector</td>\n<td>Pop\'s parent node CSS selector</td>\n<td>string</td>\n<td><code>\'body\'</code></td>\n<td>all legal CSS selector</td>\n<td>No</td>\n</tr>\n<tr>\n<td>visible</td>\n<td>Manually control pop\'s show or hide, must be used with \n<code>onVisibleChange</code></td>\n<td>bool</td>\n<td></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onVisibleChange</td>\n<td>Callback when manual control, must be used with \n<code>visible</code>\n, only triggered by user\'s open/close operation</td>\n<td>func</td>\n<td></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onPositionUpdated</td>\n<td>Callback after position updates, a position update does not imply a position change</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>onPositionReady</td>\n<td>Callback after content enters viewport, only called once within the life cycle</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>className</td>\n<td>Custom extra content class name</td>\n<td>string</td>\n<td><code>\'\'</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>style</td>\n<td>Custom content styles</td>\n<td><code>CssProperties</code></td>\n<td></td>\n<td></td>\n<td>否</td>\n</tr>\n</tbody>\n</table>\n<p><code>onBeforeShow</code> and <code>onBeforeClose</code> will return a <code>Promise</code>,<code>Popover</code> will open/close after <code>Promise</code> resolve,if <code>Promise</code> reject, open/close opreation will stop.</p>\n<p>If you do not use <code>Promise</code>, <code>onBeforeShow</code> and <code>onBeforeClose</code> also supports two arguments <code>callback</code> and <code>escapse</code>, you have to manual call <code>callback</code> to open/close in <code>onBeforeShow</code> and <code>onBeforeClose</code>. manual call <code>escape</code> to stop open/close opreation.</p>\n<p><code>onBeforeShow(callback: ?function, escape: ?escape): ?Promise</code></p>\n<p>Every kinds of trigger has it\'s own API to control component behavior, custom trigger can specifies it\'s parameter.</p>\n<h4 class="anchor-heading"><a href="#trigger-click">¶</a><a href="javascript:void(0)" id="trigger-click" class="anchor-point"></a>Trigger.Click</h4>\n<table class="table">\n<thead>\n<tr>\n<th>Property</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n<th>Required</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>closeOnClickOutside</td>\n<td>whether to auto close pop when click \n<code>outside</code></td>\n<td>bool</td>\n<td><code>true</code></td>\n<td>No</td>\n</tr>\n<tr>\n<td>toggle</td>\n<td>Toggle mode | boolean</td>\n<td><code>false</code></td>\n<td>No</td>\n<td></td>\n</tr>\n<tr>\n<td>getElement</td>\n<td>Customize trigger DOM node</td>\n<td>(node: Element</td>\n<td>Text</td>\n<td>null) => Element</td>\n</tr>\n</tbody>\n</table>\n<h4 class="anchor-heading"><a href="#trigger-hover">¶</a><a href="javascript:void(0)" id="trigger-hover" class="anchor-point"></a>Trigger.Hover</h4>\n<table class="table">\n<thead>\n<tr>\n<th>Property</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n<th>Required</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>showDelay</td>\n<td>the duration before layer open (in milliseconds), during this time, if you move mouse out of layer, pop will not open</td>\n<td>number</td>\n<td><code>150</code></td>\n<td>No</td>\n</tr>\n<tr>\n<td>hideDelay</td>\n<td>the duration before layer close (in milliseconds), during this time, if you move mouse out of layer, pop will not close</td>\n<td>number</td>\n<td><code>150</code></td>\n<td>No</td>\n</tr>\n<tr>\n<td>getElement</td>\n<td>Customize trigger DOM node</td>\n<td>(node: Element</td>\n<td>Text</td>\n<td>null) => Element</td>\n</tr>\n<tr>\n<td>anchorOnly</td>\n<td>Only use trigger as hot area</td>\n<td>boolean</td>\n<td><code>false</code></td>\n<td>No</td>\n</tr>\n<tr>\n<td>fixMouseEventsOnDisabledChildren</td>\n<td>Fix mouse events on disabled Input/Button</td>\n<td>boolean</td>\n<td><code>false</code></td>\n<td>No</td>\n</tr>\n</tbody>\n</table>\n<p>For more info on mouse events with disabled input/button, see <a href="https://github.com/youzan/zent/issues/142">https://github.com/youzan/zent/issues/142</a></p>\n<h4 class="anchor-heading"><a href="#trigger-focus">¶</a><a href="javascript:void(0)" id="trigger-focus" class="anchor-point"></a>Trigger.Focus</h4>\n<p>Display when it gets focus, close when it loses focus.</p>\n<table class="table">\n<thead>\n<tr>\n<th>Property</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n<th>Required</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>getElement</td>\n<td>Customize trigger DOM node</td>\n<td>(node: Element</td>\n<td>Text</td>\n<td>null) => Element</td>\n</tr>\n</tbody>\n</table>\n<h4 class="anchor-heading"><a href="#trigger-base-deprecated">¶</a><a href="javascript:void(0)" id="trigger-base-deprecated" class="anchor-point"></a>Trigger.Base(Deprecated)</h4>\n<p>Please use <code>PopoverAnchor</code> to implement custom trigger, checkout <code>ClickTrigger</code> source code.</p>\n<h3 class="anchor-heading"><a href="#position-api">¶</a><a href="javascript:void(0)" id="position-api" class="anchor-point"></a>Position API</h3>\n<p>Position is used to position layer. there are 12 kinds of basic positions. You can add custom position algorithms. The <code>cushion</code> on Popover affect position. It usually acts as an offset.</p>\n<pre><code class="language-text"><span class="token comment">// Basic positions</span>\n\n <span class="token maybe-class-name">TopLeft</span> <span class="token maybe-class-name">TopCenter</span> <span class="token maybe-class-name">TopRight</span>\n\n<span class="token maybe-class-name">LeftTop</span> <span class="token maybe-class-name">RightTop</span>\n\n\n<span class="token maybe-class-name">LeftCenter</span> <span class="token maybe-class-name">RightCenter</span>\n\n\n<span class="token maybe-class-name">LeftBottom</span> <span class="token maybe-class-name">RightBottom</span>\n\n <span class="token maybe-class-name">BottomLeft</span> <span class="token maybe-class-name">BottomCenter</span> <span class="token maybe-class-name">BottomRight</span></code></pre>\n<p>Except for 12 kinds of basic position algorithm, there is 6 position algorithm to automatically determine appropriate position according to the left space in screen: <code>AutoBottomLeft</code>,<code>AutoBottomCenter</code>, <code>AutoBottomRight</code>, <code>AutoTopLeft</code>, <code>AutoTopCenter</code> and <code>AutoTopRight</code>. those algorithm is used for dropdown widget。</p>\n<h4 class="anchor-heading"><a href="#custom-position">¶</a><a href="javascript:void(0)" id="custom-position" class="anchor-point"></a>Custom position</h4>\n<p>A position function is just a normal pure function.</p>\n<pre><code class="language-ts"><span class="token keyword">const</span> TopCenter<span class="token operator">:</span> <span class="token function-variable function">IPositionFunction</span> <span class="token operator">=</span> <span class="token punctuation">(</span>options<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">const</span> <span class="token punctuation">{</span> contentRect<span class="token punctuation">,</span> relativeRect<span class="token punctuation">,</span> cushion <span class="token punctuation">}</span> <span class="token operator">=</span> options<span class="token punctuation">;</span>\n <span class="token keyword">const</span> <span class="token punctuation">{</span> right<span class="token punctuation">,</span> left<span class="token punctuation">,</span> top <span class="token punctuation">}</span> <span class="token operator">=</span> relativeRect<span class="token punctuation">;</span>\n <span class="token keyword">const</span> middle <span class="token operator">=</span> <span class="token punctuation">(</span>left <span class="token operator">+</span> right<span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">;</span>\n <span class="token keyword">const</span> x <span class="token operator">=</span> middle <span class="token operator">-</span> contentRect<span class="token punctuation">.</span>width <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">;</span>\n <span class="token keyword">const</span> y <span class="token operator">=</span> top <span class="token operator">-</span> contentRect<span class="token punctuation">.</span>height <span class="token operator">-</span> cushion<span class="token punctuation">;</span>\n\n <span class="token keyword">return</span> <span class="token punctuation">{</span>\n style<span class="token operator">:</span> <span class="token punctuation">{</span>\n position<span class="token operator">:</span> <span class="token string">\'absolute\'</span><span class="token punctuation">,</span>\n left<span class="token operator">:</span> x<span class="token punctuation">,</span>\n top<span class="token operator">:</span> y<span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n\n className<span class="token operator">:</span> <span class="token function">prefix</span><span class="token punctuation">(</span><span class="token string">\'position-top-center\'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">;</span>\n<span class="token punctuation">}</span><span class="token punctuation">;</span></code></pre>\n<p>Anchor is trigger,container is the nearest positioned parent node in the DOM tree.</p>\n<ul>\n<li><code>relativeRect</code> anchor\'s position relative to container, this is what you want when calculating positions in most cases</li>\n<li><code>cushion</code> position offset</li>\n<li><code>anchor</code> anchor DOM node</li>\n<li><code>container</code> container DOM node</li>\n<li><code>content</code> content DOM node</li>\n<li><code>anchorRect</code> anchor\'s position/size relative to viewport</li>\n<li><code>containerRect</code> container\'s position/size relative to viewport</li>\n<li><code>contentRect</code> content\'s position/size relative to viewport</li>\n</ul>\n<h4 class="anchor-heading"><a href="#withpopover-high-level-compone">¶</a><a href="javascript:void(0)" id="withpopover-high-level-compone" class="anchor-point"></a>withPopover high-level component</h4>\n<p>The high-level component provides some important functions. it can be used to manually close pop in <code>Content</code></p>\n<table class="table">\n<thead>\n<tr>\n<th>Property</th>\n<th>Description</th>\n<th>Type</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>open</td>\n<td>Open content</td>\n<td><code>() => void</code></td>\n</tr>\n<tr>\n<td>close</td>\n<td>Close content</td>\n<td><code>() => void</code></td>\n</tr>\n<tr>\n<td>adjustPosition</td>\n<td>Reposition content</td>\n<td><code>() => void</code></td>\n</tr>\n</tbody>\n</table>\n<h4 class="anchor-heading"><a href="#adjustposition">¶</a><a href="javascript:void(0)" id="adjustposition" class="anchor-point"></a><code>adjustPosition</code></h4>\n<p>You can use this method to update <code>Popover</code> position.</p>\n<p>You rarely need it. <code>Popover</code> will update its position automatically on window scroll and resize.</p>'}))}}}}]);