@vx/tooltip
Advanced tools
Comparing version 0.0.165 to 0.0.179
@@ -27,2 +27,10 @@ 'use strict'; | ||
Tooltip.propTypes = { | ||
left: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
top: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
className: _propTypes2.default.string, | ||
style: _propTypes2.default.object, | ||
children: _propTypes2.default.any | ||
}; | ||
function Tooltip(_ref) { | ||
@@ -56,10 +64,2 @@ var className = _ref.className, | ||
); | ||
} | ||
Tooltip.propTypes = { | ||
left: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
top: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
className: _propTypes2.default.string, | ||
style: _propTypes2.default.object, | ||
children: _propTypes2.default.any | ||
}; | ||
} |
@@ -7,5 +7,8 @@ 'use strict'; | ||
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; }; /* eslint react/forbid-prop-types: 0 */ | ||
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; }; | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
@@ -15,6 +18,2 @@ | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _bounds = require('@vx/bounds'); | ||
@@ -30,3 +29,26 @@ | ||
var propTypes = _extends({}, _bounds.withBoundingRectsProps, _Tooltip2.default.propTypes, { | ||
var rectShape = _propTypes2.default.shape({ | ||
top: _propTypes2.default.number.isRequired, | ||
right: _propTypes2.default.number.isRequired, | ||
bottom: _propTypes2.default.number.isRequired, | ||
left: _propTypes2.default.number.isRequired, | ||
width: _propTypes2.default.number.isRequired, | ||
height: _propTypes2.default.number.isRequired | ||
}); | ||
var withBoundingRectsProps = { | ||
getRects: _propTypes2.default.func, | ||
rect: rectShape, | ||
parentRect: rectShape | ||
}; | ||
var tooltipProps = { | ||
left: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
top: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), | ||
className: _propTypes2.default.string, | ||
style: _propTypes2.default.object, | ||
children: _propTypes2.default.any | ||
}; | ||
var propTypes = _extends({}, withBoundingRectsProps, tooltipProps, { | ||
offsetLeft: _propTypes2.default.number, | ||
@@ -33,0 +55,0 @@ offsetTop: _propTypes2.default.number |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
import { withBoundingRects, withBoundingRectsProps } from '@vx/bounds'; | ||
import { withBoundingRects } from '@vx/bounds'; | ||
@@ -180,2 +180,10 @@ var classCallCheck = function (instance, Constructor) { | ||
Tooltip.propTypes = { | ||
left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
children: PropTypes.any | ||
}; | ||
function Tooltip(_ref) { | ||
@@ -211,3 +219,18 @@ var className = _ref.className, | ||
Tooltip.propTypes = { | ||
var rectShape = PropTypes.shape({ | ||
top: PropTypes.number.isRequired, | ||
right: PropTypes.number.isRequired, | ||
bottom: PropTypes.number.isRequired, | ||
left: PropTypes.number.isRequired, | ||
width: PropTypes.number.isRequired, | ||
height: PropTypes.number.isRequired | ||
}); | ||
var withBoundingRectsProps = { | ||
getRects: PropTypes.func, | ||
rect: rectShape, | ||
parentRect: rectShape | ||
}; | ||
var tooltipProps = { | ||
left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
@@ -220,5 +243,3 @@ top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
/* eslint react/forbid-prop-types: 0 */ | ||
var propTypes = _extends({}, withBoundingRectsProps, Tooltip.propTypes, { | ||
var propTypes = _extends({}, withBoundingRectsProps, tooltipProps, { | ||
offsetLeft: PropTypes.number, | ||
@@ -225,0 +246,0 @@ offsetTop: PropTypes.number |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types"),require("classnames"),require("@vx/bounds")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","classnames","@vx/bounds"],e):e(t.vx=t.vx||{},t.React,t.PropTypes,t.classNames,t.vx)}(this,function(t,h,e,l,o){"use strict";h=h&&h.hasOwnProperty("default")?h.default:h,e=e&&e.hasOwnProperty("default")?e.default:e,l=l&&l.hasOwnProperty("default")?l.default:l;var n=function(){function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(t,e,o){return e&&i(t.prototype,e),o&&i(t,o),t}}(),y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t},b=function(t,e){var o={};for(var i in t)0<=e.indexOf(i)||Object.prototype.hasOwnProperty.call(t,i)&&(o[i]=t[i]);return o};e.bool,e.number,e.number,e.object,e.func,e.func,e.func;function v(t){var e=t.className,o=t.top,i=t.left,n=t.style,r=t.children,p=b(t,["className","top","left","style","children"]);return h.createElement("div",y({className:l("vx-tooltip-portal",e),style:y({position:"absolute",backgroundColor:"white",color:"#666666",padding:".3rem .5rem",borderRadius:"3px",fontSize:"14px",boxShadow:"0 1px 2px rgba(33,33,33,0.2)",lineHeight:"1em",pointerEvents:"none",top:o,left:i},n)},p),r)}v.propTypes={left:e.oneOfType([e.number,e.string]),top:e.oneOfType([e.number,e.string]),className:e.string,style:e.object,children:e.any};var i=y({},o.withBoundingRectsProps,v.propTypes,{offsetLeft:e.number,offsetTop:e.number});function r(t){var e=t.left,o=t.top,i=t.offsetLeft,n=void 0===i?10:i,r=t.offsetTop,p=void 0===r?10:r,l=t.rect,a=t.parentRect,s=(t.getRects,t.children),u=t.style,f=b(t,["left","top","offsetLeft","offsetTop","rect","parentRect","getRects","children","style"]),c=e,d=o;return l&&a&&(c=n+l.right>a.right||n+l.right>window.innerWidth?c-l.width-n:c+n,d=p+l.bottom>a.bottom||p+l.bottom>window.innerHeight?d-l.height-p:d+p),h.createElement(v,y({style:y({top:0,transform:"translate("+c+"px, "+d+"px)"},u)},f),s)}r.propTypes=i,r.defaultProps={};var p=o.withBoundingRects(r);t.withTooltip=function(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{style:{position:"relative",width:"inherit",height:"inherit"}};return function(t){function o(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o);var e=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,t));return e.state={tooltipOpen:!1,tooltipLeft:void 0,tooltipTop:void 0,tooltipData:void 0},e.updateTooltip=e.updateTooltip.bind(e),e.showTooltip=e.showTooltip.bind(e),e.hideTooltip=e.hideTooltip.bind(e),e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(o,h.PureComponent),n(o,[{key:"updateTooltip",value:function(t){var e=t.tooltipOpen,o=t.tooltipLeft,i=t.tooltipTop,n=t.tooltipData;this.setState(function(t){return y({},t,{tooltipOpen:e,tooltipLeft:o,tooltipTop:i,tooltipData:n})})}},{key:"showTooltip",value:function(t){var e=t.tooltipLeft,o=t.tooltipTop,i=t.tooltipData;this.updateTooltip({tooltipOpen:!0,tooltipLeft:e,tooltipTop:o,tooltipData:i})}},{key:"hideTooltip",value:function(){this.updateTooltip({tooltipOpen:!1,tooltipLeft:void 0,tooltipTop:void 0,tooltipData:void 0})}},{key:"render",value:function(){return h.createElement("div",i,h.createElement(e,y({updateTooltip:this.updateTooltip,showTooltip:this.showTooltip,hideTooltip:this.hideTooltip},this.state,this.props)))}}]),o}()},t.Tooltip=v,t.TooltipWithBounds=p,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types"),require("classnames"),require("@vx/bounds")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","classnames","@vx/bounds"],e):e(t.vx=t.vx||{},t.React,t.PropTypes,t.classNames,t.vx)}(this,function(t,h,e,l,o){"use strict";h=h&&h.hasOwnProperty("default")?h.default:h,e=e&&e.hasOwnProperty("default")?e.default:e,l=l&&l.hasOwnProperty("default")?l.default:l;var n=function(){function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(t,e,o){return e&&i(t.prototype,e),o&&i(t,o),t}}(),b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t},y=function(t,e){var o={};for(var i in t)0<=e.indexOf(i)||Object.prototype.hasOwnProperty.call(t,i)&&(o[i]=t[i]);return o};e.bool,e.number,e.number,e.object,e.func,e.func,e.func;function v(t){var e=t.className,o=t.top,i=t.left,n=t.style,r=t.children,p=y(t,["className","top","left","style","children"]);return h.createElement("div",b({className:l("vx-tooltip-portal",e),style:b({position:"absolute",backgroundColor:"white",color:"#666666",padding:".3rem .5rem",borderRadius:"3px",fontSize:"14px",boxShadow:"0 1px 2px rgba(33,33,33,0.2)",lineHeight:"1em",pointerEvents:"none",top:o,left:i},n)},p),r)}v.propTypes={left:e.oneOfType([e.number,e.string]),top:e.oneOfType([e.number,e.string]),className:e.string,style:e.object,children:e.any};var i=e.shape({top:e.number.isRequired,right:e.number.isRequired,bottom:e.number.isRequired,left:e.number.isRequired,width:e.number.isRequired,height:e.number.isRequired}),r={getRects:e.func,rect:i,parentRect:i},p={left:e.oneOfType([e.number,e.string]),top:e.oneOfType([e.number,e.string]),className:e.string,style:e.object,children:e.any},a=b({},r,p,{offsetLeft:e.number,offsetTop:e.number});function s(t){var e=t.left,o=t.top,i=t.offsetLeft,n=void 0===i?10:i,r=t.offsetTop,p=void 0===r?10:r,l=t.rect,a=t.parentRect,s=(t.getRects,t.children),u=t.style,f=y(t,["left","top","offsetLeft","offsetTop","rect","parentRect","getRects","children","style"]),c=e,d=o;return l&&a&&(c=n+l.right>a.right||n+l.right>window.innerWidth?c-l.width-n:c+n,d=p+l.bottom>a.bottom||p+l.bottom>window.innerHeight?d-l.height-p:d+p),h.createElement(v,b({style:b({top:0,transform:"translate("+c+"px, "+d+"px)"},u)},f),s)}s.propTypes=a,s.defaultProps={};var u=o.withBoundingRects(s);t.withTooltip=function(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{style:{position:"relative",width:"inherit",height:"inherit"}};return function(t){function o(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o);var e=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,t));return e.state={tooltipOpen:!1,tooltipLeft:void 0,tooltipTop:void 0,tooltipData:void 0},e.updateTooltip=e.updateTooltip.bind(e),e.showTooltip=e.showTooltip.bind(e),e.hideTooltip=e.hideTooltip.bind(e),e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(o,h.PureComponent),n(o,[{key:"updateTooltip",value:function(t){var e=t.tooltipOpen,o=t.tooltipLeft,i=t.tooltipTop,n=t.tooltipData;this.setState(function(t){return b({},t,{tooltipOpen:e,tooltipLeft:o,tooltipTop:i,tooltipData:n})})}},{key:"showTooltip",value:function(t){var e=t.tooltipLeft,o=t.tooltipTop,i=t.tooltipData;this.updateTooltip({tooltipOpen:!0,tooltipLeft:e,tooltipTop:o,tooltipData:i})}},{key:"hideTooltip",value:function(){this.updateTooltip({tooltipOpen:!1,tooltipLeft:void 0,tooltipTop:void 0,tooltipData:void 0})}},{key:"render",value:function(){return h.createElement("div",i,h.createElement(e,b({updateTooltip:this.updateTooltip,showTooltip:this.showTooltip,hideTooltip:this.hideTooltip},this.state,this.props)))}}]),o}()},t.Tooltip=v,t.TooltipWithBounds=u,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "@vx/tooltip", | ||
"version": "0.0.165", | ||
"version": "0.0.179", | ||
"description": "vx tooltip", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
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
31417
512