Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hint

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hint - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

8

lib/index.js

@@ -43,2 +43,3 @@ 'use strict';

if (el.hasAttribute('data-rh')) return el;
if (el === _this._hint) return _this.state.target;
el = el.parentNode;

@@ -102,3 +103,8 @@ }return null;

var target = _ref.target;
return _this.setState({ target: _this.findHint(target) });
clearTimeout(_this.timeout);
_this.timeout = setTimeout(function () {
target = _this.findHint(target);
_this.setState({ target: target });
}, 100);
}, _this.setRef = function (name, ref) {

@@ -105,0 +111,0 @@ return _this[name] = ref;

4

package.json
{
"name": "react-hint",
"version": "1.2.1",
"description": "a simple tooltip component for React",
"version": "1.2.2",
"description": "Tooltip component for React, Preact & Inferno",
"author": "Vladimir Simonov <slmgc@ya.ru>",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/slmgc/react-hint",

@@ -64,2 +64,3 @@ import React from 'react'

if (el.hasAttribute('data-rh')) return el
if (el === this._hint) return this.state.target
el = el.parentNode

@@ -121,4 +122,9 @@ } return null

onHover = ({target}) =>
this.setState({target: this.findHint(target)})
onHover = ({target}) => {
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
target = this.findHint(target)
this.setState({target})
}, 100)
}

@@ -125,0 +131,0 @@ setRef = (name, ref) =>

/*!
* react-hint v1.2.1 - https://github.com/slmgc/react-hint
* react-hint v1.2.2 - https://github.com/slmgc/react-hint
* MIT Licensed

@@ -112,2 +112,3 @@ */

if (el.hasAttribute('data-rh')) return el;
if (el === _this._hint) return _this.state.target;
el = el.parentNode;

@@ -171,3 +172,8 @@ }return null;

var target = _ref.target;
return _this.setState({ target: _this.findHint(target) });
clearTimeout(_this.timeout);
_this.timeout = setTimeout(function () {
target = _this.findHint(target);
_this.setState({ target: target });
}, 100);
}, _this.setRef = function (name, ref) {

@@ -230,3 +236,3 @@ return _this[name] = ref;

fileName: _jsxFileName,
lineNumber: 131
lineNumber: 137
},

@@ -241,3 +247,3 @@ __self: this

fileName: _jsxFileName,
lineNumber: 134
lineNumber: 140
},

@@ -250,3 +256,3 @@ __self: this

fileName: _jsxFileName,
lineNumber: 137
lineNumber: 143
},

@@ -253,0 +259,0 @@ __self: this

