Socket
Socket
Sign inDemoInstall

@propellerads/smart-tooltip

Package Overview
Dependencies
85
Maintainers
14
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

#### `2.2.0`
* fix eslint rule
#### `2.1.0`

@@ -2,0 +6,0 @@

40

dist/index.esm.js

@@ -333,22 +333,2 @@ import React, { useRef, useState, useEffect } from 'react';

function showTooltip(target, tip, position) {
document.body.appendChild(containerDomNode);
var container = /*#__PURE__*/React.createElement(SmartTooltip, {
tip: tip,
position: position,
targetCoords: getElementCoords(target)
});
ReactDOM.render(container, containerDomNode);
}
function hideTooltip() {
ReactDOM.unmountComponentAtNode(containerDomNode);
if (_toConsumableArray(document.body.children).find(function (child) {
return child === containerDomNode;
})) {
document.body.removeChild(containerDomNode);
}
}
function SmartTooltip(_ref) {

@@ -399,2 +379,22 @@ var tip = _ref.tip,

function showTooltip(target, tip, position) {
document.body.appendChild(containerDomNode);
var container = /*#__PURE__*/React.createElement(SmartTooltip, {
tip: tip,
position: position,
targetCoords: getElementCoords(target)
});
ReactDOM.render(container, containerDomNode);
}
function hideTooltip() {
ReactDOM.unmountComponentAtNode(containerDomNode);
if (_toConsumableArray(document.body.children).find(function (child) {
return child === containerDomNode;
})) {
document.body.removeChild(containerDomNode);
}
}
SmartTooltip.propTypes = {

@@ -401,0 +401,0 @@ tip: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.node]),

@@ -1,1 +0,1 @@

import t,{useRef as n,useState as r,useEffect as e}from"react";import o from"react-dom";import i from"prop-types";import a,{css as p}from"styled-components";import{borderRadius as l,white as f,spacing as d}from"@propellerads/stylevariables";function u(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function c(t,n){if(null==t)return{};var r,e,o=function(t,n){if(null==t)return{};var r,e,o={},i=Object.keys(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||(o[r]=t[r]);return o}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function b(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,o=!1,i=void 0;try{for(var a,p=t[Symbol.iterator]();!(e=(a=p.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==p.return||p.return()}finally{if(o)throw i}}return r}(t,n)||m(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t){return function(t){if(Array.isArray(t))return g(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,n){if(t){if("string"==typeof t)return g(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,n):void 0}}function g(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function x(){var t=s(["\n &::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n left: -8px;\n top: 50%;\n margin-top: -5px;\n }\n \n &::after {\n border-right-color: hsl(0, 0%, 13%);\n border-right-style: solid;\n border-right-width: 6px;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n left: -6px;\n top: 50%;\n margin-top: -4px;\n }\n "]);return x=function(){return t},t}function y(){var t=s(["\n &::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n right: -8px;\n top: 50%;\n margin-top: -5px;\n }\n \n &::after {\n border-left-color: hsl(0, 0%, 13%);\n border-left-style: solid;\n border-left-width: 6px;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n right: -6px;\n top: 50%;\n margin-top: -4px;\n }\n "]);return y=function(){return t},t}function v(){var t=s(["\n &::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n top: -8px;\n left: 50%;\n margin-left: -10px;\n }\n \n &::after {\n border-bottom-color: hsl(0, 0%, 13%);\n border-bottom-style: solid;\n border-bottom-width: 6px;\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n top: -6px;\n left: 50%;\n margin-left: -8px;\n }\n "]);return v=function(){return t},t}function w(){var t=s(["\n &::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n bottom: -8px;\n left: 50%;\n margin-left: -10px;\n }\n \n &::after {\n border-top-color: hsl(0, 0%, 13%);\n border-top-style: solid;\n border-top-width: 6px;\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n bottom: -6px;\n left: 50%;\n margin-left: -8px;\n }\n "]);return w=function(){return t},t}function O(){var t=s(["\n background-color: hsl(0, 0%, 13%);\n border-radius: ","px;\n border-collapse: collapse;\n box-sizing: border-box;\n color: ",";\n display: block;\n font-size: 13px;\n min-height: 36px;\n line-height: 20.8px;\n max-width: 220px;\n opacity: 0.9;\n padding: ",'px;\n pointer-events: none;\n position: fixed;\n text-align: left;\n transition-delay: 0s;\n transition-duration: 0.3s;\n transition-property: opacity;\n transition-timing-function: ease-out;\n visibility: hidden;\n white-space: normal;\n z-index: 3000;\n \n &::after,\n &::before {\n content: "";\n width: 0;\n height: 0;\n position: absolute;\n }\n \n ',"\n \n ","\n \n ","\n \n ","\n"]);return O=function(){return t},t}var T,j,S={TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right"},E=a.div(O(),l,f,2*d,(function(t){return t.position===S.TOP&&p(w())}),(function(t){return t.position===S.BOTTOM&&p(v())}),(function(t){return t.position===S.LEFT&&p(y())}),(function(t){return t.position===S.RIGHT&&p(x())})),I=Object.values(S),A=document.createElement("div");function P(t){var n=t.getBoundingClientRect();return{width:n.width,height:n.height,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}function C(t,n){var r=(t.right-t.left)/2,e=n.width/2,o=t.left+r-e-window.pageXOffset,i=t.top-(n.height+6);return{top:"".concat(i,"px"),left:"".concat(o,"px"),visibility:"visible",place:S.TOP}}var H=(u(T={},S.TOP,C),u(T,S.BOTTOM,(function(t,n){var r=(t.right-t.left)/2,e=n.width/2,o=t.left+r-e-window.pageXOffset,i=t.bottom+6;return{top:"".concat(i,"px"),left:"".concat(o,"px"),visibility:"visible",place:S.BOTTOM}})),u(T,S.LEFT,(function(t,n){var r=t.height/2+t.top-n.height/2,e=t.left-n.width-6;return{top:"".concat(r,"px"),left:"".concat(e,"px"),visibility:"visible",place:S.LEFT}})),u(T,S.RIGHT,(function(t,n){var r=t.height/2+t.top-n.height/2,e=t.right+6;return{top:"".concat(r,"px"),left:"".concat(e,"px"),visibility:"visible",place:S.RIGHT}})),T);function M(t,n){var r=(t.right-t.left)/2,e=t.left+r-window.pageXOffset,o=window.innerWidth-t.right+r,i=e>=n.width/2,a=o>=n.width/2;return i&&a}function B(t,n){var r=t.height/2,e=n.height/2,o=t.top+r>=e,i=window.innerHeight-(t.bottom-r)>=e;return o&&i}var L=(u(j={},S.TOP,(function(t,n){return n.height+6<=t.top&&M(t,n)})),u(j,S.BOTTOM,(function(t,n){return n.height+6<=window.innerHeight-t.bottom&&M(t,n)})),u(j,S.LEFT,(function(t,n){return n.width+6<=t.left-window.pageXOffset&&B(t,n)})),u(j,S.RIGHT,(function(t,n){return n.width+6<=window.innerWidth-t.right&&B(t,n)})),j);function R(n,r,e){document.body.appendChild(A);var i=t.createElement(F,{tip:r,position:e,targetCoords:P(n)});o.render(i,A)}function z(){o.unmountComponentAtNode(A),h(document.body.children).find((function(t){return t===A}))&&document.body.removeChild(A)}function F(o){var i,a=o.tip,p=o.targetCoords,l=o.position,f=n(null),d=b(r({}),2),u=d[0],s=d[1],h=b(r(l),2),m=h[0],g=h[1];return e((function(){if(f&&f.current){var t=P(f.current),n=function(t,n,r){if(r&&I.includes(r))return H[r](t,n);var e=I.filter((function(r){return L[r](t,n)}));return e&&e.length>0?H[e[0]](t,n):C(t,n)}(p,t,l),r=n.place,e=c(n,["place"]);s(e),g(r)}}),[a]),a?t.createElement(E,{ref:f,style:u,id:"smart-tooltip",position:m},(i=a,"String"===Object.prototype.toString.call(i).slice(8,-1)?t.createElement("div",{dangerouslySetInnerHTML:{__html:a}}):a)):null}F.propTypes={tip:i.oneOfType([i.string,i.element,i.node]),targetCoords:i.shape({width:i.number,top:i.number,bottom:i.number,left:i.number,right:i.number}),position:i.oneOf(I)},F.defaultProps={tip:void 0,targetCoords:{},position:void 0};export{S as TOOLTIP_POSITION,z as hideTooltip,R as showTooltip};
import t,{useRef as n,useState as r,useEffect as e}from"react";import o from"react-dom";import i from"prop-types";import a,{css as p}from"styled-components";import{borderRadius as l,white as f,spacing as d}from"@propellerads/stylevariables";function u(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function c(t,n){if(null==t)return{};var r,e,o=function(t,n){if(null==t)return{};var r,e,o={},i=Object.keys(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||(o[r]=t[r]);return o}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function b(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,o=!1,i=void 0;try{for(var a,p=t[Symbol.iterator]();!(e=(a=p.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==p.return||p.return()}finally{if(o)throw i}}return r}(t,n)||m(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t){return function(t){if(Array.isArray(t))return g(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,n){if(t){if("string"==typeof t)return g(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,n):void 0}}function g(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function x(){var t=s(["\n &::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n left: -8px;\n top: 50%;\n margin-top: -5px;\n }\n \n &::after {\n border-right-color: hsl(0, 0%, 13%);\n border-right-style: solid;\n border-right-width: 6px;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n left: -6px;\n top: 50%;\n margin-top: -4px;\n }\n "]);return x=function(){return t},t}function y(){var t=s(["\n &::before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n right: -8px;\n top: 50%;\n margin-top: -5px;\n }\n \n &::after {\n border-left-color: hsl(0, 0%, 13%);\n border-left-style: solid;\n border-left-width: 6px;\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n right: -6px;\n top: 50%;\n margin-top: -4px;\n }\n "]);return y=function(){return t},t}function v(){var t=s(["\n &::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n top: -8px;\n left: 50%;\n margin-left: -10px;\n }\n \n &::after {\n border-bottom-color: hsl(0, 0%, 13%);\n border-bottom-style: solid;\n border-bottom-width: 6px;\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n top: -6px;\n left: 50%;\n margin-left: -8px;\n }\n "]);return v=function(){return t},t}function w(){var t=s(["\n &::before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n bottom: -8px;\n left: 50%;\n margin-left: -10px;\n }\n \n &::after {\n border-top-color: hsl(0, 0%, 13%);\n border-top-style: solid;\n border-top-width: 6px;\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n bottom: -6px;\n left: 50%;\n margin-left: -8px;\n }\n "]);return w=function(){return t},t}function O(){var t=s(["\n background-color: hsl(0, 0%, 13%);\n border-radius: ","px;\n border-collapse: collapse;\n box-sizing: border-box;\n color: ",";\n display: block;\n font-size: 13px;\n min-height: 36px;\n line-height: 20.8px;\n max-width: 220px;\n opacity: 0.9;\n padding: ",'px;\n pointer-events: none;\n position: fixed;\n text-align: left;\n transition-delay: 0s;\n transition-duration: 0.3s;\n transition-property: opacity;\n transition-timing-function: ease-out;\n visibility: hidden;\n white-space: normal;\n z-index: 3000;\n \n &::after,\n &::before {\n content: "";\n width: 0;\n height: 0;\n position: absolute;\n }\n \n ',"\n \n ","\n \n ","\n \n ","\n"]);return O=function(){return t},t}var T,j,S={TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right"},E=a.div(O(),l,f,2*d,(function(t){return t.position===S.TOP&&p(w())}),(function(t){return t.position===S.BOTTOM&&p(v())}),(function(t){return t.position===S.LEFT&&p(y())}),(function(t){return t.position===S.RIGHT&&p(x())})),I=Object.values(S),A=document.createElement("div");function P(t){var n=t.getBoundingClientRect();return{width:n.width,height:n.height,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}function C(t,n){var r=(t.right-t.left)/2,e=n.width/2,o=t.left+r-e-window.pageXOffset,i=t.top-(n.height+6);return{top:"".concat(i,"px"),left:"".concat(o,"px"),visibility:"visible",place:S.TOP}}var H=(u(T={},S.TOP,C),u(T,S.BOTTOM,(function(t,n){var r=(t.right-t.left)/2,e=n.width/2,o=t.left+r-e-window.pageXOffset,i=t.bottom+6;return{top:"".concat(i,"px"),left:"".concat(o,"px"),visibility:"visible",place:S.BOTTOM}})),u(T,S.LEFT,(function(t,n){var r=t.height/2+t.top-n.height/2,e=t.left-n.width-6;return{top:"".concat(r,"px"),left:"".concat(e,"px"),visibility:"visible",place:S.LEFT}})),u(T,S.RIGHT,(function(t,n){var r=t.height/2+t.top-n.height/2,e=t.right+6;return{top:"".concat(r,"px"),left:"".concat(e,"px"),visibility:"visible",place:S.RIGHT}})),T);function M(t,n){var r=(t.right-t.left)/2,e=t.left+r-window.pageXOffset,o=window.innerWidth-t.right+r,i=e>=n.width/2,a=o>=n.width/2;return i&&a}function B(t,n){var r=t.height/2,e=n.height/2,o=t.top+r>=e,i=window.innerHeight-(t.bottom-r)>=e;return o&&i}var L=(u(j={},S.TOP,(function(t,n){return n.height+6<=t.top&&M(t,n)})),u(j,S.BOTTOM,(function(t,n){return n.height+6<=window.innerHeight-t.bottom&&M(t,n)})),u(j,S.LEFT,(function(t,n){return n.width+6<=t.left-window.pageXOffset&&B(t,n)})),u(j,S.RIGHT,(function(t,n){return n.width+6<=window.innerWidth-t.right&&B(t,n)})),j);function R(o){var i,a=o.tip,p=o.targetCoords,l=o.position,f=n(null),d=b(r({}),2),u=d[0],s=d[1],h=b(r(l),2),m=h[0],g=h[1];return e((function(){if(f&&f.current){var t=P(f.current),n=function(t,n,r){if(r&&I.includes(r))return H[r](t,n);var e=I.filter((function(r){return L[r](t,n)}));return e&&e.length>0?H[e[0]](t,n):C(t,n)}(p,t,l),r=n.place,e=c(n,["place"]);s(e),g(r)}}),[a]),a?t.createElement(E,{ref:f,style:u,id:"smart-tooltip",position:m},(i=a,"String"===Object.prototype.toString.call(i).slice(8,-1)?t.createElement("div",{dangerouslySetInnerHTML:{__html:a}}):a)):null}function z(n,r,e){document.body.appendChild(A);var i=t.createElement(R,{tip:r,position:e,targetCoords:P(n)});o.render(i,A)}function F(){o.unmountComponentAtNode(A),h(document.body.children).find((function(t){return t===A}))&&document.body.removeChild(A)}R.propTypes={tip:i.oneOfType([i.string,i.element,i.node]),targetCoords:i.shape({width:i.number,top:i.number,bottom:i.number,left:i.number,right:i.number}),position:i.oneOf(I)},R.defaultProps={tip:void 0,targetCoords:{},position:void 0};export{S as TOOLTIP_POSITION,F as hideTooltip,z as showTooltip};
{
"name": "@propellerads/smart-tooltip",
"version": "2.1.0",
"version": "2.2.0",
"main": "dist/index.esm.js",

@@ -21,3 +21,7 @@ "module": "dist/index.esm.js",

"dependencies": {
"@propellerads/stylevariables": "^1.3.0"
"@propellerads/stylevariables": "^1.3.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"styled-components": "^5.1.1"
},

@@ -30,8 +34,7 @@ "devDependencies": {

"@babel/preset-react": "^7.10.1",
"react": "^16.13.1",
"rollup": "^2.16.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^6.1.0",
"styled-components": "^5.1.1"
}
"rollup-plugin-terser": "^6.1.0"
},
"gitHead": "83490e6753386e8daf51452f8c5ee4a1fd764585"
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc