-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50-a28f22da2d828c0b81f9.js
1 lines (1 loc) · 35.5 KB
/
50-a28f22da2d828c0b81f9.js
1
webpackJsonp([50],{1598:function(n,t,a){"use strict";function s(n){return n&&n.__esModule?n:{default:n}}function o(n){return y.default.createElement(n.tag,(0,l.default)({},n.attributes,{dangerouslySetInnerHTML:{__html:n.html}}))}function e(n){return y.default.createElement(o,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function p(n){return y.default.createElement(o,{tag:"style",html:n.style})}function c(n,t){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(t+=n.offsetTop),c(n.parentNode,t);return t}Object.defineProperty(t,"__esModule",{value:!0});var i=a(7),l=s(i),u=a(1),d=s(u),r=a(4),k=s(r),g=a(2),h=s(g),f=a(3),m=s(f),v=a(0),y=s(v),b=a(232),w=s(b),P=a(359),C=function(){return y.default.createElement(P.Popover,{className:"zent-doc-popover",position:P.Popover.Position.BottomLeft,display:"inline",cushion:5},y.default.createElement(P.Popover.Trigger.Click,null,y.default.createElement(P.Button,{type:"primary"},"Click to Open")),y.default.createElement(P.Popover.Content,null,y.default.createElement("div",null,"Popover content"),y.default.createElement("div",null,"You can add anything here")))},B=function(){var n=function(n){function t(){var n,a,s,o;(0,d.default)(this,t);for(var e=arguments.length,p=Array(e),c=0;c<e;c++)p[c]=arguments[c];return a=s=(0,h.default)(this,(n=t.__proto__||Object.getPrototypeOf(t)).call.apply(n,[this].concat(p))),s.state={visible:!1},o=a,(0,h.default)(s,o)}return(0,m.default)(t,n),(0,k.default)(t,[{key:"render",value:function(){var n=this;return y.default.createElement("div",{className:"zent-doc-popover-container"},y.default.createElement(P.Popover,{className:"zent-doc-popover",visible:this.state.visible,onVisibleChange:function(t){return n.setState({visible:t})},position:P.Popover.Position.BottomLeft,display:"inline",cushion:5},y.default.createElement(P.Popover.Trigger.Base,null,y.default.createElement(P.Button,{type:"primary",onClick:function(){return n.setState({visible:!0})}},"Click to Open")),y.default.createElement(P.Popover.Content,null,y.default.createElement("div",null,"Popover content"),y.default.createElement("div",null,"You can add anything here"))),y.default.createElement(P.Button,{onClick:function(){return n.setState({visible:!1})}},"Close"))}}]),t}(v.Component);return y.default.createElement(n,null)},N=function(n){function t(){var n,a,s,o;(0,d.default)(this,t);for(var e=arguments.length,p=Array(e),c=0;c<e;c++)p[c]=arguments[c];return a=s=(0,h.default)(this,(n=t.__proto__||Object.getPrototypeOf(t)).call.apply(n,[this].concat(p))),s.state={showCode:!1},s.toggle=function(){s.setState({showCode:!s.state.showCode})},o=a,(0,h.default)(s,o)}return(0,m.default)(t,n),(0,k.default)(t,[{key:"render",value:function(){var n=this.state.showCode,t=this.props,a=t.title,s=t.src,e=t.children;return y.default.createElement("div",{className:"zandoc-react-demo"},y.default.createElement("div",{className:"zandoc-react-demo__preview"},e),y.default.createElement("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle},y.default.createElement("div",{className:"zandoc-react-demo__title"},y.default.createElement("p",null,a||"")),y.default.createElement("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle "+(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})),n&&y.default.createElement("pre",{className:"zandoc-react-demo__code"},y.default.createElement(o,{tag:"code",html:s,attributes:{className:"language-jsx"}})))}}]),t}(v.Component),x=function(n){function t(){return(0,d.default)(this,t),(0,h.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return(0,m.default)(t,n),(0,k.default)(t,[{key:"componentDidMount",value:function(){var n=location.hash;if(n){var t=document.querySelector('a[href="'+n+'"]');t&&(0,w.default)(document.documentElement,0,c(t,-9))}}},{key:"render",value:function(){return y.default.createElement("div",{className:"zandoc-react-container",key:null},y.default.createElement(p,{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}"}),y.default.createElement(e,{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>'}),y.default.createElement(N,{title:"Basic usage",id:"Demobasic",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Popover<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Popover</span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</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 punctuation">=</span><span class="token punctuation">{</span>Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span>BottomLeft<span class="token punctuation">}</span></span>\n <span class="token attr-name">display</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>inline<span class="token punctuation">"</span></span>\n <span class="token attr-name">cushion</span><span class="token script language-javascript"><span class="token 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>Popover.Trigger.Click</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Click to Open<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover.Trigger.Click</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Popover.Content</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>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>div</span><span class="token punctuation">></span></span>You 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>Popover.Content</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover</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>'},y.default.createElement(C)),y.default.createElement(N,{title:"Controlled open/close",id:"Democontrolled",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Popover<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">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 visible<span class="token punctuation">:</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">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">=</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 operator"><</span>Popover\n className<span class="token operator">=</span><span class="token string">"zent-doc-popover"</span>\n visible<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>visible<span class="token punctuation">}</span>\n onVisibleChange<span class="token operator">=</span><span class="token punctuation">{</span>v <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> visible<span class="token punctuation">:</span> v <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span>\n position<span class="token operator">=</span><span class="token punctuation">{</span>Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span>BottomLeft<span class="token punctuation">}</span>\n display<span class="token operator">=</span><span class="token string">"inline"</span>\n cushion<span class="token operator">=</span><span class="token punctuation">{</span><span class="token number">5</span><span class="token punctuation">}</span><span class="token operator">></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Popover.Trigger.Base</span><span class="token punctuation">></span></span>\n <span class="token operator"><</span>Button type<span class="token operator">=</span><span class="token string">"primary"</span> onClick<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> visible<span class="token punctuation">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token operator">></span>Click to Open<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover.Trigger.Base</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Popover.Content</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>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>div</span><span class="token punctuation">></span></span>You 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>Popover.Content</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover</span><span class="token punctuation">></span></span>\n\n <span class="token operator"><</span>Button onClick<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> visible<span class="token punctuation">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token operator">></span>Close<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</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\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PopoverDemo</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>'},y.default.createElement(B)),y.default.createElement(e,{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 array</td>\n<td>number</td>\n<td><code>0</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>display</td>\n<td>the display property specifies the type of box used for an HTML element.</td>\n<td>string</td>\n<td><code>\'block\'</code></td>\n<td>all legal \n<code>display</code>\n value in CSS</td>\n<td>No</td>\n</tr>\n<tr>\n<td>onShow</td>\n<td>the 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>the 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>the 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>the 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>manual 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>the 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 enter 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 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>wrapperClassName</td>\n<td>trigger outerline div classname</td>\n<td>string</td>\n<td><code>\'\'</code></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>width</td>\n<td>width</td>\n<td>string or number</td>\n<td></td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>prefix</td>\n<td>custom prefix</td>\n<td>string</td>\n<td><code>\'zent\'</code></td>\n<td></td>\n<td>No</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>autoClose</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>isOutside</td>\n<td>to determine a node is \n<code>outside</code>\n or not, click outside to close pop. default trigger and the node outside pop is \n<code>outside</code></td>\n<td>func: (node, data) => bool</td>\n<td><code>() => false</code></td>\n<td>No</td>\n</tr>\n</tbody>\n</table>\n<p>The <code>data</code> in isOutside includes two attributes :<code>contentNode</code> and <code>triggerNode</code>。</p>\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>isOutside</td>\n<td>to determine a node is \n<code>outside</code>\n or not. default trigger and the node outside pop is \n<code>outside</code></td>\n<td>func: (node, data) => bool</td>\n<td></td>\n<td>No</td>\n</tr>\n<tr>\n<td>quirk</td>\n<td>quirk mode,in this mode, mouse is not required to move out trigger and layer when close triggers</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td>No</td>\n</tr>\n</tbody>\n</table>\n<p>The <code>data</code> in isOutside includes two attributes:<code>contentNode</code> 和 <code>triggerNode</code>。</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, no params</p>\n<h4 class="anchor-heading"><a href="#trigger-base">¶</a><a href="javascript:void(0)" id="trigger-base" class="anchor-point"></a>Trigger.Base</h4>\n<p>All trigger\'s base class, implement custom trigger need to inherit this class, you have rewrite <code>getTriggerProps</code> method to add trigger event. and you can control pop\'s open/close in event handle function.</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>getTriggerNode</td>\n<td>Get trigger\'s DOM node</td>\n<td>func: () => node</td>\n</tr>\n<tr>\n<td>getContentNode</td>\n<td>Get pop\'s DOM node</td>\n<td>func: () => node</td>\n</tr>\n<tr>\n<td>open</td>\n<td>Open pop</td>\n<td>func</td>\n</tr>\n<tr>\n<td>close</td>\n<td>Close pop</td>\n<td>func</td>\n</tr>\n<tr>\n<td>contentVisible</td>\n<td>Is popover content visible</td>\n<td>bool</td>\n</tr>\n<tr>\n<td>onTriggerRefChange</td>\n<td>Callback when ref changes. It is only needed when you rewrite render function</td>\n<td>func:(instance)</td>\n</tr>\n<tr>\n<td>getNodeForTriggerRefChange</td>\n<td>Callback to get the actual trigger DOM node when ref changes</td>\n<td>(HTMLElement) => HTMLELement</td>\n</tr>\n</tbody>\n</table>\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 TopLeft TopCenter TopRight\n\nLeftTop RightTop\n\n\nLeftCenter RightCenter\n\n\nLeftBottom RightBottom\n\n BottomLeft BottomCenter BottomRight</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<p>Every object in position algorithm has a <code>locate</code> function which can be used to implement a combination of positioning algorithms.</p>\n<pre><code class="language-jsx">Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span><span class="token punctuation">(</span>anchorBoundingBox<span class="token punctuation">,</span> containerBoundingBox<span class="token punctuation">,</span> contentDimension<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">if</span> <span class="token punctuation">(</span>someCondition<span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span>BottomLeft<span class="token punctuation">.</span><span class="token function">locate</span><span class="token punctuation">(</span>anchorBoundingBox<span class="token punctuation">,</span> containerBoundingBox<span class="token punctuation">,</span> contentDimension<span class="token punctuation">,</span> options<span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token keyword">return</span> Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span>TopRight<span class="token punctuation">.</span><span class="token function">locate</span><span class="token punctuation">(</span>anchorBoundingBox<span class="token punctuation">,</span> containerBoundingBox<span class="token punctuation">,</span> contentDimension<span class="token punctuation">,</span> options<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></code></pre>\n<h4 class="anchor-heading"><a href="#position-create">¶</a><a href="javascript:void(0)" id="position-create" class="anchor-point"></a>Position.create</h4>\n<p>The factory function, receiving a function as parameter, is used to customize position</p>\n<pre><code class="language-jsx"><span class="token comment">// a bounding box is an object with these fields: {top, left, right, bottom, width, height}</span>\n<span class="token keyword">const</span> position <span class="token operator">=</span> Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span><span class="token punctuation">(</span>anchorBoundingBox<span class="token punctuation">,</span> containerBoundingBox<span class="token punctuation">,</span> contentDimension<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">return</span> <span class="token punctuation">{</span>\n <span class="token function">getCSSStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token punctuation">{</span>\n position<span class="token punctuation">:</span> <span class="token string">\'fixed\'</span><span class="token punctuation">,</span>\n left<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>\n top<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>\n opacity<span class="token punctuation">:</span> <span class="token number">0</span>\n <span class="token punctuation">}</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n\n name<span class="token punctuation">:</span> <span class="token string">\'position-example\'</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></code></pre>\n<p>Anchor means trigger,container is nearst layer\'s parent node which have it\'s own position.</p>\n<p><code>anchorBoundingBox</code> and <code>containerBoundingBox</code> is relative to container\'s upper-left corner.</p>\n<p><code>contentDimension</code> is layer\'s width and height.</p>\n<p><code>options</code> contains another useful arguments:</p>\n<ul>\n<li><code>options.cushion</code> position offset passed by Props</li>\n<li><code>options.anchor</code> anchor\'s DOM node</li>\n<li><code>options.container</code> container\'s DOM node</li>\n<li><code>options.anchorBoundingBoxViewport</code> anchor is a coordinate relative to viewport</li>\n<li><code>options.containerBoundingBoxViewport</code> container is a coordinate 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>getTriggerNode</td>\n<td>get trigger\'s DOM node</td>\n<td>func: () => node</td>\n</tr>\n<tr>\n<td>getContentNode</td>\n<td>get layer\'s DOM node</td>\n<td>func: () => node</td>\n</tr>\n<tr>\n<td>open</td>\n<td>open layer</td>\n<td>func</td>\n</tr>\n<tr>\n<td>close</td>\n<td>close layer</td>\n<td>func</td>\n</tr>\n</tbody>\n</table>\n<p>Example:</p>\n<pre><code class="language-jsx"><span class="token comment">// click close button to close layer</span>\n<span class="token keyword">const</span> HoverContent <span class="token operator">=</span> <span class="token function">withPopover</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token function">HoverContent</span><span class="token punctuation">(</span><span class="token punctuation">{</span> popover <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">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>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>button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>popover<span class="token punctuation">.</span>close<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>close<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>button</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 tag"><span class="token tag"><span class="token punctuation"><</span>Popover</span> <span class="token attr-name">position</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>Popover<span class="token punctuation">.</span>Position<span class="token punctuation">.</span>RightTop<span class="token punctuation">}</span></span> <span class="token attr-name">display</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>inline<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>Popover.Trigger.Hover</span> <span class="token attr-name">showDelay</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token number">500</span><span class="token punctuation">}</span></span> <span class="token attr-name">hideDelay</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token number">200</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n <span class="token operator"><</span>button style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span> marginLeft<span class="token punctuation">:</span> <span class="token number">100</span> <span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">></span>hover on me<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>button</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover.Trigger.Hover</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>PopoverContent</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>HoverContent</span> <span class="token punctuation">/></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>PopoverContent</span><span class="token punctuation">></span></span>\n<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Popover</span><span class="token punctuation">></span></span></code></pre>\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>'}))}}]),t}(v.Component);t.default=x}});