react-popper
Advanced tools
Comparing version 0.9.1-alpha.1 to 0.9.1
@@ -186,2 +186,4 @@ 'use strict'; | ||
var placements = PopperJS.placements; | ||
var Popper = function (_Component) { | ||
@@ -313,5 +315,5 @@ inherits(Popper, _Component); | ||
if (this._arrowNode) { | ||
modifiers.arrow = { | ||
modifiers.arrow = _extends({}, this.props.modifiers.arrow || {}, { | ||
element: this._arrowNode | ||
}; | ||
}); | ||
} | ||
@@ -399,3 +401,3 @@ this._popper = new PopperJS(this._getTargetNode(), this._popperNode, { | ||
innerRef: PropTypes.func, | ||
placement: PropTypes.oneOf(PopperJS.placements), | ||
placement: PropTypes.oneOf(placements), | ||
eventsEnabled: PropTypes.bool, | ||
@@ -461,3 +463,4 @@ modifiers: PropTypes.object, | ||
exports.Popper = Popper; | ||
exports.placements = placements; | ||
exports.Arrow = Arrow; | ||
//# sourceMappingURL=react-popper.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var react=require('react'),PropTypes=_interopDefault(require('prop-types')),PopperJS=_interopDefault(require('popper.js')),classCallCheck=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},inherits=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},objectWithoutProperties=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},possibleConstructorReturn=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},Manager=function(a){function b(){var a,c,d,e;classCallCheck(this,b);for(var f=arguments.length,g=Array(f),h=0;h<f;h++)g[h]=arguments[h];return e=(c=(d=possibleConstructorReturn(this,(a=b.__proto__||Object.getPrototypeOf(b)).call.apply(a,[this].concat(g))),d),d._setTargetNode=function(a){d._targetNode=a},d._getTargetNode=function(){return d._targetNode},c),possibleConstructorReturn(d,e)}return inherits(b,a),createClass(b,[{key:'getChildContext',value:function(){return{popperManager:{setTargetNode:this._setTargetNode,getTargetNode:this._getTargetNode}}}},{key:'render',value:function(){var a=this.props,b=a.tag,c=a.children,d=objectWithoutProperties(a,['tag','children']);return!1===b?c:react.createElement(b,d,c)}}]),b}(react.Component);Manager.childContextTypes={popperManager:PropTypes.object.isRequired},Manager.defaultProps={tag:'div'},Manager.propTypes='production'===process.env.NODE_ENV?{}:{tag:PropTypes.oneOfType([PropTypes.string,PropTypes.bool]),children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])};var Target=function(a,b){var c=a.component,d=void 0===c?'div':c,e=a.innerRef,f=a.children,g=objectWithoutProperties(a,['component','innerRef','children']),h=b.popperManager,i=function(a){h.setTargetNode(a),'function'==typeof e&&e(a)};if('function'==typeof f){return f({targetProps:{ref:i},restProps:g})}var j=_extends({},g);return'string'==typeof d?j.ref=i:j.innerRef=i,react.createElement(d,j,f)};Target.contextTypes={popperManager:PropTypes.object.isRequired},Target.propTypes={component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])};var Popper=function(a){function b(){var a,c,d,e;classCallCheck(this,b);for(var f=arguments.length,g=Array(f),h=0;h<f;h++)g[h]=arguments[h];return e=(c=(d=possibleConstructorReturn(this,(a=b.__proto__||Object.getPrototypeOf(b)).call.apply(a,[this].concat(g))),d),d.state={},d._setArrowNode=function(a){d._arrowNode=a},d._getTargetNode=function(){if(d.props.target)return d.props.target;if(!d.context.popperManager||!d.context.popperManager.getTargetNode())throw new Error('Target missing. Popper must be given a target from the Popper Manager, or as a prop.');return d.context.popperManager.getTargetNode()},d._getOffsets=function(a){return Object.keys(a.offsets).map(function(b){return a.offsets[b]})},d._isDataDirty=function(a){return!d.state.data||JSON.stringify(d._getOffsets(d.state.data))!==JSON.stringify(d._getOffsets(a))},d._updateStateModifier={enabled:!0,order:900,fn:function(a){return d._isDataDirty(a)&&d.setState({data:a}),a}},d._getPopperStyle=function(){var a=d.state.data;return d._popper&&a?_extends({position:a.offsets.popper.position},a.styles):{position:'absolute',pointerEvents:'none',opacity:0}},d._getPopperPlacement=function(){return d.state.data?d.state.data.placement:void 0},d._getPopperHide=function(){return!!d.state.data&&d.state.data.hide?'':void 0},d._getArrowStyle=function(){if(!d.state.data||!d.state.data.offsets.arrow)return{};var a=d.state.data.offsets.arrow,b=a.top,c=a.left;return{top:b,left:c}},d._handlePopperRef=function(a){d._popperNode=a,a?d._createPopper():d._destroyPopper(),d.props.innerRef&&d.props.innerRef(a)},d._scheduleUpdate=function(){d._popper&&d._popper.scheduleUpdate()},c),possibleConstructorReturn(d,e)}return inherits(b,a),createClass(b,[{key:'getChildContext',value:function(){return{popper:{setArrowNode:this._setArrowNode,getArrowStyle:this._getArrowStyle}}}},{key:'componentDidUpdate',value:function(a){(a.placement!==this.props.placement||a.eventsEnabled!==this.props.eventsEnabled||a.target!==this.props.target)&&(this._destroyPopper(),this._createPopper()),a.children!==this.props.children&&this._scheduleUpdate()}},{key:'componentWillUnmount',value:function(){this._destroyPopper()}},{key:'_createPopper',value:function(){var a=this,b=this.props,c=b.placement,d=b.eventsEnabled,e=_extends({},this.props.modifiers,{applyStyle:{enabled:!1},updateState:this._updateStateModifier});this._arrowNode&&(e.arrow={element:this._arrowNode}),this._popper=new PopperJS(this._getTargetNode(),this._popperNode,{placement:c,eventsEnabled:d,modifiers:e}),setTimeout(function(){return a._scheduleUpdate()})}},{key:'_destroyPopper',value:function(){this._popper&&this._popper.destroy()}},{key:'render',value:function(){var a=this.props,b=a.component,c=a.innerRef,d=a.placement,e=a.eventsEnabled,f=a.modifiers,g=a.children,h=objectWithoutProperties(a,['component','innerRef','placement','eventsEnabled','modifiers','children']),i=this._getPopperStyle(),j=this._getPopperPlacement(),k=this._getPopperHide();if('function'==typeof g){var l={ref:this._handlePopperRef,style:i,"data-placement":j,"data-x-out-of-boundaries":k};return g({popperProps:l,restProps:h,scheduleUpdate:this._scheduleUpdate})}var m=_extends({},h,{style:_extends({},h.style,i),"data-placement":j,"data-x-out-of-boundaries":k});return'string'==typeof b?m.ref=this._handlePopperRef:m.innerRef=this._handlePopperRef,react.createElement(b,m,g)}}]),b}(react.Component);Popper.contextTypes={popperManager:PropTypes.object},Popper.childContextTypes={popper:PropTypes.object.isRequired},Popper.defaultProps={component:'div',placement:'bottom',eventsEnabled:!0,modifiers:{}},Popper.propTypes='production'===process.env.NODE_ENV?{}:{component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,placement:PropTypes.oneOf(PopperJS.placements),eventsEnabled:PropTypes.bool,modifiers:PropTypes.object,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),target:PropTypes.oneOfType([PropTypes.instanceOf(Element),PropTypes.shape({getBoundingClientRect:PropTypes.func.isRequired,clientWidth:PropTypes.number.isRequired,clientHeight:PropTypes.number.isRequired})])};var Arrow=function(a,b){var c=a.component,d=void 0===c?'span':c,e=a.innerRef,f=a.children,g=objectWithoutProperties(a,['component','innerRef','children']),h=b.popper,i=function(a){h.setArrowNode(a),'function'==typeof e&&e(a)},j=h.getArrowStyle();if('function'==typeof f){return f({arrowProps:{ref:i,style:j},restProps:g})}var k=_extends({},g,{style:_extends({},j,g.style)});return'string'==typeof d?k.ref=i:k.innerRef=i,react.createElement(d,k,f)};Arrow.contextTypes={popper:PropTypes.object.isRequired},Arrow.propTypes={component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])},exports.Manager=Manager,exports.Target=Target,exports.Popper=Popper,exports.Arrow=Arrow; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var react=require('react'),PropTypes=_interopDefault(require('prop-types')),PopperJS=_interopDefault(require('popper.js')),classCallCheck=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},inherits=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},objectWithoutProperties=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},possibleConstructorReturn=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},Manager=function(a){function b(){var a,c,d,e;classCallCheck(this,b);for(var f=arguments.length,g=Array(f),h=0;h<f;h++)g[h]=arguments[h];return e=(c=(d=possibleConstructorReturn(this,(a=b.__proto__||Object.getPrototypeOf(b)).call.apply(a,[this].concat(g))),d),d._setTargetNode=function(a){d._targetNode=a},d._getTargetNode=function(){return d._targetNode},c),possibleConstructorReturn(d,e)}return inherits(b,a),createClass(b,[{key:'getChildContext',value:function(){return{popperManager:{setTargetNode:this._setTargetNode,getTargetNode:this._getTargetNode}}}},{key:'render',value:function(){var a=this.props,b=a.tag,c=a.children,d=objectWithoutProperties(a,['tag','children']);return!1===b?c:react.createElement(b,d,c)}}]),b}(react.Component);Manager.childContextTypes={popperManager:PropTypes.object.isRequired},Manager.defaultProps={tag:'div'},Manager.propTypes='production'===process.env.NODE_ENV?{}:{tag:PropTypes.oneOfType([PropTypes.string,PropTypes.bool]),children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])};var Target=function(a,b){var c=a.component,d=void 0===c?'div':c,e=a.innerRef,f=a.children,g=objectWithoutProperties(a,['component','innerRef','children']),h=b.popperManager,i=function(a){h.setTargetNode(a),'function'==typeof e&&e(a)};if('function'==typeof f){return f({targetProps:{ref:i},restProps:g})}var j=_extends({},g);return'string'==typeof d?j.ref=i:j.innerRef=i,react.createElement(d,j,f)};Target.contextTypes={popperManager:PropTypes.object.isRequired},Target.propTypes={component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])};var placements=PopperJS.placements,Popper=function(a){function b(){var a,c,d,e;classCallCheck(this,b);for(var f=arguments.length,g=Array(f),h=0;h<f;h++)g[h]=arguments[h];return e=(c=(d=possibleConstructorReturn(this,(a=b.__proto__||Object.getPrototypeOf(b)).call.apply(a,[this].concat(g))),d),d.state={},d._setArrowNode=function(a){d._arrowNode=a},d._getTargetNode=function(){if(d.props.target)return d.props.target;if(!d.context.popperManager||!d.context.popperManager.getTargetNode())throw new Error('Target missing. Popper must be given a target from the Popper Manager, or as a prop.');return d.context.popperManager.getTargetNode()},d._getOffsets=function(a){return Object.keys(a.offsets).map(function(b){return a.offsets[b]})},d._isDataDirty=function(a){return!d.state.data||JSON.stringify(d._getOffsets(d.state.data))!==JSON.stringify(d._getOffsets(a))},d._updateStateModifier={enabled:!0,order:900,fn:function(a){return d._isDataDirty(a)&&d.setState({data:a}),a}},d._getPopperStyle=function(){var a=d.state.data;return d._popper&&a?_extends({position:a.offsets.popper.position},a.styles):{position:'absolute',pointerEvents:'none',opacity:0}},d._getPopperPlacement=function(){return d.state.data?d.state.data.placement:void 0},d._getPopperHide=function(){return!!d.state.data&&d.state.data.hide?'':void 0},d._getArrowStyle=function(){if(!d.state.data||!d.state.data.offsets.arrow)return{};var a=d.state.data.offsets.arrow,b=a.top,c=a.left;return{top:b,left:c}},d._handlePopperRef=function(a){d._popperNode=a,a?d._createPopper():d._destroyPopper(),d.props.innerRef&&d.props.innerRef(a)},d._scheduleUpdate=function(){d._popper&&d._popper.scheduleUpdate()},c),possibleConstructorReturn(d,e)}return inherits(b,a),createClass(b,[{key:'getChildContext',value:function(){return{popper:{setArrowNode:this._setArrowNode,getArrowStyle:this._getArrowStyle}}}},{key:'componentDidUpdate',value:function(a){(a.placement!==this.props.placement||a.eventsEnabled!==this.props.eventsEnabled||a.target!==this.props.target)&&(this._destroyPopper(),this._createPopper()),a.children!==this.props.children&&this._scheduleUpdate()}},{key:'componentWillUnmount',value:function(){this._destroyPopper()}},{key:'_createPopper',value:function(){var a=this,b=this.props,c=b.placement,d=b.eventsEnabled,e=_extends({},this.props.modifiers,{applyStyle:{enabled:!1},updateState:this._updateStateModifier});this._arrowNode&&(e.arrow=_extends({},this.props.modifiers.arrow||{},{element:this._arrowNode})),this._popper=new PopperJS(this._getTargetNode(),this._popperNode,{placement:c,eventsEnabled:d,modifiers:e}),setTimeout(function(){return a._scheduleUpdate()})}},{key:'_destroyPopper',value:function(){this._popper&&this._popper.destroy()}},{key:'render',value:function(){var a=this.props,b=a.component,c=a.innerRef,d=a.placement,e=a.eventsEnabled,f=a.modifiers,g=a.children,h=objectWithoutProperties(a,['component','innerRef','placement','eventsEnabled','modifiers','children']),i=this._getPopperStyle(),j=this._getPopperPlacement(),k=this._getPopperHide();if('function'==typeof g){var l={ref:this._handlePopperRef,style:i,"data-placement":j,"data-x-out-of-boundaries":k};return g({popperProps:l,restProps:h,scheduleUpdate:this._scheduleUpdate})}var m=_extends({},h,{style:_extends({},h.style,i),"data-placement":j,"data-x-out-of-boundaries":k});return'string'==typeof b?m.ref=this._handlePopperRef:m.innerRef=this._handlePopperRef,react.createElement(b,m,g)}}]),b}(react.Component);Popper.contextTypes={popperManager:PropTypes.object},Popper.childContextTypes={popper:PropTypes.object.isRequired},Popper.defaultProps={component:'div',placement:'bottom',eventsEnabled:!0,modifiers:{}},Popper.propTypes='production'===process.env.NODE_ENV?{}:{component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,placement:PropTypes.oneOf(placements),eventsEnabled:PropTypes.bool,modifiers:PropTypes.object,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),target:PropTypes.oneOfType([PropTypes.instanceOf(Element),PropTypes.shape({getBoundingClientRect:PropTypes.func.isRequired,clientWidth:PropTypes.number.isRequired,clientHeight:PropTypes.number.isRequired})])};var Arrow=function(a,b){var c=a.component,d=void 0===c?'span':c,e=a.innerRef,f=a.children,g=objectWithoutProperties(a,['component','innerRef','children']),h=b.popper,i=function(a){h.setArrowNode(a),'function'==typeof e&&e(a)},j=h.getArrowStyle();if('function'==typeof f){return f({arrowProps:{ref:i,style:j},restProps:g})}var k=_extends({},g,{style:_extends({},j,g.style)});return'string'==typeof d?k.ref=i:k.innerRef=i,react.createElement(d,k,f)};Arrow.contextTypes={popper:PropTypes.object.isRequired},Arrow.propTypes={component:PropTypes.oneOfType([PropTypes.node,PropTypes.func]),innerRef:PropTypes.func,children:PropTypes.oneOfType([PropTypes.node,PropTypes.func])},exports.Manager=Manager,exports.Target=Target,exports.Popper=Popper,exports.placements=placements,exports.Arrow=Arrow; | ||
//# sourceMappingURL=react-popper.min.js.map |
@@ -185,2 +185,4 @@ (function (global, factory) { | ||
var placements = PopperJS.placements; | ||
var Popper = function (_Component) { | ||
@@ -312,5 +314,5 @@ inherits(Popper, _Component); | ||
if (this._arrowNode) { | ||
modifiers.arrow = { | ||
modifiers.arrow = _extends({}, this.props.modifiers.arrow || {}, { | ||
element: this._arrowNode | ||
}; | ||
}); | ||
} | ||
@@ -398,3 +400,3 @@ this._popper = new PopperJS(this._getTargetNode(), this._popperNode, { | ||
innerRef: PropTypes.func, | ||
placement: PropTypes.oneOf(PopperJS.placements), | ||
placement: PropTypes.oneOf(placements), | ||
eventsEnabled: PropTypes.bool, | ||
@@ -460,2 +462,3 @@ modifiers: PropTypes.object, | ||
exports.Popper = Popper; | ||
exports.placements = placements; | ||
exports.Arrow = Arrow; | ||
@@ -462,0 +465,0 @@ |
@@ -1,2 +0,2 @@ | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('prop-types'),require('popper.js')):'function'==typeof define&&define.amd?define(['exports','react','prop-types','popper.js'],b):b(a['react-popper']={},a.react,a.PropTypes,a.PopperJS)})(this,function(a,b,c,d){'use strict';c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d;var e=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},f=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},h=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},i=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},j=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},k=function(a){function c(){var a,b,d,f;e(this,c);for(var g=arguments.length,h=Array(g),i=0;i<g;i++)h[i]=arguments[i];return f=(b=(d=j(this,(a=c.__proto__||Object.getPrototypeOf(c)).call.apply(a,[this].concat(h))),d),d._setTargetNode=function(a){d._targetNode=a},d._getTargetNode=function(){return d._targetNode},b),j(d,f)}return h(c,a),f(c,[{key:'getChildContext',value:function(){return{popperManager:{setTargetNode:this._setTargetNode,getTargetNode:this._getTargetNode}}}},{key:'render',value:function(){var a=this.props,c=a.tag,d=a.children,e=i(a,['tag','children']);return!1===c?d:b.createElement(c,e,d)}}]),c}(b.Component);k.childContextTypes={popperManager:c.object.isRequired},k.defaultProps={tag:'div'},k.propTypes='production'===process.env.NODE_ENV?{}:{tag:c.oneOfType([c.string,c.bool]),children:c.oneOfType([c.node,c.func])};var l=function(a,c){var d=a.component,e=void 0===d?'div':d,f=a.innerRef,h=a.children,j=i(a,['component','innerRef','children']),k=c.popperManager,l=function(a){k.setTargetNode(a),'function'==typeof f&&f(a)};if('function'==typeof h){return h({targetProps:{ref:l},restProps:j})}var m=g({},j);return'string'==typeof e?m.ref=l:m.innerRef=l,b.createElement(e,m,h)};l.contextTypes={popperManager:c.object.isRequired},l.propTypes={component:c.oneOfType([c.node,c.func]),innerRef:c.func,children:c.oneOfType([c.node,c.func])};var m=function(a){function c(){var a,b,d,f;e(this,c);for(var h=arguments.length,i=Array(h),k=0;k<h;k++)i[k]=arguments[k];return f=(b=(d=j(this,(a=c.__proto__||Object.getPrototypeOf(c)).call.apply(a,[this].concat(i))),d),d.state={},d._setArrowNode=function(a){d._arrowNode=a},d._getTargetNode=function(){if(d.props.target)return d.props.target;if(!d.context.popperManager||!d.context.popperManager.getTargetNode())throw new Error('Target missing. Popper must be given a target from the Popper Manager, or as a prop.');return d.context.popperManager.getTargetNode()},d._getOffsets=function(a){return Object.keys(a.offsets).map(function(b){return a.offsets[b]})},d._isDataDirty=function(a){return!d.state.data||JSON.stringify(d._getOffsets(d.state.data))!==JSON.stringify(d._getOffsets(a))},d._updateStateModifier={enabled:!0,order:900,fn:function(a){return d._isDataDirty(a)&&d.setState({data:a}),a}},d._getPopperStyle=function(){var a=d.state.data;return d._popper&&a?g({position:a.offsets.popper.position},a.styles):{position:'absolute',pointerEvents:'none',opacity:0}},d._getPopperPlacement=function(){return d.state.data?d.state.data.placement:void 0},d._getPopperHide=function(){return!!d.state.data&&d.state.data.hide?'':void 0},d._getArrowStyle=function(){if(!d.state.data||!d.state.data.offsets.arrow)return{};var a=d.state.data.offsets.arrow,b=a.top,c=a.left;return{top:b,left:c}},d._handlePopperRef=function(a){d._popperNode=a,a?d._createPopper():d._destroyPopper(),d.props.innerRef&&d.props.innerRef(a)},d._scheduleUpdate=function(){d._popper&&d._popper.scheduleUpdate()},b),j(d,f)}return h(c,a),f(c,[{key:'getChildContext',value:function(){return{popper:{setArrowNode:this._setArrowNode,getArrowStyle:this._getArrowStyle}}}},{key:'componentDidUpdate',value:function(a){(a.placement!==this.props.placement||a.eventsEnabled!==this.props.eventsEnabled||a.target!==this.props.target)&&(this._destroyPopper(),this._createPopper()),a.children!==this.props.children&&this._scheduleUpdate()}},{key:'componentWillUnmount',value:function(){this._destroyPopper()}},{key:'_createPopper',value:function(){var a=this,b=this.props,c=b.placement,e=b.eventsEnabled,f=g({},this.props.modifiers,{applyStyle:{enabled:!1},updateState:this._updateStateModifier});this._arrowNode&&(f.arrow={element:this._arrowNode}),this._popper=new d(this._getTargetNode(),this._popperNode,{placement:c,eventsEnabled:e,modifiers:f}),setTimeout(function(){return a._scheduleUpdate()})}},{key:'_destroyPopper',value:function(){this._popper&&this._popper.destroy()}},{key:'render',value:function(){var a=this.props,c=a.component,d=a.innerRef,e=a.placement,f=a.eventsEnabled,h=a.modifiers,j=a.children,k=i(a,['component','innerRef','placement','eventsEnabled','modifiers','children']),l=this._getPopperStyle(),m=this._getPopperPlacement(),n=this._getPopperHide();if('function'==typeof j){var o={ref:this._handlePopperRef,style:l,"data-placement":m,"data-x-out-of-boundaries":n};return j({popperProps:o,restProps:k,scheduleUpdate:this._scheduleUpdate})}var p=g({},k,{style:g({},k.style,l),"data-placement":m,"data-x-out-of-boundaries":n});return'string'==typeof c?p.ref=this._handlePopperRef:p.innerRef=this._handlePopperRef,b.createElement(c,p,j)}}]),c}(b.Component);m.contextTypes={popperManager:c.object},m.childContextTypes={popper:c.object.isRequired},m.defaultProps={component:'div',placement:'bottom',eventsEnabled:!0,modifiers:{}},m.propTypes='production'===process.env.NODE_ENV?{}:{component:c.oneOfType([c.node,c.func]),innerRef:c.func,placement:c.oneOf(d.placements),eventsEnabled:c.bool,modifiers:c.object,children:c.oneOfType([c.node,c.func]),target:c.oneOfType([c.instanceOf(Element),c.shape({getBoundingClientRect:c.func.isRequired,clientWidth:c.number.isRequired,clientHeight:c.number.isRequired})])};var n=function(a,c){var d=a.component,e=void 0===d?'span':d,f=a.innerRef,h=a.children,j=i(a,['component','innerRef','children']),k=c.popper,l=function(a){k.setArrowNode(a),'function'==typeof f&&f(a)},m=k.getArrowStyle();if('function'==typeof h){return h({arrowProps:{ref:l,style:m},restProps:j})}var n=g({},j,{style:g({},m,j.style)});return'string'==typeof e?n.ref=l:n.innerRef=l,b.createElement(e,n,h)};n.contextTypes={popper:c.object.isRequired},n.propTypes={component:c.oneOfType([c.node,c.func]),innerRef:c.func,children:c.oneOfType([c.node,c.func])},a.Manager=k,a.Target=l,a.Popper=m,a.Arrow=n,Object.defineProperty(a,'__esModule',{value:!0})}); | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports,require('react'),require('prop-types'),require('popper.js')):'function'==typeof define&&define.amd?define(['exports','react','prop-types','popper.js'],b):b(a['react-popper']={},a.react,a.PropTypes,a.PopperJS)})(this,function(a,b,c,d){'use strict';c=c&&c.hasOwnProperty('default')?c['default']:c,d=d&&d.hasOwnProperty('default')?d['default']:d;var e=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},f=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},h=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},i=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},j=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},k=function(a){function c(){var a,b,d,f;e(this,c);for(var g=arguments.length,h=Array(g),i=0;i<g;i++)h[i]=arguments[i];return f=(b=(d=j(this,(a=c.__proto__||Object.getPrototypeOf(c)).call.apply(a,[this].concat(h))),d),d._setTargetNode=function(a){d._targetNode=a},d._getTargetNode=function(){return d._targetNode},b),j(d,f)}return h(c,a),f(c,[{key:'getChildContext',value:function(){return{popperManager:{setTargetNode:this._setTargetNode,getTargetNode:this._getTargetNode}}}},{key:'render',value:function(){var a=this.props,c=a.tag,d=a.children,e=i(a,['tag','children']);return!1===c?d:b.createElement(c,e,d)}}]),c}(b.Component);k.childContextTypes={popperManager:c.object.isRequired},k.defaultProps={tag:'div'},k.propTypes='production'===process.env.NODE_ENV?{}:{tag:c.oneOfType([c.string,c.bool]),children:c.oneOfType([c.node,c.func])};var l=function(a,c){var d=a.component,e=void 0===d?'div':d,f=a.innerRef,h=a.children,j=i(a,['component','innerRef','children']),k=c.popperManager,l=function(a){k.setTargetNode(a),'function'==typeof f&&f(a)};if('function'==typeof h){return h({targetProps:{ref:l},restProps:j})}var m=g({},j);return'string'==typeof e?m.ref=l:m.innerRef=l,b.createElement(e,m,h)};l.contextTypes={popperManager:c.object.isRequired},l.propTypes={component:c.oneOfType([c.node,c.func]),innerRef:c.func,children:c.oneOfType([c.node,c.func])};var m=d.placements,n=function(a){function c(){var a,b,d,f;e(this,c);for(var h=arguments.length,i=Array(h),k=0;k<h;k++)i[k]=arguments[k];return f=(b=(d=j(this,(a=c.__proto__||Object.getPrototypeOf(c)).call.apply(a,[this].concat(i))),d),d.state={},d._setArrowNode=function(a){d._arrowNode=a},d._getTargetNode=function(){if(d.props.target)return d.props.target;if(!d.context.popperManager||!d.context.popperManager.getTargetNode())throw new Error('Target missing. Popper must be given a target from the Popper Manager, or as a prop.');return d.context.popperManager.getTargetNode()},d._getOffsets=function(a){return Object.keys(a.offsets).map(function(b){return a.offsets[b]})},d._isDataDirty=function(a){return!d.state.data||JSON.stringify(d._getOffsets(d.state.data))!==JSON.stringify(d._getOffsets(a))},d._updateStateModifier={enabled:!0,order:900,fn:function(a){return d._isDataDirty(a)&&d.setState({data:a}),a}},d._getPopperStyle=function(){var a=d.state.data;return d._popper&&a?g({position:a.offsets.popper.position},a.styles):{position:'absolute',pointerEvents:'none',opacity:0}},d._getPopperPlacement=function(){return d.state.data?d.state.data.placement:void 0},d._getPopperHide=function(){return!!d.state.data&&d.state.data.hide?'':void 0},d._getArrowStyle=function(){if(!d.state.data||!d.state.data.offsets.arrow)return{};var a=d.state.data.offsets.arrow,b=a.top,c=a.left;return{top:b,left:c}},d._handlePopperRef=function(a){d._popperNode=a,a?d._createPopper():d._destroyPopper(),d.props.innerRef&&d.props.innerRef(a)},d._scheduleUpdate=function(){d._popper&&d._popper.scheduleUpdate()},b),j(d,f)}return h(c,a),f(c,[{key:'getChildContext',value:function(){return{popper:{setArrowNode:this._setArrowNode,getArrowStyle:this._getArrowStyle}}}},{key:'componentDidUpdate',value:function(a){(a.placement!==this.props.placement||a.eventsEnabled!==this.props.eventsEnabled||a.target!==this.props.target)&&(this._destroyPopper(),this._createPopper()),a.children!==this.props.children&&this._scheduleUpdate()}},{key:'componentWillUnmount',value:function(){this._destroyPopper()}},{key:'_createPopper',value:function(){var a=this,b=this.props,c=b.placement,e=b.eventsEnabled,f=g({},this.props.modifiers,{applyStyle:{enabled:!1},updateState:this._updateStateModifier});this._arrowNode&&(f.arrow=g({},this.props.modifiers.arrow||{},{element:this._arrowNode})),this._popper=new d(this._getTargetNode(),this._popperNode,{placement:c,eventsEnabled:e,modifiers:f}),setTimeout(function(){return a._scheduleUpdate()})}},{key:'_destroyPopper',value:function(){this._popper&&this._popper.destroy()}},{key:'render',value:function(){var a=this.props,c=a.component,d=a.innerRef,e=a.placement,f=a.eventsEnabled,h=a.modifiers,j=a.children,k=i(a,['component','innerRef','placement','eventsEnabled','modifiers','children']),l=this._getPopperStyle(),m=this._getPopperPlacement(),n=this._getPopperHide();if('function'==typeof j){var o={ref:this._handlePopperRef,style:l,"data-placement":m,"data-x-out-of-boundaries":n};return j({popperProps:o,restProps:k,scheduleUpdate:this._scheduleUpdate})}var p=g({},k,{style:g({},k.style,l),"data-placement":m,"data-x-out-of-boundaries":n});return'string'==typeof c?p.ref=this._handlePopperRef:p.innerRef=this._handlePopperRef,b.createElement(c,p,j)}}]),c}(b.Component);n.contextTypes={popperManager:c.object},n.childContextTypes={popper:c.object.isRequired},n.defaultProps={component:'div',placement:'bottom',eventsEnabled:!0,modifiers:{}},n.propTypes='production'===process.env.NODE_ENV?{}:{component:c.oneOfType([c.node,c.func]),innerRef:c.func,placement:c.oneOf(m),eventsEnabled:c.bool,modifiers:c.object,children:c.oneOfType([c.node,c.func]),target:c.oneOfType([c.instanceOf(Element),c.shape({getBoundingClientRect:c.func.isRequired,clientWidth:c.number.isRequired,clientHeight:c.number.isRequired})])};var o=function(a,c){var d=a.component,e=void 0===d?'span':d,f=a.innerRef,h=a.children,j=i(a,['component','innerRef','children']),k=c.popper,l=function(a){k.setArrowNode(a),'function'==typeof f&&f(a)},m=k.getArrowStyle();if('function'==typeof h){return h({arrowProps:{ref:l,style:m},restProps:j})}var n=g({},j,{style:g({},m,j.style)});return'string'==typeof e?n.ref=l:n.innerRef=l,b.createElement(e,n,h)};o.contextTypes={popper:c.object.isRequired},o.propTypes={component:c.oneOfType([c.node,c.func]),innerRef:c.func,children:c.oneOfType([c.node,c.func])},a.Manager=k,a.Target=l,a.Popper=n,a.placements=m,a.Arrow=o,Object.defineProperty(a,'__esModule',{value:!0})}); | ||
//# sourceMappingURL=react-popper.umd.min.js.map |
@@ -17,2 +17,4 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
export var placements = PopperJS.placements; | ||
var Popper = function (_Component) { | ||
@@ -144,5 +146,5 @@ _inherits(Popper, _Component); | ||
if (this._arrowNode) { | ||
modifiers.arrow = { | ||
modifiers.arrow = _extends({}, this.props.modifiers.arrow || {}, { | ||
element: this._arrowNode | ||
}; | ||
}); | ||
} | ||
@@ -225,3 +227,3 @@ this._popper = new PopperJS(this._getTargetNode(), this._popperNode, { | ||
innerRef: PropTypes.func, | ||
placement: PropTypes.oneOf(PopperJS.placements), | ||
placement: PropTypes.oneOf(placements), | ||
eventsEnabled: PropTypes.bool, | ||
@@ -228,0 +230,0 @@ modifiers: PropTypes.object, |
export { default as Manager } from './Manager'; | ||
export { default as Target } from './Target'; | ||
export { default as Popper } from './Popper'; | ||
export { default as Popper, placements } from './Popper'; | ||
export { default as Arrow } from './Arrow'; |
{ | ||
"name": "react-popper", | ||
"version": "0.9.1-alpha.1", | ||
"version": "0.9.1", | ||
"description": "React wrapper around PopperJS.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143945
1273