/*!
* react-hint v1.2.1 - https://github.com/slmgc/react-hint
* react-hint v1.2.2 - https://github.com/slmgc/react-hint
* MIT Licensed
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactHint=e(require("react")):t.ReactHint=e(t.React)}(this,function(t){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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}function a(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)}e.__esModule=!0,e.default=void 0;var u,c,s=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),f=n(2),l=o(f),p=(c=u=function(t){function e(){var n,o,a;r(this,e);for(var u=arguments.length,c=Array(u),s=0;s<u;s++)c[s]=arguments[s];return n=o=i(this,t.call.apply(t,[this].concat(c))),o.state={target:null,at:"top",top:0,left:0},o.findHint=function(t){for(;t&&t!==document;){if(t.hasAttribute("data-rh"))return t;t=t.parentNode}return null},o.getPosition=function(t){var e=o,n=e._container,r=e._hint,i=n.getBoundingClientRect(),a=i.top,u=i.left,c=r.getBoundingClientRect(),s=c.width,f=c.height,l=t.getBoundingClientRect(),p=l.top,d=l.left,h=l.width,m=l.height,v=void 0,g=void 0,b=t.getAttribute("data-rh-at")||"top";switch(b){case"left":v=m-f>>1,g=-s;break;case"right":v=m-f>>1,g=h;break;case"bottom":v=m,g=h-s>>1;break;case"top":default:v=-f,g=h-s>>1}return{at:b,top:v+p-a,left:g+d-u}},o.onHover=function(t){var e=t.target;return o.setState({target:o.findHint(e)})},o.setRef=function(t,e){return o[t]=e},a=n,i(o,a)}return a(e,t),e.prototype.shouldComponentUpdate=function(t,e){var n=t.className,o=e.target,r=e.at,i=e.top,a=e.left,u=this.props,c=this.state;return o!==c.target||r!==c.at||i!==c.top||a!==c.left||n!==u.className},e.prototype.componentDidMount=function(){e.instance&&(e.instance=null),e.instance=this},e.prototype.componentDidUpdate=function(){var t=this.state.target;if(t){var e=t.getBoundingClientRect(),n=e.top,o=e.left,r=e.width,i=e.height;(n||o||r||i)&&this.setState(this.getPosition(t))}},e.prototype.componentWillUnmount=function(){e.instance=null},e.prototype.render=function(){var t=this.props.className,e=this.state,n=e.target,o=e.at,r=e.top,i=e.left;return l.default.createElement("div",{style:{position:"relative"},ref:this.setRef.bind(this,"_container")},n&&l.default.createElement("div",{className:t+" "+t+"--"+o,ref:this.setRef.bind(this,"_hint"),style:{top:r,left:i}},l.default.createElement("div",{className:t+"__content"},n.getAttribute("data-rh"))))},s(e,null,[{key:"instance",get:function(){return e._instance},set:function(t){t?document.addEventListener("mouseover",t.onHover):document.removeEventListener("mouseover",e.instance.onHover),e._instance=t}}]),e}(l.default.Component),u._instance=null,u.defaultProps={className:"react-hint"},c);e.default=p},function(e,n){e.exports=t}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactHint=e(require("react")):t.ReactHint=e(t.React)}(this,function(t){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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}function a(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)}e.__esModule=!0,e.default=void 0;var u,c,s=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),f=n(2),l=o(f),p=(c=u=function(t){function e(){var n,o,a;r(this,e);for(var u=arguments.length,c=Array(u),s=0;s<u;s++)c[s]=arguments[s];return n=o=i(this,t.call.apply(t,[this].concat(c))),o.state={target:null,at:"top",top:0,left:0},o.findHint=function(t){for(;t&&t!==document;){if(t.hasAttribute("data-rh"))return t;if(t===o._hint)return o.state.target;t=t.parentNode}return null},o.getPosition=function(t){var e=o,n=e._container,r=e._hint,i=n.getBoundingClientRect(),a=i.top,u=i.left,c=r.getBoundingClientRect(),s=c.width,f=c.height,l=t.getBoundingClientRect(),p=l.top,d=l.left,h=l.width,m=l.height,v=void 0,g=void 0,b=t.getAttribute("data-rh-at")||"top";switch(b){case"left":v=m-f>>1,g=-s;break;case"right":v=m-f>>1,g=h;break;case"bottom":v=m,g=h-s>>1;break;case"top":default:v=-f,g=h-s>>1}return{at:b,top:v+p-a,left:g+d-u}},o.onHover=function(t){var e=t.target;clearTimeout(o.timeout),o.timeout=setTimeout(function(){e=o.findHint(e),o.setState({target:e})},100)},o.setRef=function(t,e){return o[t]=e},a=n,i(o,a)}return a(e,t),e.prototype.shouldComponentUpdate=function(t,e){var n=t.className,o=e.target,r=e.at,i=e.top,a=e.left,u=this.props,c=this.state;return o!==c.target||r!==c.at||i!==c.top||a!==c.left||n!==u.className},e.prototype.componentDidMount=function(){e.instance&&(e.instance=null),e.instance=this},e.prototype.componentDidUpdate=function(){var t=this.state.target;if(t){var e=t.getBoundingClientRect(),n=e.top,o=e.left,r=e.width,i=e.height;(n||o||r||i)&&this.setState(this.getPosition(t))}},e.prototype.componentWillUnmount=function(){e.instance=null},e.prototype.render=function(){var t=this.props.className,e=this.state,n=e.target,o=e.at,r=e.top,i=e.left;return l.default.createElement("div",{style:{position:"relative"},ref:this.setRef.bind(this,"_container")},n&&l.default.createElement("div",{className:t+" "+t+"--"+o,ref:this.setRef.bind(this,"_hint"),style:{top:r,left:i}},l.default.createElement("div",{className:t+"__content"},n.getAttribute("data-rh"))))},s(e,null,[{key:"instance",get:function(){return e._instance},set:function(t){t?document.addEventListener("mouseover",t.onHover):document.removeEventListener("mouseover",e.instance.onHover),e._instance=t}}]),e}(l.default.Component),u._instance=null,u.defaultProps={className:"react-hint"},c);e.default=p},function(e,n){e.exports=t}])});
//# sourceMappingURL=react-hint.min.js.map

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc