├── .gitignore ├── LICENSE ├── README.md ├── build.js ├── demo_bundles └── scroll.bundle.js ├── dist ├── poppy.amd.js ├── poppy.amd.min.js ├── poppy.commonjs2.js ├── poppy.commonjs2.min.js ├── poppy.css ├── poppy.js ├── poppy.min.js ├── poppy.umd.js └── poppy.umd.min.js ├── libs ├── container.js ├── index.js ├── poppy.css └── poppy.js ├── package.json └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 TaDaa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #React-Poppy 2 | 3 | React popover that scales, follows, scrolls, and grows 4 | 5 | 6 | ##Usage 7 | ``` 8 | npm install react-poppy 9 | ``` 10 | 11 | or 12 | 13 | clone/download and use appropriate script in /dist 14 | 15 | 16 | 17 | 18 | ##Demos 19 | 20 | * reposition on scroll events 21 | 22 | * interactions (hover to show, mouse over to keep popover open, toggle to open, grow based on content, scroll content) 23 | 24 | * repositions on state change 25 | 26 | * can track elements (same as above demo except follows elements not modified by react state) 27 | 28 | 29 | 30 | ##Psuedo JSX 31 | ``` 32 | 33 | 34 | 35 | ``` 36 | 37 | 38 | 39 | ###Properties 40 | * children=[ReactElement] - the target element that the popover should follow and position around 41 | 42 | * constrainTo=[element,ReactElement,querySelector='parent'] - used to calculate the bounding area that the popover should be contained in. If using a string, the querySelector is matched upward from the popover's location in the DOM tree. Parent is a special selector that will use the React element containing the popover. 43 | 44 | * show=[boolean=undefined] - forces the popover to show. Show takes precedence over all other types of show/hide interactions. 45 | 46 | * showDelay=[number=300] - amount of time that needs to pass before the popover begins to show. 47 | 48 | * hideDelay=[number=320] - amount of time that needs to pass before the popover begins to hide. 49 | 50 | * track=[boolean=false] - enables an internal timer to track the target element's position and size 51 | 52 | * constrainHeight=[boolean=true] - limits the height to the constrainTo's available space 53 | 54 | * constrainWidth=[boolean=true] - limits the width to the constrainTo's available space 55 | 56 | * arrowSize=[number=15] - changes the size of the arrow 57 | 58 | * region=["left"|"right|"top|"bottom"|undefined] - forces popover placement in a particular region 59 | 60 | * bindScroll=[boolean=false|querySelector] - binds the popover to the window scroll event if "true" or an element matching the querySelector traversing upwards from the popover target. 61 | 62 | * bindWindowResize=[boolean=false] - binds the popover to the window resize event 63 | 64 | * arrowStyle=[object={}] - arrowStyle override 65 | 66 | * backgroundStyle=[object=undefined] - backgroundStyle override 67 | 68 | * wrapperStyle=[object=undefined] - wrapperStyle verride 69 | 70 | * titleStyle=[object=undefined] - titleStyle override 71 | 72 | * className=[string=''] - className to apply to popover 73 | 74 | * title=[string=''|ReactElement] - title to be used. 75 | 76 | * showOnMouseEnter=[boolean=true] - popover will show when mouse enters target element 77 | 78 | * hideOnMouseLeave=[boolean=true] - popover will hide when mouse leaves target element. 79 | 80 | * toggleOnClick=[boolean=false] - popover will toggle show/hide when target element is clicked. 81 | 82 | * persistOverContent=[boolean=false] - popover will stay visible while the mouse is over the popover 83 | 84 | * onHide=[function] - event called when the popover is hidden 85 | 86 | * onShow=[function] - event called when the popover is shown 87 | 88 | 89 | 90 | 91 | ###Methods -- warning you should generally control these behaviors with props to keep behaviors consistent 92 | 93 | * track() - start tracking target element 94 | 95 | * untrack() - stop tracking target element 96 | 97 | * show() - show popover 98 | 99 | * hide() - hide popover 100 | 101 | * refresh() - redraw popover 102 | 103 | -------------------------------------------------------------------------------- /build.js: -------------------------------------------------------------------------------- 1 | var babel = require('babel-core'), 2 | fs = require('fs'); 3 | 4 | copy ("index.js") ("poppy.css"); 5 | transform_jsx ("container.js") ("poppy.js") 6 | 7 | 8 | function copy (file) { 9 | fs.readFile("libs/"+file,function (err,data) { 10 | fs.writeFile("dist/"+file,data,function (err,data) { 11 | if (err) { 12 | console.error(err.toString()); 13 | } else { 14 | console.error("done writing " + file); 15 | } 16 | }); 17 | }); 18 | return copy; 19 | } 20 | function transform_jsx (file) { 21 | babel.transformFile("libs/"+file,{ 22 | 'presets' : ['react'] 23 | },function (err,code) { 24 | if (err) { 25 | console.error(err.toString()); 26 | } else { 27 | fs.writeFile("dist/"+file,code.code,function (err) { 28 | if (err) { 29 | console.error(err.toString()); 30 | } else { 31 | console.error("done writing " + file); 32 | } 33 | }); 34 | } 35 | }); 36 | return transform_jsx; 37 | } 38 | -------------------------------------------------------------------------------- /demo_bundles/scroll.bundle.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) 10 | /******/ return installedModules[moduleId].exports; 11 | 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ exports: {}, 15 | /******/ id: moduleId, 16 | /******/ loaded: false 17 | /******/ }; 18 | 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | 22 | /******/ // Flag the module as loaded 23 | /******/ module.loaded = true; 24 | 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | 29 | 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | 36 | /******/ // __webpack_public_path__ 37 | /******/ __webpack_require__.p = ""; 38 | 39 | /******/ // Load entry module and return exports 40 | /******/ return __webpack_require__(0); 41 | /******/ }) 42 | /************************************************************************/ 43 | /******/ ([ 44 | /* 0 */ 45 | /***/ function(module, exports, __webpack_require__) { 46 | 47 | (function webpackMissingModule() { throw new Error("Cannot find module \"./demos/scroll.js\""); }()); 48 | 49 | 50 | /***/ } 51 | /******/ ]); -------------------------------------------------------------------------------- /dist/poppy.amd.min.js: -------------------------------------------------------------------------------- 1 | define("poppy",["react","react-dom"],function(__WEBPACK_EXTERNAL_MODULE_4__,__WEBPACK_EXTERNAL_MODULE_9__){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(p===setTimeout)return setTimeout(e,0);if((p===n||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function i(e){if(c===clearTimeout)return clearTimeout(e);if((c===r||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}function s(){y&&h&&(y=!1,h.length?d=h.concat(d):m=-1,d.length&&a())}function a(){if(!y){var e=o(s);y=!0;for(var t=d.length;t;){for(h=d,d=[];++m1)for(var n=1;n1?t-1:0),r=1;r2?r-2:0),i=2;i=0&&isSafari.indexOf("chrome")<0;var SHOWING={NONE:0,MOUSEOVER:1,CONTENT:2,CLICK:4,PROPERTY:8},LEFT=1,RIGHT=2,TOP=3,BOTTOM=4,defaults={backgroundStyle:void 0,arrowStyle:{},wrapperStyle:void 0,titleStyle:void 0,content:"",className:"",title:"",position:{overflow:"auto",position:"relative",top:0,height:"100%",left:0,width:"100%"},constrainTo:"parent",persistOverContent:!1,showOnMouseEnter:!0,hideOnMouseLeave:!0,bindWindowResize:!1,bindScroll:!1,toggleOnClick:!1,constrainWidth:!0,constrainHeight:!0,track:!1,arrowSize:15,region:void 0,show:void 0,showDelay:300,hideDelay:320},getDefaults=eval("(function () {return "+JSON.stringify(defaults)+";})");!function(defaults){var p,item;for(p in defaults)(item=defaults[p])&&"object"===(void 0===item?"undefined":_typeof(item))&&(defaults[p]=eval("(function (obj) {var result ="+JSON.stringify(item)+",p; for (p in obj) {result[p]=obj[p]} return result;})"))}(defaults);var Popover=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._onExit=function(t){e.__onExit(t)},e._onEnter=function(t){e.__onEnter(t)},e}return _inherits(t,e),_createClass(t,[{key:"shouldComponentUpdate",value:function(e,t){var n=this.state||{},r=t.position||{};return this.minWidth!==r.minWidth||this.minHeight!==r.minHeight||this.maxWidth!==r.maxWidth||n.content!==t.content||n.title!==t.title||this.maxHeight!==r.maxHeight}},{key:"render",value:function(){var e=this.state;if(!e)return null;var t=e.title,n=e.position,r=n.maxWidth,o=n.maxHeight,i=n.minWidth,s=n.minHeight,a=e.content,l=this.overflowStyle,u=this.wrapperStyle,p=e.wrapperStyle||{},c=e.backgroundStyle||{};return l.overflow=a?"auto":null,this.maxHeight=l.maxHeight=u.maxHeight=o,this.maxWidth=l.maxWidth=u.maxWidth=r,this.minHeight=c.minHeight=p.minHeight=s,this.minWidth=c.minWidth=p.minWidth=i,React.createElement("span",{className:"poppy "+(e.className||""),onMouseOver:this._onEnter,onMouseOut:this._onExit},React.createElement("span",{ref:"inner",style:e.backgroundStyle,className:"poppy-background"},React.createElement("div",{ref:"arrow",className:"poppy-arrow",style:e.mergedArrowStyle}),React.createElement("div",{ref:"wrapper",className:"poppy-background-overlay",style:p})),React.createElement("div",{ref:"content",className:"poppy-content-wrapper",style:u},t?React.createElement("div",{ref:"titleWrapper",style:e.titleStyle,className:"poppy-title-wrapper"},React.createElement("span",{ref:"title",className:"poppy-title"},e.title)):null,React.createElement("div",{ref:"overflow",className:"poppy-overflow",style:l},a?React.createElement("div",{ref:"popover",className:"poppy-content"}," ",a||""," "):React.createElement("span",{ref:"popover"}))))}},{key:"__onEnter",value:function(){this.state.onEnterContent&&this.state.onEnterContent(SHOWING.CONTENT)}},{key:"__onExit",value:function(){this.state.onLeaveContent&&this.state.onLeaveContent(SHOWING.CONTENT)}}]),t}(React.Component),overlay_template=document.createElement("span");overlay_template.innerHTML='
',overlay_template=overlay_template.lastChild,Popover.prototype.overflowStyle={},Popover.prototype.wrapperStyle={},module.exports=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=assign_defaults(e.props);return e._lastTargetRect={left:0,top:0,width:0,height:0},e.pack={},e._transitioning=!0,e._doTrack=function(t){return e.__doTrack(t)},e._onClick=function(t){return e.__onClick(t)},e._onResize=function(t){return e.__onResize(t)},e._onScroll=function(t){return e.__onScroll(t)},e._onMouseEnter=function(t){return e.__onMouseEnter(t)},e._onMouseLeave=function(t){return e.__onMouseLeave(t)},e.settings={arrowStyle:{width:defaults.arrowSize,height:defaults.arrowSize},constrainTo:defaults.constrainTo,showing:0,showDelay:defaults.showDelay,hideDelay:defaults.hideDelay,track:defaults.track,constrainHeight:defaults.constrainHeight,constrainWidth:defaults.constrainWidth,className:defaults.className,title:""},e.componentWillUpdate(e.props,n),e.state=n,e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=this,t=ReactDOM.findDOMNode(this);e.setState({target:t}),this._mount_timer=setTimeout(function(){e._updateSync(e.props,e.state)})}},{key:"componentWillUnmount",value:function(){var e=this.state.target,t=e.ownerDocument,n=t.defaultView;this.settings&&(e=this.settings.target)&&(e.removeEventListener("mouseenter",this._onMouseEnter),e.removeEventListener("mouseleave",this._onMouseLeave),e.removeEventListener("click",this._onClick)),this.untrack(),this._resize_timer&&clearTimeout(this._resize_timer),this._show_timer&&clearTimeout(this._show_timer),this._mount_timer&&clearTimeout(this._mount_timer),this.overlay&&this.popoverEl.parentNode===this.overlay&&this.overlay.removeChild(this.popoverEl),this._init_timer&&clearTimeout(this._init_timer),this.settings.bindWindowResize&&n.removeEventListener("resize",this._onResize),this._boundScroll&&this._boundScroll.removeEventListener("scroll",this._onScroll)}},{key:"componentWillUpdate",value:function(e,t){this._updateSync(e,t),!this._group&&group(this)}},{key:"_updateSync",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];n=n||this.state;var r=this.settings,o=t.bindWindowResize||!1,i=n&&n.target,s=r.target,a=t.track||!1,l=i&&i.ownerDocument.defaultView,u=!0===t.bindScroll?"window":t.bindScroll,p=this._boundScroll,c=!!r.target&&this._upwardSelector(u,r);o!==r.bindWindowResize&&(o?l&&(l.addEventListener("resize",this._onResize),r.bindWindowResize=!0):(l&&l.removeEventListener("resize",this._onResize),r.bindWindowResize=!1)),r.titleStyle=t.titleStyle||defaults.titleStyle,r.wrapperStyle=t.wrapperStyle||defaults.wrapperStyle,c!==p&&(p&&(p.removeEventListener("scroll",this._onScroll),this._boundScroll=!1),c&&(c.addEventListener("scroll",this._onScroll,!0),this._boundScroll=c)),a!==r.track&&(a?(r.track=!0,this.track()):(r.track=!1,this.untrack())),i&&s!==i&&(i.addEventListener("mouseenter",this._onMouseEnter),i.addEventListener("mouseleave",this._onMouseLeave),i.addEventListener("click",this._onClick),r.target=i,s&&(s.removeEventListener("mouseenter",this._onMouseEnter),s.removeEventListener("mouseleave",this._onMouseLeave),s.removeEventListener("click",this._onClick))),t.persistOverContent?(r.persistOverContent=!0,r.onEnterContent=function(t){return e.show(t)},r.onLeaveContent=function(t){return e.hide(t)}):(r.persistOverContent=!1,r.onEnterContent=!1,r.onLeaveContent=!1),r.toggleOnClick=void 0!==t.toggleOnClick?t.toggleOnClick:defaults.toggleOnClick,r.showOnMouseEnter=void 0!==t.showOnMouseEnter?t.showOnMouseEnter:defaults.showOnMouseEnter,r.hideOnMouseLeave=void 0!==t.hideOnMouseLeave?t.hideOnMouseLeave:defaults.hideOnMouseLeave,r.constrainHeight=void 0!==t.constrainHeight?t.constrainHeight:defaults.constrainHeight,r.constrainWidth=void 0!==t.constrainWidth?t.constrainWidth:defaults.constrainWidth}},{key:"_updateAsync",value:function(){if(this.settings.target){var e=this,t=this.props,n=t.show,r=this.settings,o=r.showing&SHOWING.PROPERTY,i=r.target.ownerDocument,s=i.body,a=this._upwardSelector(".poppy-container",r),l=this.popover,u=void 0!==t.arrowSize?t.arrowSize:defaults.arrowSize,p=r.mergedArrowStyle=Object.assign({},r.arrowStyle,t.arrowStyle),c=t.region;if(c&&c!==r.last_prop_region?"top"===c?r.region=TOP:"left"===c?r.region=LEFT:"right"===c?r.region=RIGHT:"bottom"===c&&(r.region=BOTTOM):c||(r.region=defaults.region),r.backgroundStyle=t.backgroundStyle,r.last_prop_region=c,r.title=t.title||defaults.title,r.content=t.content||defaults.content,r.className=t.className||defaults.className,r.arrowSize=u,r.arrowSize3_4=.75*u,r.arrowSize1_2=.5*u,r.arrowSize2_1=2*u,r.arrowSize3_2=1.5*u,p.height=p.width=u,this._adjustPosition(this.settings),a===s&&(a=s.querySelector(".poppy-container")),a?this.overlay||(this.overlay=a):s.appendChild(a=this.overlay=overlay_template.cloneNode(!0)),l)this.overlay.ownerDocument!==i&&this.popoverEl&&(a.appendChild(this.popoverEl),this.overlay=a);else{var f=document.createElement("div");l=this.popover=ReactDOM.render(React.createElement(Popover,null),f),a.appendChild(f.lastChild)}l.setState(r),this.popoverEl||(this.popoverEl=ReactDOM.findDOMNode(l)), 2 | //!this._init_timer && requestAnimationFrame(function () { 3 | o&&!n?e.hide(SHOWING.PROPERTY):!o&&n&&e.show(SHOWING.PROPERTY),e._updatePositions()}}},{key:"__onResize",value:function(){var e=this;this._resize_timer&&clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){e._resize_timer=void 0,e.setState({})},60)}},{key:"__onMouseEnter",value:function(){this.settings.showOnMouseEnter&&this.show(SHOWING.MOUSEOVER)}},{key:"__onMouseLeave",value:function(){this.settings.hideOnMouseLeave&&this.hide(SHOWING.MOUSEOVER)}},{key:"__onClick",value:function(){this.settings.toggleOnClick&&(this.settings.showing&SHOWING.CLICK?this.hide(SHOWING.CLICK):this.show(SHOWING.CLICK))}},{key:"_adjustPosition",value:function(e){var t,n,r,o,i=this.pack.targetRect,s=this.pack.parentRect,a=s.width/s.height,l=e.region,u=e.leftSpace=i.left-s.left,p=e.rightSpace=s.left+s.width-(i.left+i.width),c=e.topSpace=i.top-s.top,f=e.bottomSpace=s.top+s.height-(i.top+i.height),h=e.arrowSize,d=e.position,y=e.arrowSize3_4,m=e.constrainHeight,v=e.constrainWidth,g=2*h;d||(d=e.position={}),l||(n=.75*u,r=.75*p,t=c*a,o=f*a,l=e.region=n>o&&n>t&&n>=r?LEFT:r>o&&r>t?RIGHT:t>o?TOP:BOTTOM),l===LEFT?(d.minWidth=h,d.minHeight=g,d.top=d.left=0,v&&(d.maxWidth=Math.max(u-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===RIGHT?(d.minWidth=h,d.top=0,d.minHeight=g,d.left=i.left+i.width+y,v&&(d.maxWidth=Math.max(p-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===BOTTOM?(d.minHeight=h,d.top=i.top+i.height+y,d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(f-y-5,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25))):(d.minHeight=h,d.top=d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(c-y+2,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25)))}},{key:"__onScroll",value:function(){!this._group&&group(this,!0)}},{key:"__doTrack",value:function(){this._track_timer=setTimeout(this._doTrack,16),this.settings.target&&this.popover&&!this._group&&group(this,!0)}},{key:"track",value:function(){return this._track_timer||(this._track_timer=setTimeout(this._doTrack,16)),this}},{key:"untrack",value:function(){return this._track_timer&&(clearTimeout(this._track_timer),this._track_timer=!1),this}},{key:"refresh",value:function(){return this.setState({}),this}},{key:"hide",value:function(e){var t=this,n=this.settings,r=n.showing;if(r&&r&e){n.showing-=e;var o=this.popoverEl,i=o.style;this._show_timer&&clearTimeout(this._show_timer),this._show_timer=setTimeout(function(){n.showing||(!o.$listener&&o.addEventListener("transitionend",o.$listener=function(){o.removeEventListener("transitionend",o.$listener),o.$listener=!1,!n.showing&&(o.style.visibility="hidden")}),t._show_timer=void 0,i.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",n.region===RIGHT?i.transform="translateX(30px)translateY(0px)":n.region===LEFT?i.transform="translateX(-30px)translateY(0px)":n.region===TOP?i.transform="translateX(0px)translateY(-30px)":i.transform="translateX(0px)translateY(30px)",i.pointerEvents="none",i.opacity=0,t.props.onHide&&t.props.onHide())},n.hideDelay)}}},{key:"show",value:function(e){var t=this,n=this.settings,r=this.popoverEl,o=r.style,i=!0,s=n.showing;n.showing|=e,s||(this._show_timer&&(clearTimeout(this._show_timer),this._show_timer=void 0,i=!1),r.$listener&&r.removeEventListener("transitionend",r.$listener),r.$listener=!1,i?this._show_timer=setTimeout(function(){n.showing&&(t.props.onShow&&t.props.onShow(),t._show_timer=void 0,o.transition=null,n.region===RIGHT?o.transfrom="translateX(30px)translateY(0px)":n.region===LEFT?o.transform="translateX(-30px)translateY(0px)":n.region===TOP?o.transform="translateX(0px)translateY(-30px)":o.transform="translateX(0px)translateY(30px)",o.pointerEvents="all",t._show_timer=setTimeout(function(){t._show_timer=void 0,o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"},n.showDelay))}):(o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"))}},{key:"_upwardSelector",value:function(e,t){var n=t.target,r=n.ownerDocument;if(!e)return e;if("string"==typeof e){if("body"===e)return r.body;if("parent"===e)return n&&n.parentNode;if("window"===e)return n&&n.ownerDocument.defaultView;for(;n;){if(n.matches&&n.matches(e))return n;n=n.parentNode}return r.body}return(n=ReactDOM.findDOMNode(e))?n:e}},{key:"_updatePositions",value:function(){if(this.settings.target){var e,t,n,r,o,i,s,a,l=this.popover.refs.overflow,u=l.style,p=this.popover.refs.wrapper.style,c=this.popover.refs.arrow,f=c.style,h=this.popover.refs.content.style,d=this.settings,y=this.popover.refs.title,m=y&&y.getBoundingClientRect(),v=this.pack.targetRect,g=this.pack.parentRect,_=m&&m.width||0,w=m&&m.height||0,b=v.top,T=v.width,E=T/2,O=v.height,S=O/2,x=v.left,k=t=g.top,R=n=g.left,C=0|n,N=0|t,M=d.region,L=d.leftSpace,P=d.topSpace,W=0|d.arrowSize,H=d.arrowSize1_2,z=d.arrowSize3_4,D=d.arrowSize2_1,j=d.arrowSize3_2,I=d.position.left,A=d.position.top;u.paddingTop=w+"px",u.maxHeight=Math.max(Math.round(this.settings.position.maxHeight-w),0)+"px",e=l.getBoundingClientRect(),r=Math.max(e.width,_),o=e.height,this.settings.target&&(M===TOP||M===BOTTOM?(s=5,i=R+g.width-5,n=x+E-r/2,n(a=i-r)&&(n=a),(a=x+W)>i&&(n=a-r),C+=L+E-W,C=Math.max(Math.min(C,n+r-D),n)+H,I=n,M===TOP?(A=b-o-z-9,N=b-z-9-H):N=A-H):M!==LEFT&&M!==RIGHT||(t+=P+O-S-o/2,i=k+g.height-5,s=5,t(a=i-o)&&(t=a),(a=b+W)>i&&(t=a-o),N+=P+S-W,N=Math.max(Math.min(N,t+o-D),t)+H,A=t,M===LEFT?(I=x-r-z-6,C=I+r-H-1):(I=x+T+z,C=I-H+1)),h.width=p.width=(0|r)+"px",isSafari&&this._unsafe&&this.popoverEl&&(this.popoverEl.style.transition=f.transition=h.transition=p.transition=group_timer?"none":null),h.width=p.width=(0|r)+"px",f.top=(0|N)+"px",f.left=(0|C)+"px",p.top=h.top=(0|A)+"px",p.left=h.left=(0|I)+"px",p.height=(0|o)+"px",this.settings.showing&&this.popoverEl.style.visiblity&&(this.popoverEl.style.visiblity=null))}}},{key:"render",value:function(){var e=this.props.children;return"string"==typeof e&&(e=React.createElement("span",null,e)),e||null}}]),t}(React.Component),module.exports.propTypes={children:propTypes.any,constrainTo:propTypes.any,show:propTypes.bool,showDelay:propTypes.number,hideDelay:propTypes.number,track:propTypes.bool,constrainHeight:propTypes.bool,constrainWidth:propTypes.bool,arrowSize:propTypes.number,region:propTypes.oneOf(["left","right","top","bottom",null,!1,void 0]),bindScroll:propTypes.oneOfType([propTypes.bool,propTypes.string]),bindWindowResize:propTypes.bool,arrowStyle:propTypes.object,backgroundStyle:propTypes.object,wrapperStyle:propTypes.object,titleStyle:propTypes.object,className:propTypes.string,title:propTypes.any,showOnMouseEnter:propTypes.bool,hideOnMouseLeave:propTypes.bool,toggleOnClick:propTypes.bool,persistOverContent:propTypes.bool,onHide:propTypes.func,onShow:propTypes.func},module.exports.defaultProps={constrainTo:"parent",showDelay:300,hideDelay:320,track:!1,constrainHeight:!0,constrainWidth:!0,arrowSize:15,bindScroll:!1,bindWindowResize:!1,className:"",title:"",showOnMouseEnter:!0,hideOnMouseLeave:!0,toggleOnClick:!1,persistOverContent:!1}},function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE_9__},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(13)()}).call(t,n(0))},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),s=n(3),a=n(12);e.exports=function(e,n){function l(e){var t=e&&(S&&e[S]||e[x]);if("function"==typeof t)return t}function u(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function p(e){this.message=e,this.stack=""}function c(e){function r(r,u,c,f,h,d,y){if(f=f||k,d=d||c,y!==s)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var m=f+":"+c;!a[m]&&l<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),a[m]=!0,l++)}return null==u[c]?r?new p(null===u[c]?"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `null`.":"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(u,c,f,h,d)}if("production"!==t.env.NODE_ENV)var a={},l=0;var u=r.bind(null,!1);return u.isRequired=r.bind(null,!0),u}function f(e){function t(t,n,r,o,i,s){var a=t[n];if(b(a)!==e)return new p("Invalid "+o+" `"+i+"` of type `"+T(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return c(t)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new p("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new p("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+r+"`, expected an array.")}for(var l=0;l1)for(var n=1;n1?t-1:0),r=1;r2?r-2:0),i=2;i=0&&isSafari.indexOf("chrome")<0;var SHOWING={NONE:0,MOUSEOVER:1,CONTENT:2,CLICK:4,PROPERTY:8},LEFT=1,RIGHT=2,TOP=3,BOTTOM=4,defaults={backgroundStyle:void 0,arrowStyle:{},wrapperStyle:void 0,titleStyle:void 0,content:"",className:"",title:"",position:{overflow:"auto",position:"relative",top:0,height:"100%",left:0,width:"100%"},constrainTo:"parent",persistOverContent:!1,showOnMouseEnter:!0,hideOnMouseLeave:!0,bindWindowResize:!1,bindScroll:!1,toggleOnClick:!1,constrainWidth:!0,constrainHeight:!0,track:!1,arrowSize:15,region:void 0,show:void 0,showDelay:300,hideDelay:320},getDefaults=eval("(function () {return "+JSON.stringify(defaults)+";})");!function(defaults){var p,item;for(p in defaults)(item=defaults[p])&&"object"===(void 0===item?"undefined":_typeof(item))&&(defaults[p]=eval("(function (obj) {var result ="+JSON.stringify(item)+",p; for (p in obj) {result[p]=obj[p]} return result;})"))}(defaults);var Popover=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._onExit=function(t){e.__onExit(t)},e._onEnter=function(t){e.__onEnter(t)},e}return _inherits(t,e),_createClass(t,[{key:"shouldComponentUpdate",value:function(e,t){var n=this.state||{},r=t.position||{};return this.minWidth!==r.minWidth||this.minHeight!==r.minHeight||this.maxWidth!==r.maxWidth||n.content!==t.content||n.title!==t.title||this.maxHeight!==r.maxHeight}},{key:"render",value:function(){var e=this.state;if(!e)return null;var t=e.title,n=e.position,r=n.maxWidth,o=n.maxHeight,i=n.minWidth,s=n.minHeight,a=e.content,l=this.overflowStyle,u=this.wrapperStyle,p=e.wrapperStyle||{},c=e.backgroundStyle||{};return l.overflow=a?"auto":null,this.maxHeight=l.maxHeight=u.maxHeight=o,this.maxWidth=l.maxWidth=u.maxWidth=r,this.minHeight=c.minHeight=p.minHeight=s,this.minWidth=c.minWidth=p.minWidth=i,React.createElement("span",{className:"poppy "+(e.className||""),onMouseOver:this._onEnter,onMouseOut:this._onExit},React.createElement("span",{ref:"inner",style:e.backgroundStyle,className:"poppy-background"},React.createElement("div",{ref:"arrow",className:"poppy-arrow",style:e.mergedArrowStyle}),React.createElement("div",{ref:"wrapper",className:"poppy-background-overlay",style:p})),React.createElement("div",{ref:"content",className:"poppy-content-wrapper",style:u},t?React.createElement("div",{ref:"titleWrapper",style:e.titleStyle,className:"poppy-title-wrapper"},React.createElement("span",{ref:"title",className:"poppy-title"},e.title)):null,React.createElement("div",{ref:"overflow",className:"poppy-overflow",style:l},a?React.createElement("div",{ref:"popover",className:"poppy-content"}," ",a||""," "):React.createElement("span",{ref:"popover"}))))}},{key:"__onEnter",value:function(){this.state.onEnterContent&&this.state.onEnterContent(SHOWING.CONTENT)}},{key:"__onExit",value:function(){this.state.onLeaveContent&&this.state.onLeaveContent(SHOWING.CONTENT)}}]),t}(React.Component),overlay_template=document.createElement("span");overlay_template.innerHTML='
',overlay_template=overlay_template.lastChild,Popover.prototype.overflowStyle={},Popover.prototype.wrapperStyle={},module.exports=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=assign_defaults(e.props);return e._lastTargetRect={left:0,top:0,width:0,height:0},e.pack={},e._transitioning=!0,e._doTrack=function(t){return e.__doTrack(t)},e._onClick=function(t){return e.__onClick(t)},e._onResize=function(t){return e.__onResize(t)},e._onScroll=function(t){return e.__onScroll(t)},e._onMouseEnter=function(t){return e.__onMouseEnter(t)},e._onMouseLeave=function(t){return e.__onMouseLeave(t)},e.settings={arrowStyle:{width:defaults.arrowSize,height:defaults.arrowSize},constrainTo:defaults.constrainTo,showing:0,showDelay:defaults.showDelay,hideDelay:defaults.hideDelay,track:defaults.track,constrainHeight:defaults.constrainHeight,constrainWidth:defaults.constrainWidth,className:defaults.className,title:""},e.componentWillUpdate(e.props,n),e.state=n,e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=this,t=ReactDOM.findDOMNode(this);e.setState({target:t}),this._mount_timer=setTimeout(function(){e._updateSync(e.props,e.state)})}},{key:"componentWillUnmount",value:function(){var e=this.state.target,t=e.ownerDocument,n=t.defaultView;this.settings&&(e=this.settings.target)&&(e.removeEventListener("mouseenter",this._onMouseEnter),e.removeEventListener("mouseleave",this._onMouseLeave),e.removeEventListener("click",this._onClick)),this.untrack(),this._resize_timer&&clearTimeout(this._resize_timer),this._show_timer&&clearTimeout(this._show_timer),this._mount_timer&&clearTimeout(this._mount_timer),this.overlay&&this.popoverEl.parentNode===this.overlay&&this.overlay.removeChild(this.popoverEl),this._init_timer&&clearTimeout(this._init_timer),this.settings.bindWindowResize&&n.removeEventListener("resize",this._onResize),this._boundScroll&&this._boundScroll.removeEventListener("scroll",this._onScroll)}},{key:"componentWillUpdate",value:function(e,t){this._updateSync(e,t),!this._group&&group(this)}},{key:"_updateSync",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];n=n||this.state;var r=this.settings,o=t.bindWindowResize||!1,i=n&&n.target,s=r.target,a=t.track||!1,l=i&&i.ownerDocument.defaultView,u=!0===t.bindScroll?"window":t.bindScroll,p=this._boundScroll,c=!!r.target&&this._upwardSelector(u,r);o!==r.bindWindowResize&&(o?l&&(l.addEventListener("resize",this._onResize),r.bindWindowResize=!0):(l&&l.removeEventListener("resize",this._onResize),r.bindWindowResize=!1)),r.titleStyle=t.titleStyle||defaults.titleStyle,r.wrapperStyle=t.wrapperStyle||defaults.wrapperStyle,c!==p&&(p&&(p.removeEventListener("scroll",this._onScroll),this._boundScroll=!1),c&&(c.addEventListener("scroll",this._onScroll,!0),this._boundScroll=c)),a!==r.track&&(a?(r.track=!0,this.track()):(r.track=!1,this.untrack())),i&&s!==i&&(i.addEventListener("mouseenter",this._onMouseEnter),i.addEventListener("mouseleave",this._onMouseLeave),i.addEventListener("click",this._onClick),r.target=i,s&&(s.removeEventListener("mouseenter",this._onMouseEnter),s.removeEventListener("mouseleave",this._onMouseLeave),s.removeEventListener("click",this._onClick))),t.persistOverContent?(r.persistOverContent=!0,r.onEnterContent=function(t){return e.show(t)},r.onLeaveContent=function(t){return e.hide(t)}):(r.persistOverContent=!1,r.onEnterContent=!1,r.onLeaveContent=!1),r.toggleOnClick=void 0!==t.toggleOnClick?t.toggleOnClick:defaults.toggleOnClick,r.showOnMouseEnter=void 0!==t.showOnMouseEnter?t.showOnMouseEnter:defaults.showOnMouseEnter,r.hideOnMouseLeave=void 0!==t.hideOnMouseLeave?t.hideOnMouseLeave:defaults.hideOnMouseLeave,r.constrainHeight=void 0!==t.constrainHeight?t.constrainHeight:defaults.constrainHeight,r.constrainWidth=void 0!==t.constrainWidth?t.constrainWidth:defaults.constrainWidth}},{key:"_updateAsync",value:function(){if(this.settings.target){var e=this,t=this.props,n=t.show,r=this.settings,o=r.showing&SHOWING.PROPERTY,i=r.target.ownerDocument,s=i.body,a=this._upwardSelector(".poppy-container",r),l=this.popover,u=void 0!==t.arrowSize?t.arrowSize:defaults.arrowSize,p=r.mergedArrowStyle=Object.assign({},r.arrowStyle,t.arrowStyle),c=t.region;if(c&&c!==r.last_prop_region?"top"===c?r.region=TOP:"left"===c?r.region=LEFT:"right"===c?r.region=RIGHT:"bottom"===c&&(r.region=BOTTOM):c||(r.region=defaults.region),r.backgroundStyle=t.backgroundStyle,r.last_prop_region=c,r.title=t.title||defaults.title,r.content=t.content||defaults.content,r.className=t.className||defaults.className,r.arrowSize=u,r.arrowSize3_4=.75*u,r.arrowSize1_2=.5*u,r.arrowSize2_1=2*u,r.arrowSize3_2=1.5*u,p.height=p.width=u,this._adjustPosition(this.settings),a===s&&(a=s.querySelector(".poppy-container")),a?this.overlay||(this.overlay=a):s.appendChild(a=this.overlay=overlay_template.cloneNode(!0)),l)this.overlay.ownerDocument!==i&&this.popoverEl&&(a.appendChild(this.popoverEl),this.overlay=a);else{var f=document.createElement("div");l=this.popover=ReactDOM.render(React.createElement(Popover,null),f),a.appendChild(f.lastChild)}l.setState(r),this.popoverEl||(this.popoverEl=ReactDOM.findDOMNode(l)), 2 | //!this._init_timer && requestAnimationFrame(function () { 3 | o&&!n?e.hide(SHOWING.PROPERTY):!o&&n&&e.show(SHOWING.PROPERTY),e._updatePositions()}}},{key:"__onResize",value:function(){var e=this;this._resize_timer&&clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){e._resize_timer=void 0,e.setState({})},60)}},{key:"__onMouseEnter",value:function(){this.settings.showOnMouseEnter&&this.show(SHOWING.MOUSEOVER)}},{key:"__onMouseLeave",value:function(){this.settings.hideOnMouseLeave&&this.hide(SHOWING.MOUSEOVER)}},{key:"__onClick",value:function(){this.settings.toggleOnClick&&(this.settings.showing&SHOWING.CLICK?this.hide(SHOWING.CLICK):this.show(SHOWING.CLICK))}},{key:"_adjustPosition",value:function(e){var t,n,r,o,i=this.pack.targetRect,s=this.pack.parentRect,a=s.width/s.height,l=e.region,u=e.leftSpace=i.left-s.left,p=e.rightSpace=s.left+s.width-(i.left+i.width),c=e.topSpace=i.top-s.top,f=e.bottomSpace=s.top+s.height-(i.top+i.height),h=e.arrowSize,d=e.position,y=e.arrowSize3_4,m=e.constrainHeight,v=e.constrainWidth,g=2*h;d||(d=e.position={}),l||(n=.75*u,r=.75*p,t=c*a,o=f*a,l=e.region=n>o&&n>t&&n>=r?LEFT:r>o&&r>t?RIGHT:t>o?TOP:BOTTOM),l===LEFT?(d.minWidth=h,d.minHeight=g,d.top=d.left=0,v&&(d.maxWidth=Math.max(u-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===RIGHT?(d.minWidth=h,d.top=0,d.minHeight=g,d.left=i.left+i.width+y,v&&(d.maxWidth=Math.max(p-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===BOTTOM?(d.minHeight=h,d.top=i.top+i.height+y,d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(f-y-5,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25))):(d.minHeight=h,d.top=d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(c-y+2,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25)))}},{key:"__onScroll",value:function(){!this._group&&group(this,!0)}},{key:"__doTrack",value:function(){this._track_timer=setTimeout(this._doTrack,16),this.settings.target&&this.popover&&!this._group&&group(this,!0)}},{key:"track",value:function(){return this._track_timer||(this._track_timer=setTimeout(this._doTrack,16)),this}},{key:"untrack",value:function(){return this._track_timer&&(clearTimeout(this._track_timer),this._track_timer=!1),this}},{key:"refresh",value:function(){return this.setState({}),this}},{key:"hide",value:function(e){var t=this,n=this.settings,r=n.showing;if(r&&r&e){n.showing-=e;var o=this.popoverEl,i=o.style;this._show_timer&&clearTimeout(this._show_timer),this._show_timer=setTimeout(function(){n.showing||(!o.$listener&&o.addEventListener("transitionend",o.$listener=function(){o.removeEventListener("transitionend",o.$listener),o.$listener=!1,!n.showing&&(o.style.visibility="hidden")}),t._show_timer=void 0,i.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",n.region===RIGHT?i.transform="translateX(30px)translateY(0px)":n.region===LEFT?i.transform="translateX(-30px)translateY(0px)":n.region===TOP?i.transform="translateX(0px)translateY(-30px)":i.transform="translateX(0px)translateY(30px)",i.pointerEvents="none",i.opacity=0,t.props.onHide&&t.props.onHide())},n.hideDelay)}}},{key:"show",value:function(e){var t=this,n=this.settings,r=this.popoverEl,o=r.style,i=!0,s=n.showing;n.showing|=e,s||(this._show_timer&&(clearTimeout(this._show_timer),this._show_timer=void 0,i=!1),r.$listener&&r.removeEventListener("transitionend",r.$listener),r.$listener=!1,i?this._show_timer=setTimeout(function(){n.showing&&(t.props.onShow&&t.props.onShow(),t._show_timer=void 0,o.transition=null,n.region===RIGHT?o.transfrom="translateX(30px)translateY(0px)":n.region===LEFT?o.transform="translateX(-30px)translateY(0px)":n.region===TOP?o.transform="translateX(0px)translateY(-30px)":o.transform="translateX(0px)translateY(30px)",o.pointerEvents="all",t._show_timer=setTimeout(function(){t._show_timer=void 0,o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"},n.showDelay))}):(o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"))}},{key:"_upwardSelector",value:function(e,t){var n=t.target,r=n.ownerDocument;if(!e)return e;if("string"==typeof e){if("body"===e)return r.body;if("parent"===e)return n&&n.parentNode;if("window"===e)return n&&n.ownerDocument.defaultView;for(;n;){if(n.matches&&n.matches(e))return n;n=n.parentNode}return r.body}return(n=ReactDOM.findDOMNode(e))?n:e}},{key:"_updatePositions",value:function(){if(this.settings.target){var e,t,n,r,o,i,s,a,l=this.popover.refs.overflow,u=l.style,p=this.popover.refs.wrapper.style,c=this.popover.refs.arrow,f=c.style,h=this.popover.refs.content.style,d=this.settings,y=this.popover.refs.title,m=y&&y.getBoundingClientRect(),v=this.pack.targetRect,g=this.pack.parentRect,_=m&&m.width||0,w=m&&m.height||0,b=v.top,T=v.width,O=T/2,E=v.height,S=E/2,x=v.left,k=t=g.top,R=n=g.left,C=0|n,N=0|t,M=d.region,L=d.leftSpace,H=d.topSpace,P=0|d.arrowSize,W=d.arrowSize1_2,z=d.arrowSize3_4,j=d.arrowSize2_1,D=d.arrowSize3_2,I=d.position.left,A=d.position.top;u.paddingTop=w+"px",u.maxHeight=Math.max(Math.round(this.settings.position.maxHeight-w),0)+"px",e=l.getBoundingClientRect(),r=Math.max(e.width,_),o=e.height,this.settings.target&&(M===TOP||M===BOTTOM?(s=5,i=R+g.width-5,n=x+O-r/2,n(a=i-r)&&(n=a),(a=x+P)>i&&(n=a-r),C+=L+O-P,C=Math.max(Math.min(C,n+r-j),n)+W,I=n,M===TOP?(A=b-o-z-9,N=b-z-9-W):N=A-W):M!==LEFT&&M!==RIGHT||(t+=H+E-S-o/2,i=k+g.height-5,s=5,t(a=i-o)&&(t=a),(a=b+P)>i&&(t=a-o),N+=H+S-P,N=Math.max(Math.min(N,t+o-j),t)+W,A=t,M===LEFT?(I=x-r-z-6,C=I+r-W-1):(I=x+T+z,C=I-W+1)),h.width=p.width=(0|r)+"px",isSafari&&this._unsafe&&this.popoverEl&&(this.popoverEl.style.transition=f.transition=h.transition=p.transition=group_timer?"none":null),h.width=p.width=(0|r)+"px",f.top=(0|N)+"px",f.left=(0|C)+"px",p.top=h.top=(0|A)+"px",p.left=h.left=(0|I)+"px",p.height=(0|o)+"px",this.settings.showing&&this.popoverEl.style.visiblity&&(this.popoverEl.style.visiblity=null))}}},{key:"render",value:function(){var e=this.props.children;return"string"==typeof e&&(e=React.createElement("span",null,e)),e||null}}]),t}(React.Component),module.exports.propTypes={children:propTypes.any,constrainTo:propTypes.any,show:propTypes.bool,showDelay:propTypes.number,hideDelay:propTypes.number,track:propTypes.bool,constrainHeight:propTypes.bool,constrainWidth:propTypes.bool,arrowSize:propTypes.number,region:propTypes.oneOf(["left","right","top","bottom",null,!1,void 0]),bindScroll:propTypes.oneOfType([propTypes.bool,propTypes.string]),bindWindowResize:propTypes.bool,arrowStyle:propTypes.object,backgroundStyle:propTypes.object,wrapperStyle:propTypes.object,titleStyle:propTypes.object,className:propTypes.string,title:propTypes.any,showOnMouseEnter:propTypes.bool,hideOnMouseLeave:propTypes.bool,toggleOnClick:propTypes.bool,persistOverContent:propTypes.bool,onHide:propTypes.func,onShow:propTypes.func},module.exports.defaultProps={constrainTo:"parent",showDelay:300,hideDelay:320,track:!1,constrainHeight:!0,constrainWidth:!0,arrowSize:15,bindScroll:!1,bindWindowResize:!1,className:"",title:"",showOnMouseEnter:!0,hideOnMouseLeave:!0,toggleOnClick:!1,persistOverContent:!1}},function(e,t){e.exports=require("react-dom")},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(13)()}).call(t,n(0))},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),s=n(3),a=n(12);e.exports=function(e,n){function l(e){var t=e&&(S&&e[S]||e[x]);if("function"==typeof t)return t}function u(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function p(e){this.message=e,this.stack=""}function c(e){function r(r,u,c,f,h,d,y){if(f=f||k,d=d||c,y!==s)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var m=f+":"+c;!a[m]&&l<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),a[m]=!0,l++)}return null==u[c]?r?new p(null===u[c]?"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `null`.":"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(u,c,f,h,d)}if("production"!==t.env.NODE_ENV)var a={},l=0;var u=r.bind(null,!1);return u.isRequired=r.bind(null,!0),u}function f(e){function t(t,n,r,o,i,s){var a=t[n];if(b(a)!==e)return new p("Invalid "+o+" `"+i+"` of type `"+T(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return c(t)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new p("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new p("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+r+"`, expected an array.")}for(var l=0;l1)for(var n=1;n1?t-1:0),r=1;r2?r-2:0),i=2;i=0&&isSafari.indexOf("chrome")<0;var SHOWING={NONE:0,MOUSEOVER:1,CONTENT:2,CLICK:4,PROPERTY:8},LEFT=1,RIGHT=2,TOP=3,BOTTOM=4,defaults={backgroundStyle:void 0,arrowStyle:{},wrapperStyle:void 0,titleStyle:void 0,content:"",className:"",title:"",position:{overflow:"auto",position:"relative",top:0,height:"100%",left:0,width:"100%"},constrainTo:"parent",persistOverContent:!1,showOnMouseEnter:!0,hideOnMouseLeave:!0,bindWindowResize:!1,bindScroll:!1,toggleOnClick:!1,constrainWidth:!0,constrainHeight:!0,track:!1,arrowSize:15,region:void 0,show:void 0,showDelay:300,hideDelay:320},getDefaults=eval("(function () {return "+JSON.stringify(defaults)+";})");!function(defaults){var p,item;for(p in defaults)(item=defaults[p])&&"object"===(void 0===item?"undefined":_typeof(item))&&(defaults[p]=eval("(function (obj) {var result ="+JSON.stringify(item)+",p; for (p in obj) {result[p]=obj[p]} return result;})"))}(defaults);var Popover=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._onExit=function(t){e.__onExit(t)},e._onEnter=function(t){e.__onEnter(t)},e}return _inherits(t,e),_createClass(t,[{key:"shouldComponentUpdate",value:function(e,t){var n=this.state||{},r=t.position||{};return this.minWidth!==r.minWidth||this.minHeight!==r.minHeight||this.maxWidth!==r.maxWidth||n.content!==t.content||n.title!==t.title||this.maxHeight!==r.maxHeight}},{key:"render",value:function(){var e=this.state;if(!e)return null;var t=e.title,n=e.position,r=n.maxWidth,o=n.maxHeight,i=n.minWidth,s=n.minHeight,a=e.content,l=this.overflowStyle,u=this.wrapperStyle,p=e.wrapperStyle||{},c=e.backgroundStyle||{};return l.overflow=a?"auto":null,this.maxHeight=l.maxHeight=u.maxHeight=o,this.maxWidth=l.maxWidth=u.maxWidth=r,this.minHeight=c.minHeight=p.minHeight=s,this.minWidth=c.minWidth=p.minWidth=i,React.createElement("span",{className:"poppy "+(e.className||""),onMouseOver:this._onEnter,onMouseOut:this._onExit},React.createElement("span",{ref:"inner",style:e.backgroundStyle,className:"poppy-background"},React.createElement("div",{ref:"arrow",className:"poppy-arrow",style:e.mergedArrowStyle}),React.createElement("div",{ref:"wrapper",className:"poppy-background-overlay",style:p})),React.createElement("div",{ref:"content",className:"poppy-content-wrapper",style:u},t?React.createElement("div",{ref:"titleWrapper",style:e.titleStyle,className:"poppy-title-wrapper"},React.createElement("span",{ref:"title",className:"poppy-title"},e.title)):null,React.createElement("div",{ref:"overflow",className:"poppy-overflow",style:l},a?React.createElement("div",{ref:"popover",className:"poppy-content"}," ",a||""," "):React.createElement("span",{ref:"popover"}))))}},{key:"__onEnter",value:function(){this.state.onEnterContent&&this.state.onEnterContent(SHOWING.CONTENT)}},{key:"__onExit",value:function(){this.state.onLeaveContent&&this.state.onLeaveContent(SHOWING.CONTENT)}}]),t}(React.Component),overlay_template=document.createElement("span");overlay_template.innerHTML='
',overlay_template=overlay_template.lastChild,Popover.prototype.overflowStyle={},Popover.prototype.wrapperStyle={},module.exports=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=assign_defaults(e.props);return e._lastTargetRect={left:0,top:0,width:0,height:0},e.pack={},e._transitioning=!0,e._doTrack=function(t){return e.__doTrack(t)},e._onClick=function(t){return e.__onClick(t)},e._onResize=function(t){return e.__onResize(t)},e._onScroll=function(t){return e.__onScroll(t)},e._onMouseEnter=function(t){return e.__onMouseEnter(t)},e._onMouseLeave=function(t){return e.__onMouseLeave(t)},e.settings={arrowStyle:{width:defaults.arrowSize,height:defaults.arrowSize},constrainTo:defaults.constrainTo,showing:0,showDelay:defaults.showDelay,hideDelay:defaults.hideDelay,track:defaults.track,constrainHeight:defaults.constrainHeight,constrainWidth:defaults.constrainWidth,className:defaults.className,title:""},e.componentWillUpdate(e.props,n),e.state=n,e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=this,t=ReactDOM.findDOMNode(this);e.setState({target:t}),this._mount_timer=setTimeout(function(){e._updateSync(e.props,e.state)})}},{key:"componentWillUnmount",value:function(){var e=this.state.target,t=e.ownerDocument,n=t.defaultView;this.settings&&(e=this.settings.target)&&(e.removeEventListener("mouseenter",this._onMouseEnter),e.removeEventListener("mouseleave",this._onMouseLeave),e.removeEventListener("click",this._onClick)),this.untrack(),this._resize_timer&&clearTimeout(this._resize_timer),this._show_timer&&clearTimeout(this._show_timer),this._mount_timer&&clearTimeout(this._mount_timer),this.overlay&&this.popoverEl.parentNode===this.overlay&&this.overlay.removeChild(this.popoverEl),this._init_timer&&clearTimeout(this._init_timer),this.settings.bindWindowResize&&n.removeEventListener("resize",this._onResize),this._boundScroll&&this._boundScroll.removeEventListener("scroll",this._onScroll)}},{key:"componentWillUpdate",value:function(e,t){this._updateSync(e,t),!this._group&&group(this)}},{key:"_updateSync",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];n=n||this.state;var r=this.settings,o=t.bindWindowResize||!1,i=n&&n.target,s=r.target,a=t.track||!1,l=i&&i.ownerDocument.defaultView,u=!0===t.bindScroll?"window":t.bindScroll,p=this._boundScroll,c=!!r.target&&this._upwardSelector(u,r);o!==r.bindWindowResize&&(o?l&&(l.addEventListener("resize",this._onResize),r.bindWindowResize=!0):(l&&l.removeEventListener("resize",this._onResize),r.bindWindowResize=!1)),r.titleStyle=t.titleStyle||defaults.titleStyle,r.wrapperStyle=t.wrapperStyle||defaults.wrapperStyle,c!==p&&(p&&(p.removeEventListener("scroll",this._onScroll),this._boundScroll=!1),c&&(c.addEventListener("scroll",this._onScroll,!0),this._boundScroll=c)),a!==r.track&&(a?(r.track=!0,this.track()):(r.track=!1,this.untrack())),i&&s!==i&&(i.addEventListener("mouseenter",this._onMouseEnter),i.addEventListener("mouseleave",this._onMouseLeave),i.addEventListener("click",this._onClick),r.target=i,s&&(s.removeEventListener("mouseenter",this._onMouseEnter),s.removeEventListener("mouseleave",this._onMouseLeave),s.removeEventListener("click",this._onClick))),t.persistOverContent?(r.persistOverContent=!0,r.onEnterContent=function(t){return e.show(t)},r.onLeaveContent=function(t){return e.hide(t)}):(r.persistOverContent=!1,r.onEnterContent=!1,r.onLeaveContent=!1),r.toggleOnClick=void 0!==t.toggleOnClick?t.toggleOnClick:defaults.toggleOnClick,r.showOnMouseEnter=void 0!==t.showOnMouseEnter?t.showOnMouseEnter:defaults.showOnMouseEnter,r.hideOnMouseLeave=void 0!==t.hideOnMouseLeave?t.hideOnMouseLeave:defaults.hideOnMouseLeave,r.constrainHeight=void 0!==t.constrainHeight?t.constrainHeight:defaults.constrainHeight,r.constrainWidth=void 0!==t.constrainWidth?t.constrainWidth:defaults.constrainWidth}},{key:"_updateAsync",value:function(){if(this.settings.target){var e=this,t=this.props,n=t.show,r=this.settings,o=r.showing&SHOWING.PROPERTY,i=r.target.ownerDocument,s=i.body,a=this._upwardSelector(".poppy-container",r),l=this.popover,u=void 0!==t.arrowSize?t.arrowSize:defaults.arrowSize,p=r.mergedArrowStyle=Object.assign({},r.arrowStyle,t.arrowStyle),c=t.region;if(c&&c!==r.last_prop_region?"top"===c?r.region=TOP:"left"===c?r.region=LEFT:"right"===c?r.region=RIGHT:"bottom"===c&&(r.region=BOTTOM):c||(r.region=defaults.region),r.backgroundStyle=t.backgroundStyle,r.last_prop_region=c,r.title=t.title||defaults.title,r.content=t.content||defaults.content,r.className=t.className||defaults.className,r.arrowSize=u,r.arrowSize3_4=.75*u,r.arrowSize1_2=.5*u,r.arrowSize2_1=2*u,r.arrowSize3_2=1.5*u,p.height=p.width=u,this._adjustPosition(this.settings),a===s&&(a=s.querySelector(".poppy-container")),a?this.overlay||(this.overlay=a):s.appendChild(a=this.overlay=overlay_template.cloneNode(!0)),l)this.overlay.ownerDocument!==i&&this.popoverEl&&(a.appendChild(this.popoverEl),this.overlay=a);else{var f=document.createElement("div");l=this.popover=ReactDOM.render(React.createElement(Popover,null),f),a.appendChild(f.lastChild)}l.setState(r),this.popoverEl||(this.popoverEl=ReactDOM.findDOMNode(l)), 2 | //!this._init_timer && requestAnimationFrame(function () { 3 | o&&!n?e.hide(SHOWING.PROPERTY):!o&&n&&e.show(SHOWING.PROPERTY),e._updatePositions()}}},{key:"__onResize",value:function(){var e=this;this._resize_timer&&clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){e._resize_timer=void 0,e.setState({})},60)}},{key:"__onMouseEnter",value:function(){this.settings.showOnMouseEnter&&this.show(SHOWING.MOUSEOVER)}},{key:"__onMouseLeave",value:function(){this.settings.hideOnMouseLeave&&this.hide(SHOWING.MOUSEOVER)}},{key:"__onClick",value:function(){this.settings.toggleOnClick&&(this.settings.showing&SHOWING.CLICK?this.hide(SHOWING.CLICK):this.show(SHOWING.CLICK))}},{key:"_adjustPosition",value:function(e){var t,n,r,o,i=this.pack.targetRect,s=this.pack.parentRect,a=s.width/s.height,l=e.region,u=e.leftSpace=i.left-s.left,p=e.rightSpace=s.left+s.width-(i.left+i.width),c=e.topSpace=i.top-s.top,f=e.bottomSpace=s.top+s.height-(i.top+i.height),h=e.arrowSize,d=e.position,y=e.arrowSize3_4,m=e.constrainHeight,v=e.constrainWidth,g=2*h;d||(d=e.position={}),l||(n=.75*u,r=.75*p,t=c*a,o=f*a,l=e.region=n>o&&n>t&&n>=r?LEFT:r>o&&r>t?RIGHT:t>o?TOP:BOTTOM),l===LEFT?(d.minWidth=h,d.minHeight=g,d.top=d.left=0,v&&(d.maxWidth=Math.max(u-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===RIGHT?(d.minWidth=h,d.top=0,d.minHeight=g,d.left=i.left+i.width+y,v&&(d.maxWidth=Math.max(p-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):l===BOTTOM?(d.minHeight=h,d.top=i.top+i.height+y,d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(f-y-5,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25))):(d.minHeight=h,d.top=d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(c-y+2,25)),v&&(d.maxWidth=Math.max(u+p+i.width-30,25)))}},{key:"__onScroll",value:function(){!this._group&&group(this,!0)}},{key:"__doTrack",value:function(){this._track_timer=setTimeout(this._doTrack,16),this.settings.target&&this.popover&&!this._group&&group(this,!0)}},{key:"track",value:function(){return this._track_timer||(this._track_timer=setTimeout(this._doTrack,16)),this}},{key:"untrack",value:function(){return this._track_timer&&(clearTimeout(this._track_timer),this._track_timer=!1),this}},{key:"refresh",value:function(){return this.setState({}),this}},{key:"hide",value:function(e){var t=this,n=this.settings,r=n.showing;if(r&&r&e){n.showing-=e;var o=this.popoverEl,i=o.style;this._show_timer&&clearTimeout(this._show_timer),this._show_timer=setTimeout(function(){n.showing||(!o.$listener&&o.addEventListener("transitionend",o.$listener=function(){o.removeEventListener("transitionend",o.$listener),o.$listener=!1,!n.showing&&(o.style.visibility="hidden")}),t._show_timer=void 0,i.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",n.region===RIGHT?i.transform="translateX(30px)translateY(0px)":n.region===LEFT?i.transform="translateX(-30px)translateY(0px)":n.region===TOP?i.transform="translateX(0px)translateY(-30px)":i.transform="translateX(0px)translateY(30px)",i.pointerEvents="none",i.opacity=0,t.props.onHide&&t.props.onHide())},n.hideDelay)}}},{key:"show",value:function(e){var t=this,n=this.settings,r=this.popoverEl,o=r.style,i=!0,s=n.showing;n.showing|=e,s||(this._show_timer&&(clearTimeout(this._show_timer),this._show_timer=void 0,i=!1),r.$listener&&r.removeEventListener("transitionend",r.$listener),r.$listener=!1,i?this._show_timer=setTimeout(function(){n.showing&&(t.props.onShow&&t.props.onShow(),t._show_timer=void 0,o.transition=null,n.region===RIGHT?o.transfrom="translateX(30px)translateY(0px)":n.region===LEFT?o.transform="translateX(-30px)translateY(0px)":n.region===TOP?o.transform="translateX(0px)translateY(-30px)":o.transform="translateX(0px)translateY(30px)",o.pointerEvents="all",t._show_timer=setTimeout(function(){t._show_timer=void 0,o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"},n.showDelay))}):(o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"))}},{key:"_upwardSelector",value:function(e,t){var n=t.target,r=n.ownerDocument;if(!e)return e;if("string"==typeof e){if("body"===e)return r.body;if("parent"===e)return n&&n.parentNode;if("window"===e)return n&&n.ownerDocument.defaultView;for(;n;){if(n.matches&&n.matches(e))return n;n=n.parentNode}return r.body}return(n=ReactDOM.findDOMNode(e))?n:e}},{key:"_updatePositions",value:function(){if(this.settings.target){var e,t,n,r,o,i,s,a,l=this.popover.refs.overflow,u=l.style,p=this.popover.refs.wrapper.style,c=this.popover.refs.arrow,f=c.style,h=this.popover.refs.content.style,d=this.settings,y=this.popover.refs.title,m=y&&y.getBoundingClientRect(),v=this.pack.targetRect,g=this.pack.parentRect,_=m&&m.width||0,w=m&&m.height||0,b=v.top,T=v.width,O=T/2,E=v.height,S=E/2,x=v.left,k=t=g.top,R=n=g.left,C=0|n,N=0|t,M=d.region,L=d.leftSpace,H=d.topSpace,P=0|d.arrowSize,W=d.arrowSize1_2,z=d.arrowSize3_4,j=d.arrowSize2_1,D=d.arrowSize3_2,I=d.position.left,A=d.position.top;u.paddingTop=w+"px",u.maxHeight=Math.max(Math.round(this.settings.position.maxHeight-w),0)+"px",e=l.getBoundingClientRect(),r=Math.max(e.width,_),o=e.height,this.settings.target&&(M===TOP||M===BOTTOM?(s=5,i=R+g.width-5,n=x+O-r/2,n(a=i-r)&&(n=a),(a=x+P)>i&&(n=a-r),C+=L+O-P,C=Math.max(Math.min(C,n+r-j),n)+W,I=n,M===TOP?(A=b-o-z-9,N=b-z-9-W):N=A-W):M!==LEFT&&M!==RIGHT||(t+=H+E-S-o/2,i=k+g.height-5,s=5,t(a=i-o)&&(t=a),(a=b+P)>i&&(t=a-o),N+=H+S-P,N=Math.max(Math.min(N,t+o-j),t)+W,A=t,M===LEFT?(I=x-r-z-6,C=I+r-W-1):(I=x+T+z,C=I-W+1)),h.width=p.width=(0|r)+"px",isSafari&&this._unsafe&&this.popoverEl&&(this.popoverEl.style.transition=f.transition=h.transition=p.transition=group_timer?"none":null),h.width=p.width=(0|r)+"px",f.top=(0|N)+"px",f.left=(0|C)+"px",p.top=h.top=(0|A)+"px",p.left=h.left=(0|I)+"px",p.height=(0|o)+"px",this.settings.showing&&this.popoverEl.style.visiblity&&(this.popoverEl.style.visiblity=null))}}},{key:"render",value:function(){var e=this.props.children;return"string"==typeof e&&(e=React.createElement("span",null,e)),e||null}}]),t}(React.Component),module.exports.propTypes={children:propTypes.any,constrainTo:propTypes.any,show:propTypes.bool,showDelay:propTypes.number,hideDelay:propTypes.number,track:propTypes.bool,constrainHeight:propTypes.bool,constrainWidth:propTypes.bool,arrowSize:propTypes.number,region:propTypes.oneOf(["left","right","top","bottom",null,!1,void 0]),bindScroll:propTypes.oneOfType([propTypes.bool,propTypes.string]),bindWindowResize:propTypes.bool,arrowStyle:propTypes.object,backgroundStyle:propTypes.object,wrapperStyle:propTypes.object,titleStyle:propTypes.object,className:propTypes.string,title:propTypes.any,showOnMouseEnter:propTypes.bool,hideOnMouseLeave:propTypes.bool,toggleOnClick:propTypes.bool,persistOverContent:propTypes.bool,onHide:propTypes.func,onShow:propTypes.func},module.exports.defaultProps={constrainTo:"parent",showDelay:300,hideDelay:320,track:!1,constrainHeight:!0,constrainWidth:!0,arrowSize:15,bindScroll:!1,bindWindowResize:!1,className:"",title:"",showOnMouseEnter:!0,hideOnMouseLeave:!0,toggleOnClick:!1,persistOverContent:!1}},function(e,t){e.exports=void 0},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(13)()}).call(t,n(0))},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),s=n(3),a=n(12);e.exports=function(e,n){function l(e){var t=e&&(S&&e[S]||e[x]);if("function"==typeof t)return t}function u(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function p(e){this.message=e,this.stack=""}function c(e){function r(r,u,c,f,h,d,y){if(f=f||k,d=d||c,y!==s)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var m=f+":"+c;!a[m]&&l<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),a[m]=!0,l++)}return null==u[c]?r?new p(null===u[c]?"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `null`.":"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(u,c,f,h,d)}if("production"!==t.env.NODE_ENV)var a={},l=0;var u=r.bind(null,!1);return u.isRequired=r.bind(null,!0),u}function f(e){function t(t,n,r,o,i,s){var a=t[n];if(b(a)!==e)return new p("Invalid "+o+" `"+i+"` of type `"+T(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return c(t)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new p("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new p("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+r+"`, expected an array.")}for(var l=0;l1)for(var n=1;n1?t-1:0),r=1;r2?r-2:0),i=2;i=0&&isSafari.indexOf("chrome")<0;var SHOWING={NONE:0,MOUSEOVER:1,CONTENT:2,CLICK:4,PROPERTY:8},LEFT=1,RIGHT=2,TOP=3,BOTTOM=4,defaults={backgroundStyle:void 0,arrowStyle:{},wrapperStyle:void 0,titleStyle:void 0,content:"",className:"",title:"",position:{overflow:"auto",position:"relative",top:0,height:"100%",left:0,width:"100%"},constrainTo:"parent",persistOverContent:!1,showOnMouseEnter:!0,hideOnMouseLeave:!0,bindWindowResize:!1,bindScroll:!1,toggleOnClick:!1,constrainWidth:!0,constrainHeight:!0,track:!1,arrowSize:15,region:void 0,show:void 0,showDelay:300,hideDelay:320},getDefaults=eval("(function () {return "+JSON.stringify(defaults)+";})");!function(defaults){var p,item;for(p in defaults)(item=defaults[p])&&"object"===(void 0===item?"undefined":_typeof(item))&&(defaults[p]=eval("(function (obj) {var result ="+JSON.stringify(item)+",p; for (p in obj) {result[p]=obj[p]} return result;})"))}(defaults);var Popover=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._onExit=function(t){e.__onExit(t)},e._onEnter=function(t){e.__onEnter(t)},e}return _inherits(t,e),_createClass(t,[{key:"shouldComponentUpdate",value:function(e,t){var n=this.state||{},r=t.position||{};return this.minWidth!==r.minWidth||this.minHeight!==r.minHeight||this.maxWidth!==r.maxWidth||n.content!==t.content||n.title!==t.title||this.maxHeight!==r.maxHeight}},{key:"render",value:function(){var e=this.state;if(!e)return null;var t=e.title,n=e.position,r=n.maxWidth,o=n.maxHeight,i=n.minWidth,s=n.minHeight,a=e.content,u=this.overflowStyle,l=this.wrapperStyle,p=e.wrapperStyle||{},c=e.backgroundStyle||{};return u.overflow=a?"auto":null,this.maxHeight=u.maxHeight=l.maxHeight=o,this.maxWidth=u.maxWidth=l.maxWidth=r,this.minHeight=c.minHeight=p.minHeight=s,this.minWidth=c.minWidth=p.minWidth=i,React.createElement("span",{className:"poppy "+(e.className||""),onMouseOver:this._onEnter,onMouseOut:this._onExit},React.createElement("span",{ref:"inner",style:e.backgroundStyle,className:"poppy-background"},React.createElement("div",{ref:"arrow",className:"poppy-arrow",style:e.mergedArrowStyle}),React.createElement("div",{ref:"wrapper",className:"poppy-background-overlay",style:p})),React.createElement("div",{ref:"content",className:"poppy-content-wrapper",style:l},t?React.createElement("div",{ref:"titleWrapper",style:e.titleStyle,className:"poppy-title-wrapper"},React.createElement("span",{ref:"title",className:"poppy-title"},e.title)):null,React.createElement("div",{ref:"overflow",className:"poppy-overflow",style:u},a?React.createElement("div",{ref:"popover",className:"poppy-content"}," ",a||""," "):React.createElement("span",{ref:"popover"}))))}},{key:"__onEnter",value:function(){this.state.onEnterContent&&this.state.onEnterContent(SHOWING.CONTENT)}},{key:"__onExit",value:function(){this.state.onLeaveContent&&this.state.onLeaveContent(SHOWING.CONTENT)}}]),t}(React.Component),overlay_template=document.createElement("span");overlay_template.innerHTML='
',overlay_template=overlay_template.lastChild,Popover.prototype.overflowStyle={},Popover.prototype.wrapperStyle={},module.exports=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=assign_defaults(e.props);return e._lastTargetRect={left:0,top:0,width:0,height:0},e.pack={},e._transitioning=!0,e._doTrack=function(t){return e.__doTrack(t)},e._onClick=function(t){return e.__onClick(t)},e._onResize=function(t){return e.__onResize(t)},e._onScroll=function(t){return e.__onScroll(t)},e._onMouseEnter=function(t){return e.__onMouseEnter(t)},e._onMouseLeave=function(t){return e.__onMouseLeave(t)},e.settings={arrowStyle:{width:defaults.arrowSize,height:defaults.arrowSize},constrainTo:defaults.constrainTo,showing:0,showDelay:defaults.showDelay,hideDelay:defaults.hideDelay,track:defaults.track,constrainHeight:defaults.constrainHeight,constrainWidth:defaults.constrainWidth,className:defaults.className,title:""},e.componentWillUpdate(e.props,n),e.state=n,e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=this,t=ReactDOM.findDOMNode(this);e.setState({target:t}),this._mount_timer=setTimeout(function(){e._updateSync(e.props,e.state)})}},{key:"componentWillUnmount",value:function(){var e=this.state.target,t=e.ownerDocument,n=t.defaultView;this.settings&&(e=this.settings.target)&&(e.removeEventListener("mouseenter",this._onMouseEnter),e.removeEventListener("mouseleave",this._onMouseLeave),e.removeEventListener("click",this._onClick)),this.untrack(),this._resize_timer&&clearTimeout(this._resize_timer),this._show_timer&&clearTimeout(this._show_timer),this._mount_timer&&clearTimeout(this._mount_timer),this.overlay&&this.popoverEl.parentNode===this.overlay&&this.overlay.removeChild(this.popoverEl),this._init_timer&&clearTimeout(this._init_timer),this.settings.bindWindowResize&&n.removeEventListener("resize",this._onResize),this._boundScroll&&this._boundScroll.removeEventListener("scroll",this._onScroll)}},{key:"componentWillUpdate",value:function(e,t){this._updateSync(e,t),!this._group&&group(this)}},{key:"_updateSync",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];n=n||this.state;var r=this.settings,o=t.bindWindowResize||!1,i=n&&n.target,s=r.target,a=t.track||!1,u=i&&i.ownerDocument.defaultView,l=!0===t.bindScroll?"window":t.bindScroll,p=this._boundScroll,c=!!r.target&&this._upwardSelector(l,r);o!==r.bindWindowResize&&(o?u&&(u.addEventListener("resize",this._onResize),r.bindWindowResize=!0):(u&&u.removeEventListener("resize",this._onResize),r.bindWindowResize=!1)),r.titleStyle=t.titleStyle||defaults.titleStyle,r.wrapperStyle=t.wrapperStyle||defaults.wrapperStyle,c!==p&&(p&&(p.removeEventListener("scroll",this._onScroll),this._boundScroll=!1),c&&(c.addEventListener("scroll",this._onScroll,!0),this._boundScroll=c)),a!==r.track&&(a?(r.track=!0,this.track()):(r.track=!1,this.untrack())),i&&s!==i&&(i.addEventListener("mouseenter",this._onMouseEnter),i.addEventListener("mouseleave",this._onMouseLeave),i.addEventListener("click",this._onClick),r.target=i,s&&(s.removeEventListener("mouseenter",this._onMouseEnter),s.removeEventListener("mouseleave",this._onMouseLeave),s.removeEventListener("click",this._onClick))),t.persistOverContent?(r.persistOverContent=!0,r.onEnterContent=function(t){return e.show(t)},r.onLeaveContent=function(t){return e.hide(t)}):(r.persistOverContent=!1,r.onEnterContent=!1,r.onLeaveContent=!1),r.toggleOnClick=void 0!==t.toggleOnClick?t.toggleOnClick:defaults.toggleOnClick,r.showOnMouseEnter=void 0!==t.showOnMouseEnter?t.showOnMouseEnter:defaults.showOnMouseEnter,r.hideOnMouseLeave=void 0!==t.hideOnMouseLeave?t.hideOnMouseLeave:defaults.hideOnMouseLeave,r.constrainHeight=void 0!==t.constrainHeight?t.constrainHeight:defaults.constrainHeight,r.constrainWidth=void 0!==t.constrainWidth?t.constrainWidth:defaults.constrainWidth}},{key:"_updateAsync",value:function(){if(this.settings.target){var e=this,t=this.props,n=t.show,r=this.settings,o=r.showing&SHOWING.PROPERTY,i=r.target.ownerDocument,s=i.body,a=this._upwardSelector(".poppy-container",r),u=this.popover,l=void 0!==t.arrowSize?t.arrowSize:defaults.arrowSize,p=r.mergedArrowStyle=Object.assign({},r.arrowStyle,t.arrowStyle),c=t.region;if(c&&c!==r.last_prop_region?"top"===c?r.region=TOP:"left"===c?r.region=LEFT:"right"===c?r.region=RIGHT:"bottom"===c&&(r.region=BOTTOM):c||(r.region=defaults.region),r.backgroundStyle=t.backgroundStyle,r.last_prop_region=c,r.title=t.title||defaults.title,r.content=t.content||defaults.content,r.className=t.className||defaults.className,r.arrowSize=l,r.arrowSize3_4=.75*l,r.arrowSize1_2=.5*l,r.arrowSize2_1=2*l,r.arrowSize3_2=1.5*l,p.height=p.width=l,this._adjustPosition(this.settings),a===s&&(a=s.querySelector(".poppy-container")),a?this.overlay||(this.overlay=a):s.appendChild(a=this.overlay=overlay_template.cloneNode(!0)),u)this.overlay.ownerDocument!==i&&this.popoverEl&&(a.appendChild(this.popoverEl),this.overlay=a);else{var f=document.createElement("div");u=this.popover=ReactDOM.render(React.createElement(Popover,null),f),a.appendChild(f.lastChild)}u.setState(r),this.popoverEl||(this.popoverEl=ReactDOM.findDOMNode(u)), 2 | //!this._init_timer && requestAnimationFrame(function () { 3 | o&&!n?e.hide(SHOWING.PROPERTY):!o&&n&&e.show(SHOWING.PROPERTY),e._updatePositions()}}},{key:"__onResize",value:function(){var e=this;this._resize_timer&&clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){e._resize_timer=void 0,e.setState({})},60)}},{key:"__onMouseEnter",value:function(){this.settings.showOnMouseEnter&&this.show(SHOWING.MOUSEOVER)}},{key:"__onMouseLeave",value:function(){this.settings.hideOnMouseLeave&&this.hide(SHOWING.MOUSEOVER)}},{key:"__onClick",value:function(){this.settings.toggleOnClick&&(this.settings.showing&SHOWING.CLICK?this.hide(SHOWING.CLICK):this.show(SHOWING.CLICK))}},{key:"_adjustPosition",value:function(e){var t,n,r,o,i=this.pack.targetRect,s=this.pack.parentRect,a=s.width/s.height,u=e.region,l=e.leftSpace=i.left-s.left,p=e.rightSpace=s.left+s.width-(i.left+i.width),c=e.topSpace=i.top-s.top,f=e.bottomSpace=s.top+s.height-(i.top+i.height),h=e.arrowSize,d=e.position,y=e.arrowSize3_4,m=e.constrainHeight,v=e.constrainWidth,g=2*h;d||(d=e.position={}),u||(n=.75*l,r=.75*p,t=c*a,o=f*a,u=e.region=n>o&&n>t&&n>=r?LEFT:r>o&&r>t?RIGHT:t>o?TOP:BOTTOM),u===LEFT?(d.minWidth=h,d.minHeight=g,d.top=d.left=0,v&&(d.maxWidth=Math.max(l-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):u===RIGHT?(d.minWidth=h,d.top=0,d.minHeight=g,d.left=i.left+i.width+y,v&&(d.maxWidth=Math.max(p-y-25,g)),m&&(d.maxHeight=Math.max(c+f+i.height-30,5))):u===BOTTOM?(d.minHeight=h,d.top=i.top+i.height+y,d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(f-y-5,25)),v&&(d.maxWidth=Math.max(l+p+i.width-30,25))):(d.minHeight=h,d.top=d.left=0,d.minWidth=g,m&&(d.maxHeight=Math.max(c-y+2,25)),v&&(d.maxWidth=Math.max(l+p+i.width-30,25)))}},{key:"__onScroll",value:function(){!this._group&&group(this,!0)}},{key:"__doTrack",value:function(){this._track_timer=setTimeout(this._doTrack,16),this.settings.target&&this.popover&&!this._group&&group(this,!0)}},{key:"track",value:function(){return this._track_timer||(this._track_timer=setTimeout(this._doTrack,16)),this}},{key:"untrack",value:function(){return this._track_timer&&(clearTimeout(this._track_timer),this._track_timer=!1),this}},{key:"refresh",value:function(){return this.setState({}),this}},{key:"hide",value:function(e){var t=this,n=this.settings,r=n.showing;if(r&&r&e){n.showing-=e;var o=this.popoverEl,i=o.style;this._show_timer&&clearTimeout(this._show_timer),this._show_timer=setTimeout(function(){n.showing||(!o.$listener&&o.addEventListener("transitionend",o.$listener=function(){o.removeEventListener("transitionend",o.$listener),o.$listener=!1,!n.showing&&(o.style.visibility="hidden")}),t._show_timer=void 0,i.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",n.region===RIGHT?i.transform="translateX(30px)translateY(0px)":n.region===LEFT?i.transform="translateX(-30px)translateY(0px)":n.region===TOP?i.transform="translateX(0px)translateY(-30px)":i.transform="translateX(0px)translateY(30px)",i.pointerEvents="none",i.opacity=0,t.props.onHide&&t.props.onHide())},n.hideDelay)}}},{key:"show",value:function(e){var t=this,n=this.settings,r=this.popoverEl,o=r.style,i=!0,s=n.showing;n.showing|=e,s||(this._show_timer&&(clearTimeout(this._show_timer),this._show_timer=void 0,i=!1),r.$listener&&r.removeEventListener("transitionend",r.$listener),r.$listener=!1,i?this._show_timer=setTimeout(function(){n.showing&&(t.props.onShow&&t.props.onShow(),t._show_timer=void 0,o.transition=null,n.region===RIGHT?o.transfrom="translateX(30px)translateY(0px)":n.region===LEFT?o.transform="translateX(-30px)translateY(0px)":n.region===TOP?o.transform="translateX(0px)translateY(-30px)":o.transform="translateX(0px)translateY(30px)",o.pointerEvents="all",t._show_timer=setTimeout(function(){t._show_timer=void 0,o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"},n.showDelay))}):(o.transition="all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms",o.visibility=null,o.opacity=1,o.transform="translateX(0px)translateY(0px)"))}},{key:"_upwardSelector",value:function(e,t){var n=t.target,r=n.ownerDocument;if(!e)return e;if("string"==typeof e){if("body"===e)return r.body;if("parent"===e)return n&&n.parentNode;if("window"===e)return n&&n.ownerDocument.defaultView;for(;n;){if(n.matches&&n.matches(e))return n;n=n.parentNode}return r.body}return(n=ReactDOM.findDOMNode(e))?n:e}},{key:"_updatePositions",value:function(){if(this.settings.target){var e,t,n,r,o,i,s,a,u=this.popover.refs.overflow,l=u.style,p=this.popover.refs.wrapper.style,c=this.popover.refs.arrow,f=c.style,h=this.popover.refs.content.style,d=this.settings,y=this.popover.refs.title,m=y&&y.getBoundingClientRect(),v=this.pack.targetRect,g=this.pack.parentRect,_=m&&m.width||0,w=m&&m.height||0,b=v.top,T=v.width,E=T/2,O=v.height,S=O/2,x=v.left,k=t=g.top,R=n=g.left,C=0|n,N=0|t,M=d.region,L=d.leftSpace,P=d.topSpace,W=0|d.arrowSize,H=d.arrowSize1_2,z=d.arrowSize3_4,j=d.arrowSize2_1,D=d.arrowSize3_2,I=d.position.left,A=d.position.top;l.paddingTop=w+"px",l.maxHeight=Math.max(Math.round(this.settings.position.maxHeight-w),0)+"px",e=u.getBoundingClientRect(),r=Math.max(e.width,_),o=e.height,this.settings.target&&(M===TOP||M===BOTTOM?(s=5,i=R+g.width-5,n=x+E-r/2,n(a=i-r)&&(n=a),(a=x+W)>i&&(n=a-r),C+=L+E-W,C=Math.max(Math.min(C,n+r-j),n)+H,I=n,M===TOP?(A=b-o-z-9,N=b-z-9-H):N=A-H):M!==LEFT&&M!==RIGHT||(t+=P+O-S-o/2,i=k+g.height-5,s=5,t(a=i-o)&&(t=a),(a=b+W)>i&&(t=a-o),N+=P+S-W,N=Math.max(Math.min(N,t+o-j),t)+H,A=t,M===LEFT?(I=x-r-z-6,C=I+r-H-1):(I=x+T+z,C=I-H+1)),h.width=p.width=(0|r)+"px",isSafari&&this._unsafe&&this.popoverEl&&(this.popoverEl.style.transition=f.transition=h.transition=p.transition=group_timer?"none":null),h.width=p.width=(0|r)+"px",f.top=(0|N)+"px",f.left=(0|C)+"px",p.top=h.top=(0|A)+"px",p.left=h.left=(0|I)+"px",p.height=(0|o)+"px",this.settings.showing&&this.popoverEl.style.visiblity&&(this.popoverEl.style.visiblity=null))}}},{key:"render",value:function(){var e=this.props.children;return"string"==typeof e&&(e=React.createElement("span",null,e)),e||null}}]),t}(React.Component),module.exports.propTypes={children:propTypes.any,constrainTo:propTypes.any,show:propTypes.bool,showDelay:propTypes.number,hideDelay:propTypes.number,track:propTypes.bool,constrainHeight:propTypes.bool,constrainWidth:propTypes.bool,arrowSize:propTypes.number,region:propTypes.oneOf(["left","right","top","bottom",null,!1,void 0]),bindScroll:propTypes.oneOfType([propTypes.bool,propTypes.string]),bindWindowResize:propTypes.bool,arrowStyle:propTypes.object,backgroundStyle:propTypes.object,wrapperStyle:propTypes.object,titleStyle:propTypes.object,className:propTypes.string,title:propTypes.any,showOnMouseEnter:propTypes.bool,hideOnMouseLeave:propTypes.bool,toggleOnClick:propTypes.bool,persistOverContent:propTypes.bool,onHide:propTypes.func,onShow:propTypes.func},module.exports.defaultProps={constrainTo:"parent",showDelay:300,hideDelay:320,track:!1,constrainHeight:!0,constrainWidth:!0,arrowSize:15,bindScroll:!1,bindWindowResize:!1,className:"",title:"",showOnMouseEnter:!0,hideOnMouseLeave:!0,toggleOnClick:!1,persistOverContent:!1}},function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE_9__},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(13)()}).call(t,n(0))},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),s=n(3),a=n(12);e.exports=function(e,n){function u(e){var t=e&&(S&&e[S]||e[x]);if("function"==typeof t)return t}function l(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function p(e){this.message=e,this.stack=""}function c(e){function r(r,l,c,f,h,d,y){if(f=f||k,d=d||c,y!==s)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var m=f+":"+c;!a[m]&&u<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,f),a[m]=!0,u++)}return null==l[c]?r?new p(null===l[c]?"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `null`.":"The "+h+" `"+d+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(l,c,f,h,d)}if("production"!==t.env.NODE_ENV)var a={},u=0;var l=r.bind(null,!1);return l.isRequired=r.bind(null,!0),l}function f(e){function t(t,n,r,o,i,s){var a=t[n];if(b(a)!==e)return new p("Invalid "+o+" `"+i+"` of type `"+T(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return c(t)}function h(e){function t(t,n,r,o,i){if("function"!=typeof e)return new p("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new p("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+r+"`, expected an array.")}for(var u=0;u 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /libs/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./poppy.js'); 2 | module.exports.Container = require('./container.js'); 3 | -------------------------------------------------------------------------------- /libs/poppy.css: -------------------------------------------------------------------------------- 1 | .poppy { 2 | visiblity:hidden; 3 | display:inline-block; 4 | opacity:0; 5 | position:absolute; 6 | z-index:0; 7 | backface-visibility:hidden; 8 | -webkit-backface-visibility:hidden; 9 | } 10 | .poppy-background { 11 | opacity:0.925; 12 | z-index:0; 13 | backface-visibility:hidden; 14 | background:#000; 15 | transform:translateZ(0); 16 | } 17 | .poppy-arrow { 18 | position:absolute; 19 | z-index:-1; 20 | background:inherit; 21 | transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; 22 | transform:rotateZ(45deg); 23 | } 24 | .poppy-background-overlay { 25 | z-index:0; 26 | background:inherit; 27 | border-radius:4px; 28 | border-top-width:0; 29 | position: absolute; 30 | top: 0px; 31 | left: 0px; 32 | width: 100%; 33 | transform: translateZ(0); 34 | height: 100%; 35 | transition : all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; 36 | } 37 | .poppy-content { 38 | display:inline-block; 39 | z-index: 1; 40 | position: relative; 41 | /*pointer-events:all;*/ 42 | transition:none; 43 | padding-left: 10px; 44 | width: auto; 45 | padding-right: 10px; 46 | padding-top: 10px; 47 | padding-bottom: 5px; 48 | color: #fff; 49 | font-size: 12px; 50 | box-sizing: border-box; 51 | } 52 | .poppy-overflow { 53 | position:relative; 54 | display: inline-block; 55 | z-index:0; 56 | padding:0; 57 | transition:none; 58 | } 59 | .poppy-content-wrapper { 60 | position:absolute; 61 | /*pointer-events:all;*/ 62 | width:auto; 63 | display:inline-block; 64 | transition:all 450ms cubic-bezier(0.23,1,0.32,1) 0ms; 65 | overflow:hidden; 66 | z-index:1; 67 | } 68 | .poppy-title-wrapper { 69 | z-index:1; 70 | transition:none; 71 | position:absolute; 72 | display:inline-block; 73 | width: 100%; 74 | text-align: center; 75 | transition: none; 76 | color: #fff; 77 | } 78 | .poppy-title { 79 | display: inline-block; 80 | white-space:nowrap; 81 | padding: 10px; 82 | } 83 | -------------------------------------------------------------------------------- /libs/poppy.js: -------------------------------------------------------------------------------- 1 | 2 | var group_timer, 3 | groups=[], 4 | React = require('react'), 5 | ReactDOM = require('react-dom'), 6 | isSafari = navigator.userAgent.toLowerCase(), 7 | propTypes = require('prop-types'); 8 | 9 | isSafari = (isSafari.indexOf('safari') >= 0) && (isSafari.indexOf('chrome') < 0); 10 | 11 | function group (item,unsafe) { 12 | if (!group_timer) { 13 | group_timer = requestAnimationFrame(do_group,16); 14 | } 15 | item._group = 1; 16 | unsafe && (item._unsafe=1); 17 | groups.push(item); 18 | } 19 | function ungroup (item) { 20 | var index = groups.indexOf(item); 21 | groups[index] = 0; 22 | } 23 | function do_group () { 24 | var i,ln,item, 25 | pack, 26 | settings; 27 | for (i=0,ln=groups.length;i {this.__onExit(e)}; 161 | this._onEnter = (e) => {this.__onEnter(e)}; 162 | } 163 | shouldComponentUpdate (props,state) { 164 | var last = this.state || {}, 165 | position2 = state.position || {}, 166 | result = (this.minWidth !== position2.minWidth || this.minHeight !== position2.minHeight || this.maxWidth !== position2.maxWidth || last.content !== state.content || last.title !== state.title || this.maxHeight !== position2.maxHeight); 167 | return result; 168 | } 169 | render () { 170 | var state = this.state; 171 | if (!state) { 172 | return null; 173 | } 174 | var title = state.title, 175 | position = state.position, 176 | maxWidth = position.maxWidth, 177 | maxHeight = position.maxHeight, 178 | minWidth = position.minWidth, 179 | minHeight = position.minHeight, 180 | content = state.content, 181 | overflowStyle = this.overflowStyle, 182 | wrapperStyle = this.wrapperStyle, 183 | sWrap = state.wrapperStyle || {}, 184 | backgroundStyle = state.backgroundStyle || {}; 185 | 186 | 187 | overflowStyle.overflow = content ? 'auto' : null; 188 | this.maxHeight = overflowStyle.maxHeight = wrapperStyle.maxHeight = maxHeight; 189 | this.maxWidth = overflowStyle.maxWidth = wrapperStyle.maxWidth = maxWidth; 190 | this.minHeight = backgroundStyle.minHeight = sWrap.minHeight = minHeight; 191 | this.minWidth = backgroundStyle.minWidth = sWrap.minWidth = minWidth; 192 | 193 | 194 | 195 | 196 | return ( 197 | 198 |
199 |
200 |
201 |
202 | { title ?
{state.title}
203 | : null 204 | } 205 |
206 | { 207 | content ?
{content||''}
208 | : 209 | } 210 |
211 |
212 |
); 213 | } 214 | __onEnter () { 215 | this.state.onEnterContent && this.state.onEnterContent(SHOWING.CONTENT); 216 | } 217 | __onExit () { 218 | this.state.onLeaveContent && this.state.onLeaveContent(SHOWING.CONTENT); 219 | } 220 | }, 221 | overlay_template = document.createElement('span'); 222 | overlay_template.innerHTML = '
' 223 | overlay_template = overlay_template.lastChild; 224 | Popover.prototype.overflowStyle = {}; 225 | Popover.prototype.wrapperStyle = {}, 226 | 227 | 228 | module.exports = class Poppy extends React.Component { 229 | constructor () { 230 | super(); 231 | var state = assign_defaults(this.props); 232 | this._lastTargetRect = {left:0,top:0,width:0,height:0}; 233 | this.pack={}; 234 | this._transitioning = true; 235 | 236 | this._doTrack = (e) => this.__doTrack(e); 237 | this._onClick = (e) => this.__onClick(e); 238 | this._onResize = (e) => this.__onResize(e); 239 | this._onScroll = (e) => this.__onScroll(e); 240 | this._onMouseEnter = (e) => this.__onMouseEnter(e); 241 | this._onMouseLeave = (e) => this.__onMouseLeave(e); 242 | 243 | 244 | this.settings = { 245 | arrowStyle:{ 246 | width:defaults.arrowSize, 247 | height:defaults.arrowSize 248 | }, 249 | constrainTo : defaults.constrainTo, 250 | showing:0, 251 | showDelay:defaults.showDelay, 252 | hideDelay:defaults.hideDelay, 253 | //arrowSize:defaults.arrowSize, 254 | track:defaults.track, 255 | constrainHeight:defaults.constrainHeight, 256 | constrainWidth:defaults.constrainWidth, 257 | className : defaults.className, 258 | 259 | //showOnMouseEnter : defaults.showOnMouseEnter, 260 | //hideOnMouseLeave : defaults.hideOnMouseLeave, 261 | //toggleOnClick : defaults.toggleOnClick, 262 | //bindWindowResize : defaults.bindWindowResize, 263 | //persistOverContent : defaults.persistOverContent, 264 | //bindScrollContainer : defaults.bindScrollContainer 265 | 266 | title:'' 267 | }; 268 | this.componentWillUpdate(this.props,state); 269 | this.state = state; 270 | } 271 | componentDidMount () { 272 | var 273 | me = this, 274 | target = ReactDOM.findDOMNode(this); 275 | 276 | 277 | me.setState({ 278 | 'target' : target 279 | }); 280 | this._mount_timer = setTimeout(function () { 281 | me._updateSync(me.props,me.state); 282 | }); 283 | } 284 | componentWillUnmount () { 285 | var target = this.state.target, 286 | doc = target.ownerDocument, 287 | window = doc.defaultView; 288 | 289 | if (this.settings && (target = this.settings.target)) { 290 | target.removeEventListener('mouseenter',this._onMouseEnter); 291 | target.removeEventListener('mouseleave',this._onMouseLeave); 292 | target.removeEventListener('click',this._onClick); 293 | } 294 | this.untrack(); 295 | this._resize_timer && clearTimeout(this._resize_timer); 296 | this._show_timer && clearTimeout(this._show_timer); 297 | this._mount_timer && clearTimeout(this._mount_timer); 298 | //this._render_timer && clearTimeout(this._render_timer); 299 | this.overlay && this.popoverEl.parentNode === this.overlay && this.overlay.removeChild(this.popoverEl) 300 | this._init_timer && clearTimeout(this._init_timer); 301 | 302 | this.settings.bindWindowResize && window.removeEventListener('resize',this._onResize); 303 | this._boundScroll && this._boundScroll.removeEventListener('scroll',this._onScroll); 304 | } 305 | componentWillUpdate (props,state) { 306 | this._updateSync(props,state); 307 | !this._group && group(this); 308 | } 309 | _updateSync (props={},state) { 310 | state = state || this.state; 311 | var 312 | settings = this.settings, 313 | bindWindowResize = props.bindWindowResize || false, 314 | target = state && state.target , 315 | ltarget = settings.target, 316 | track = props.track || false, 317 | view = target && target.ownerDocument.defaultView, 318 | bindScroll = props.bindScroll === true ? 'window' : props.bindScroll, 319 | boundScroll = this._boundScroll, 320 | scroller = settings.target ? this._upwardSelector(bindScroll,settings) : false; 321 | 322 | 323 | if (bindWindowResize !== settings.bindWindowResize) { 324 | if (bindWindowResize) { 325 | view && (view.addEventListener('resize',this._onResize),settings.bindWindowResize = true); 326 | } else { 327 | view && view.removeEventListener('resize',this._onResize); 328 | settings.bindWindowResize = false; 329 | } 330 | } 331 | 332 | settings.titleStyle = props.titleStyle || defaults.titleStyle; 333 | settings.wrapperStyle = props.wrapperStyle || defaults.wrapperStyle; 334 | 335 | if (scroller !== boundScroll) { 336 | if (boundScroll) { 337 | boundScroll.removeEventListener('scroll',this._onScroll); 338 | this._boundScroll = false; 339 | } 340 | if (scroller) { 341 | scroller.addEventListener('scroll',this._onScroll,true); 342 | this._boundScroll = scroller; 343 | } 344 | } 345 | 346 | if (track !== settings.track) { 347 | if (track) { 348 | settings.track = true; 349 | this.track(); 350 | } else { 351 | settings.track = false; 352 | this.untrack(); 353 | } 354 | } 355 | 356 | if (target && ltarget !== target) { 357 | target.addEventListener('mouseenter',this._onMouseEnter); 358 | target.addEventListener('mouseleave',this._onMouseLeave); 359 | target.addEventListener('click',this._onClick); 360 | settings.target = target; 361 | if (ltarget) { 362 | ltarget.removeEventListener('mouseenter',this._onMouseEnter); 363 | ltarget.removeEventListener('mouseleave',this._onMouseLeave); 364 | ltarget.removeEventListener('click',this._onClick); 365 | } 366 | } 367 | 368 | if (props.persistOverContent) { 369 | settings.persistOverContent = true; 370 | settings.onEnterContent = (e)=>this.show(e); 371 | settings.onLeaveContent = (e)=>this.hide(e); 372 | } else { 373 | settings.persistOverContent = false; 374 | settings.onEnterContent = false; 375 | settings.onLeaveContent = false; 376 | } 377 | 378 | settings.toggleOnClick = props.toggleOnClick !== undefined ? props.toggleOnClick : defaults.toggleOnClick; 379 | settings.showOnMouseEnter = props.showOnMouseEnter !== undefined ? props.showOnMouseEnter : defaults.showOnMouseEnter; 380 | settings.hideOnMouseLeave = props.hideOnMouseLeave !== undefined ? props.hideOnMouseLeave : defaults.hideOnMouseLeave; 381 | settings.constrainHeight = props.constrainHeight !== undefined ? props.constrainHeight : defaults.constrainHeight; 382 | settings.constrainWidth = props.constrainWidth !== undefined ? props.constrainWidth : defaults.constrainWidth; 383 | 384 | } 385 | _updateAsync () { 386 | 387 | if (!this.settings.target) { 388 | return; 389 | } 390 | 391 | 392 | var me = this, 393 | props = this.props, 394 | show = props.show, 395 | settings = this.settings, 396 | showing = settings.showing & SHOWING.PROPERTY, 397 | doc = settings.target.ownerDocument, 398 | body = doc.body, 399 | overlay = this._upwardSelector(".poppy-container",settings), 400 | popover = this.popover, 401 | arrowSize = props.arrowSize !== undefined ? props.arrowSize : defaults.arrowSize, 402 | arrowStyle = settings.mergedArrowStyle= Object.assign({},settings.arrowStyle,props.arrowStyle), 403 | region = props.region; 404 | 405 | 406 | 407 | 408 | if (region && region !== settings.last_prop_region) { 409 | if (region === 'top') { 410 | settings.region = TOP; 411 | } else if (region === 'left') { 412 | settings.region = LEFT; 413 | } else if (region === 'right') { 414 | settings.region = RIGHT; 415 | } else if (region === 'bottom') { 416 | settings.region = BOTTOM; 417 | } 418 | } else if (!region) { 419 | settings.region = defaults.region; 420 | } 421 | 422 | settings.backgroundStyle = props.backgroundStyle; 423 | 424 | 425 | settings.last_prop_region = region; 426 | settings.title = props.title || defaults.title; 427 | settings.content = props.content || defaults.content; 428 | settings.className = props.className || defaults.className; 429 | 430 | settings.arrowSize = arrowSize; 431 | settings.arrowSize3_4 = arrowSize * .75; 432 | settings.arrowSize1_2 = arrowSize * .5; 433 | settings.arrowSize2_1 = arrowSize * 2; 434 | settings.arrowSize3_2 = arrowSize * 1.5; 435 | arrowStyle.height = arrowStyle.width = arrowSize; 436 | 437 | 438 | this._adjustPosition(this.settings); 439 | 440 | 441 | if (overlay === body) { 442 | overlay = body.querySelector('.poppy-container'); 443 | } 444 | if (!overlay) { 445 | body.appendChild(overlay = this.overlay = overlay_template.cloneNode(true)); 446 | } else if (!this.overlay) { 447 | this.overlay = overlay; 448 | } 449 | 450 | if (!popover) { 451 | var test = document.createElement('div'); 452 | popover = this.popover = ReactDOM.render(,test); 453 | overlay.appendChild(test.lastChild); 454 | } else if (this.overlay.ownerDocument !== doc && this.popoverEl) { 455 | overlay.appendChild(this.popoverEl); 456 | this.overlay = overlay; 457 | } 458 | 459 | 460 | popover.setState(settings); 461 | if (!this.popoverEl) { 462 | this.popoverEl = ReactDOM.findDOMNode(popover); 463 | } 464 | 465 | 466 | 467 | //!this._init_timer && requestAnimationFrame(function () { 468 | if (showing && !show) { 469 | me.hide(SHOWING.PROPERTY); 470 | } else if (!showing && show) { 471 | me.show(SHOWING.PROPERTY); 472 | } 473 | 474 | //me._init_timer = false; 475 | me._updatePositions(); 476 | 477 | //}); 478 | } 479 | __onResize () { 480 | var me = this; 481 | if (this._resize_timer) { 482 | clearTimeout(this._resize_timer); 483 | } 484 | this._resize_timer = setTimeout(function () { 485 | me._resize_timer = undefined; 486 | me.setState({}) 487 | },60); 488 | } 489 | __onMouseEnter () { 490 | if (this.settings.showOnMouseEnter) { 491 | this.show(SHOWING.MOUSEOVER); 492 | } 493 | } 494 | __onMouseLeave () { 495 | if (this.settings.hideOnMouseLeave) { 496 | this.hide(SHOWING.MOUSEOVER); 497 | } 498 | } 499 | __onClick () { 500 | if (this.settings.toggleOnClick) { 501 | if (this.settings.showing & SHOWING.CLICK) { 502 | this.hide(SHOWING.CLICK); 503 | } else { 504 | this.show(SHOWING.CLICK); 505 | } 506 | } 507 | } 508 | _adjustPosition (settings) { 509 | var rect = this.pack.targetRect,//settings.target.getBoundingClientRect(), 510 | parentRect = this.pack.parentRect,//settings.constrainTarget.getBoundingClientRect(), 511 | parentRatio = parentRect.width/parentRect.height, 512 | region = settings.region, 513 | _topSpace,_leftSpace,_rightSpace,_bottomSpace, 514 | leftSpace = settings.leftSpace = rect.left - parentRect.left, 515 | rightSpace = settings.rightSpace = parentRect.left + parentRect.width - (rect.left + rect.width), 516 | topSpace = settings.topSpace = rect.top - parentRect.top, 517 | bottomSpace = settings.bottomSpace = parentRect.top + parentRect.height - (rect.top + rect.height), 518 | arrowSize = settings.arrowSize, 519 | position = settings.position, 520 | half_size = settings.arrowSize3_4, 521 | constrainHeight = settings.constrainHeight, 522 | constrainWidth = settings.constrainWidth, 523 | double_size = arrowSize * 2; 524 | 525 | if (!position) { 526 | position = settings.position = {}; 527 | } 528 | 529 | if (!region) { 530 | _leftSpace =leftSpace*.75; 531 | _rightSpace =rightSpace*.75; 532 | _topSpace = topSpace*parentRatio; 533 | _bottomSpace = bottomSpace*parentRatio; 534 | if (_leftSpace > _bottomSpace && _leftSpace > _topSpace && _leftSpace >= _rightSpace) { 535 | region = settings.region = LEFT; 536 | } else if (_rightSpace > _bottomSpace && _rightSpace > _topSpace) { 537 | region = settings.region = RIGHT; 538 | } else if (_topSpace > _bottomSpace) { 539 | region = settings.region = TOP; 540 | } else { 541 | region = settings.region = BOTTOM; 542 | } 543 | } 544 | 545 | if (region === LEFT) { 546 | //position.minWidth = 0; 547 | position.minWidth = arrowSize; 548 | position.minHeight = double_size; 549 | position.top = position.left = 0; 550 | constrainWidth && (position.maxWidth = Math.max(leftSpace - half_size-25,double_size)); 551 | constrainHeight && (position.maxHeight = Math.max(topSpace+bottomSpace+rect.height-30,5)); 552 | } else if (region === RIGHT) { 553 | //position.minWidth = 0; 554 | position.minWidth = arrowSize; 555 | position.top = 0; 556 | position.minHeight = double_size; 557 | position.left = rect.left + rect.width + half_size; 558 | constrainWidth && (position.maxWidth = Math.max(rightSpace - half_size-25,double_size)); 559 | constrainHeight && (position.maxHeight = Math.max(topSpace+bottomSpace+rect.height-30,5)); 560 | } else if (region === BOTTOM) { 561 | //position.minHeight = 'auto'; 562 | position.minHeight = arrowSize; 563 | position.top = rect.top + rect.height + half_size; 564 | position.left = 0; 565 | position.minWidth = double_size; 566 | constrainHeight && (position.maxHeight = Math.max(bottomSpace - half_size-5,25)); 567 | constrainWidth && (position.maxWidth = Math.max(leftSpace+rightSpace+rect.width-30,25)); 568 | } else { 569 | //position.minHeight = 'auto'; 570 | position.minHeight = arrowSize; 571 | position.top = position.left = 0; 572 | position.minWidth = double_size; 573 | constrainHeight && (position.maxHeight = Math.max(topSpace - half_size+2,25)); 574 | constrainWidth && (position.maxWidth = Math.max(leftSpace+rightSpace+rect.width-30,25)); 575 | } 576 | 577 | } 578 | __onScroll () { 579 | !this._group && group(this,true); 580 | } 581 | __doTrack () { 582 | this._track_timer = setTimeout(this._doTrack,16); 583 | 584 | var settings = this.settings, 585 | target = settings.target; 586 | 587 | if (!target || !this.popover) { 588 | return; 589 | } 590 | 591 | !this._group && group(this,true); 592 | } 593 | track () { 594 | if (!this._track_timer) { 595 | this._track_timer = setTimeout(this._doTrack,16); 596 | } 597 | return this; 598 | } 599 | untrack () { 600 | if (this._track_timer) { 601 | clearTimeout(this._track_timer); 602 | this._track_timer = false; 603 | } 604 | return this; 605 | } 606 | refresh () { 607 | this.setState({}); 608 | return this; 609 | } 610 | hide (trigger) { 611 | var me = this, 612 | settings = this.settings, 613 | showing = settings.showing; 614 | if (!showing) { 615 | return; 616 | } 617 | 618 | if (showing & trigger) { 619 | settings.showing -= trigger; 620 | } else { 621 | return; 622 | } 623 | 624 | var node = this.popoverEl, 625 | style = node.style; 626 | this._show_timer && clearTimeout(this._show_timer); 627 | this._show_timer = setTimeout(function () { 628 | if (settings.showing) { 629 | return; 630 | } 631 | !node.$listener && node.addEventListener('transitionend',node.$listener = function () { 632 | node.removeEventListener('transitionend',node.$listener); 633 | node.$listener = false; 634 | !settings.showing && (node.style.visibility = 'hidden'); 635 | }); 636 | me._show_timer = undefined; 637 | style.transition = 'all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms'; 638 | if (settings.region === RIGHT) { 639 | style.transform = 'translateX(30px)translateY(0px)'; 640 | } else if (settings.region === LEFT) { 641 | style.transform = 'translateX(-30px)translateY(0px)'; 642 | } else if (settings.region === TOP) { 643 | style.transform='translateX(0px)translateY(-30px)'; 644 | } else { 645 | style.transform='translateX(0px)translateY(30px)'; 646 | } 647 | style.pointerEvents = 'none'; 648 | style.opacity = 0 649 | me.props.onHide && me.props.onHide(); 650 | },settings.hideDelay); 651 | } 652 | show (trigger) { 653 | var 654 | me = this, 655 | settings = this.settings, 656 | node = this.popoverEl, 657 | style = node.style, 658 | reset = true, 659 | was_showing = settings.showing; 660 | 661 | 662 | settings.showing |= trigger; 663 | if (was_showing) { 664 | return; 665 | } else if (this._show_timer) { 666 | clearTimeout(this._show_timer); 667 | this._show_timer = undefined; 668 | reset = false; 669 | } 670 | node.$listener && node.removeEventListener('transitionend',node.$listener); 671 | node.$listener = false; 672 | 673 | if (reset) { 674 | this._show_timer = setTimeout(function () { 675 | if (!settings.showing) { 676 | return; 677 | } 678 | me.props.onShow && me.props.onShow(); 679 | me._show_timer = undefined; 680 | style.transition = null; 681 | if (settings.region === RIGHT) { 682 | style.transfrom = 'translateX(30px)translateY(0px)'; 683 | } else if (settings.region === LEFT) { 684 | style.transform = 'translateX(-30px)translateY(0px)'; 685 | } else if (settings.region === TOP) { 686 | style.transform = 'translateX(0px)translateY(-30px)'; 687 | } else { 688 | style.transform = 'translateX(0px)translateY(30px)'; 689 | } 690 | style.pointerEvents = 'all' 691 | me._show_timer = setTimeout(function () { 692 | me._show_timer = undefined; 693 | style.transition = 'all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms'; 694 | style.visibility = null; 695 | style.opacity = 1; 696 | style.transform = 'translateX(0px)translateY(0px)'; 697 | },settings.showDelay); 698 | }); 699 | } else { 700 | style.transition = 'all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms'; 701 | style.visibility = null; 702 | style.opacity = 1; 703 | style.transform = 'translateX(0px)translateY(0px)'; 704 | } 705 | } 706 | _upwardSelector (selector,settings) { 707 | var target = settings.target, 708 | document = target.ownerDocument; 709 | 710 | if (!selector) { 711 | return selector; 712 | } else if (typeof selector === 'string') { 713 | if (selector === 'body') { 714 | return document.body; 715 | } else if (selector === 'parent') { 716 | return target && target.parentNode; 717 | } else if (selector === 'window') { 718 | return target && target.ownerDocument.defaultView; 719 | } else { 720 | while (target) { 721 | if (target.matches && target.matches(selector)) { 722 | return target; 723 | } 724 | target = target.parentNode; 725 | } 726 | return document.body; 727 | } 728 | } else if (target = ReactDOM.findDOMNode(selector)) { 729 | return target; 730 | } 731 | return selector; 732 | } 733 | _updatePositions () { 734 | var target = this.settings.target; 735 | if (!target) { 736 | return; 737 | } 738 | var 739 | overflow = this.popover.refs.overflow, 740 | overflowStyle = overflow.style, 741 | overflowRect, 742 | wrapperStyle = this.popover.refs.wrapper.style, 743 | arrow = this.popover.refs.arrow, 744 | arrowelStyle = arrow.style, 745 | contentStyle = this.popover.refs.content.style, 746 | settings = this.settings, 747 | title = this.popover.refs.title, 748 | titleRect = title && title.getBoundingClientRect(), 749 | targetRect = this.pack.targetRect,//target.getBoundingClientRect(), 750 | parentRect = this.pack.parentRect,//settings.constrainTarget.getBoundingClientRect(), 751 | titleWidth = titleRect && titleRect.width || 0, 752 | titleHeight = titleRect && titleRect.height || 0, 753 | targetTop = targetRect.top, 754 | targetWidth = targetRect.width, 755 | halfTargetWidth = targetWidth / 2, 756 | targetHeight = targetRect.height, 757 | halfTargetHeight = targetHeight / 2, 758 | targetLeft = targetRect.left, 759 | offsetTop, 760 | offsetLeft, 761 | parentTop = offsetTop = parentRect.top, 762 | parentLeft = offsetLeft = parentRect.left, 763 | arrowLeft = offsetLeft|0, 764 | arrowTop = offsetTop|0, 765 | width, 766 | height, 767 | region = settings.region, 768 | spaceLeft = settings.leftSpace, 769 | spaceTop = settings.topSpace, 770 | arrowSize = settings.arrowSize|0, 771 | size1_2 = settings.arrowSize1_2, 772 | size3_4 = settings.arrowSize3_4, 773 | size2_1 = settings.arrowSize2_1, 774 | size3_2 = settings.arrowSize3_2, 775 | upperBounds, 776 | lowerBounds, 777 | x = settings.position.left, 778 | y = settings.position.top, 779 | c; 780 | 781 | 782 | 783 | overflowStyle.paddingTop = titleHeight + 'px'; 784 | overflowStyle.maxHeight = Math.max(Math.round(this.settings.position.maxHeight - titleHeight),0) + 'px'; 785 | 786 | overflowRect = overflow.getBoundingClientRect(); 787 | width = Math.max(overflowRect.width,titleWidth); 788 | height = overflowRect.height; 789 | 790 | if (!this.settings.target) { 791 | return; 792 | } 793 | if (region === TOP || region === BOTTOM) { 794 | lowerBounds = 5; 795 | upperBounds = parentLeft + parentRect.width - 5; 796 | offsetLeft = targetLeft + halfTargetWidth - width/2; 797 | if (offsetLeft < lowerBounds) { 798 | offsetLeft = lowerBounds; 799 | } 800 | if ((c=targetLeft + targetWidth-size3_2) < lowerBounds) { 801 | offsetLeft = c; 802 | } 803 | if (offsetLeft > (c=upperBounds - width)) { 804 | offsetLeft = c; 805 | } 806 | if ((c=targetLeft + arrowSize) > upperBounds) { 807 | offsetLeft = c - width; 808 | } 809 | 810 | arrowLeft += spaceLeft + halfTargetWidth - arrowSize; 811 | arrowLeft = Math.max(Math.min(arrowLeft,offsetLeft+width-size2_1),offsetLeft) + size1_2; 812 | x = offsetLeft; 813 | if (region === TOP) { 814 | y = (targetTop - height - size3_4 -9); 815 | //y = (targetTop - height - size3_4 -9); 816 | 817 | arrowTop = targetTop- size3_4-9-size1_2;// size3_4 - size1_2; 818 | } else { 819 | arrowTop = y - size1_2; 820 | } 821 | 822 | } else if (region === LEFT || region === RIGHT) { 823 | offsetTop += spaceTop + targetHeight - halfTargetHeight - height / 2; 824 | upperBounds = parentTop + parentRect.height - 5; 825 | lowerBounds = 5; 826 | 827 | if (offsetTop < lowerBounds) { 828 | offsetTop = lowerBounds; 829 | } 830 | if ((c=targetTop + targetHeight - size3_2) < lowerBounds ) { 831 | offsetTop = c; 832 | } 833 | if (offsetTop > (c=upperBounds-height)) { 834 | offsetTop = c; 835 | } 836 | if ((c=targetTop +arrowSize) > upperBounds) { 837 | offsetTop = c - height; 838 | } 839 | arrowTop += spaceTop + halfTargetHeight - arrowSize; 840 | arrowTop = Math.max(Math.min(arrowTop,offsetTop + height - size2_1),offsetTop) + size1_2; 841 | y= offsetTop; 842 | if (region === LEFT) { 843 | x = (targetLeft - width - size3_4 - 6); 844 | arrowLeft = x + width - size1_2 -1; 845 | } else { 846 | x = (targetLeft + targetWidth+ size3_4); 847 | arrowLeft = x - size1_2 + 1; 848 | } 849 | } 850 | 851 | contentStyle.width = wrapperStyle.width = (width|0) + 'px'; 852 | //arrowelStyle.top = (arrowTop|0) + 'px'; 853 | //arrowelStyle.left = (arrowLeft|0) + 'px'; 854 | //wrapperStyle.top = contentStyle.top = (y|0) + 'px'; 855 | //wrapperStyle.left = contentStyle.left = (x|0) + 'px' 856 | 857 | 858 | if (isSafari && (this._unsafe) && this.popoverEl) { 859 | if (group_timer) { 860 | this.popoverEl.style.transition = 861 | arrowelStyle.transition = 862 | contentStyle.transition = 863 | wrapperStyle.transition = 'none' 864 | 865 | 866 | } else { 867 | this.popoverEl.style.transition = 868 | arrowelStyle.transition = 869 | contentStyle.transition = 870 | wrapperStyle.transition = null 871 | 872 | } 873 | } 874 | 875 | //var me = this; 876 | 877 | contentStyle.width = wrapperStyle.width = (width|0) + 'px'; 878 | arrowelStyle.top = (arrowTop|0) + 'px'; 879 | arrowelStyle.left = (arrowLeft|0) + 'px'; 880 | wrapperStyle.top = contentStyle.top = (y|0) + 'px'; 881 | wrapperStyle.left = contentStyle.left = (x|0) + 'px' 882 | wrapperStyle.height = (height|0) + 'px'; 883 | 884 | 885 | 886 | this.settings.showing && this.popoverEl.style.visiblity && (this.popoverEl.style.visiblity = null); 887 | 888 | } 889 | render () { 890 | var children = this.props.children; 891 | if (typeof children === 'string') { 892 | children = {children}; 893 | } 894 | return children || null; 895 | } 896 | }; 897 | module.exports.propTypes = { 898 | children : propTypes.any, 899 | constrainTo : propTypes.any, 900 | show : propTypes.bool, 901 | showDelay : propTypes.number, 902 | hideDelay : propTypes.number, 903 | track : propTypes.bool, 904 | constrainHeight : propTypes.bool, 905 | constrainWidth : propTypes.bool, 906 | arrowSize : propTypes.number, 907 | region : propTypes.oneOf(['left','right','top','bottom',null,false,undefined]), 908 | bindScroll : propTypes.oneOfType([propTypes.bool,propTypes.string]), 909 | bindWindowResize : propTypes.bool, 910 | arrowStyle : propTypes.object, 911 | backgroundStyle : propTypes.object, 912 | wrapperStyle : propTypes.object, 913 | titleStyle : propTypes.object, 914 | className : propTypes.string, 915 | title : propTypes.any, 916 | showOnMouseEnter : propTypes.bool, 917 | hideOnMouseLeave : propTypes.bool, 918 | toggleOnClick : propTypes.bool, 919 | persistOverContent : propTypes.bool, 920 | onHide : propTypes.func, 921 | onShow : propTypes.func 922 | }; 923 | module.exports.defaultProps = { 924 | constrainTo : 'parent', 925 | showDelay : 300, 926 | hideDelay : 320, 927 | track : false, 928 | constrainHeight : true, 929 | constrainWidth : true, 930 | arrowSize : 15, 931 | bindScroll : false, 932 | bindWindowResize : false, 933 | className : '', 934 | title : '', 935 | showOnMouseEnter : true, 936 | hideOnMouseLeave : true, 937 | toggleOnClick : false, 938 | persistOverContent : false 939 | } 940 | 941 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-poppy", 3 | "version": "0.1.17", 4 | "description": "React popover that scales, follows, scrolls, and grows", 5 | "main": "dist/poppy.umd.js", 6 | "author": { 7 | "name": "Trevor Lovell" 8 | }, 9 | "keywords": [ 10 | "react", 11 | "popover", 12 | "pop", 13 | "poppy", 14 | "hover" 15 | ], 16 | "license": "ISC", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/TaDaa/react-poppy.git" 20 | }, 21 | "scripts": { 22 | "prepublish": "npm run build", 23 | "build": "rm -rf dist/*.* && cp libs/poppy.css dist/poppy.css && webpack", 24 | "postpublish": "git push --follow-tags" 25 | }, 26 | "peerDependencies": { 27 | "react": ">= 15.0.0", 28 | "react-dom": ">= 15.0.0" 29 | }, 30 | "devDependencies": { 31 | "babel-core": "^6.16.0", 32 | "babel-loader": "^6.2.5", 33 | "babel-preset-es2015": "^6.24.1", 34 | "babel-preset-react": "^6.16.0", 35 | "prop-types": "^15.5.10", 36 | "uglify": "^0.1.5", 37 | "webpack": "^3.0.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var 2 | webpack = require('webpack'), 3 | path = require('path'), 4 | dedupe = new webpack.optimize.DedupePlugin(), 5 | dir = path.resolve(__dirname,'dist'); 6 | 7 | module.exports = [ 8 | ]; 9 | 10 | config('var',''), 11 | config('commonjs2'), 12 | config('amd'), 13 | config('umd') 14 | //demo 15 | //("scroll"); 16 | 17 | //function demo (target) { 18 | //module.exports.push({ 19 | //'entry' : { 20 | //'app' : ["./demos/"+target+".js"] 21 | //}, 22 | //'output' : { 23 | //'path' : dir, 24 | //'filename' : "/demo_bundles/" + target +'.bundle.js' 25 | //}, 26 | //'externals' : { 27 | //'react' : 'React', 28 | //'react-dom' : 'ReactDOM' 29 | //}, 30 | //'module' : { 31 | //'loaders' : [{ 32 | //'test' : /\.jsx?$/, 33 | //'loader' : 'babel-loader', 34 | //'exclude' : /node_modules/, 35 | //'query' : { 36 | //'presets' : ['react'] 37 | //} 38 | //}] 39 | //} 40 | //}); 41 | //return demo; 42 | //} 43 | 44 | function config (target,optionalName) { 45 | optionalName = optionalName !== '' ? ('.'+(optionalName || target)) : ''; 46 | module.exports.push({ 47 | 'entry' : { 48 | 'app' : ['./libs/index.js'] 49 | }, 50 | 'output' : { 51 | 'path' : dir, 52 | 'library' : 'poppy', 53 | 'libraryTarget' : target, 54 | 'filename' : 'poppy'+optionalName +'.js' 55 | }, 56 | 'externals': { 57 | 'react': { 58 | 'root': 'React', 59 | 'commonjs2': 'react', 60 | 'commonjs': 'react', 61 | 'amd': 'react', 62 | 'umd' : 'react' 63 | }, 64 | 'react-dom': { 65 | 'root': 'ReactDOM', 66 | 'commonjs2': 'react-dom', 67 | 'commonjs': 'react-dom', 68 | 'amd': 'react-dom', 69 | 'umd' : 'react-dom' 70 | } 71 | }, 72 | 'module' : { 73 | 'loaders' : [{ 74 | 'test' : /\.jsx?$/, 75 | 'loader' : 'babel-loader', 76 | 'exclude' : /node_modules/, 77 | 'query' : { 78 | 'presets' : ['react','es2015'] 79 | } 80 | }] 81 | } 82 | }); 83 | module.exports.push({ 84 | 'entry' : { 85 | 'app' : ['./libs/index.js'] 86 | }, 87 | 'output' : { 88 | 'path' : dir, 89 | 'library' : 'poppy', 90 | 'libraryTarget' : target, 91 | 'filename' : 'poppy'+optionalName+'.min.js' 92 | }, 93 | 'externals': { 94 | 'react': { 95 | 'root': 'React', 96 | 'commonjs2': 'react', 97 | 'commonjs': 'react', 98 | 'amd': 'react' 99 | }, 100 | 'react-dom': { 101 | 'root': 'ReactDOM', 102 | 'commonjs2': 'react-dom', 103 | 'commonjs': 'react-dom', 104 | 'amd': 'react-dom' 105 | } 106 | }, 107 | 'module' : { 108 | 'loaders' : [{ 109 | 'test' : /\.jsx?$/, 110 | 'loader' : 'babel-loader', 111 | 'exclude' : /node_modules/, 112 | 'query' : { 113 | 'presets' : ['es2015','react'] 114 | } 115 | }] 116 | }, 117 | 'plugins' : [ 118 | new webpack.optimize.UglifyJsPlugin({minimize:true}) 119 | ] 120 | }); 121 | } 122 | 123 | --------------------------------------------------------------------------------