New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-tooltip

Package Overview
Dependencies
Maintainers
6
Versions
347
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tooltip - npm Package Compare versions

Comparing version 5.21.6 to 5.21.7-beta.1110.0

2

dist/react-tooltip.umd.js

@@ -811,3 +811,3 @@

setAnchorsBySelect((anchors) => [
...anchors.filter((anchor) => removedAnchors.includes(anchor)),
...anchors.filter((anchor) => !removedAnchors.includes(anchor)),
...newAnchors,

@@ -814,0 +814,0 @@ ]);

@@ -7,3 +7,3 @@ /*

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@floating-ui/dom"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/dom","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactTooltip={},e.React,e.FloatingUIDOM,e.classNames)}(this,(function(e,t,o,r){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=l(t),s=l(r);const c="react-tooltip-core-styles",i="react-tooltip-base-styles",a={core:!1,base:!1};function u({css:e,id:t=i,type:o="base",ref:r}){var l,n;if(!e||"undefined"==typeof document||a[o])return;if("core"===o&&"undefined"!=typeof process&&(null===(l=null===process||void 0===process?void 0:process.env)||void 0===l?void 0:l.REACT_TOOLTIP_DISABLE_CORE_STYLES))return;if("base"!==o&&"undefined"!=typeof process&&(null===(n=null===process||void 0===process?void 0:process.env)||void 0===n?void 0:n.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;"core"===o&&(t=c),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return void console.warn(`[react-tooltip] Element with id '${t}' already exists. Call \`removeStyle()\` first`);const u=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.id=t,d.type="text/css","top"===s&&u.firstChild?u.insertBefore(d,u.firstChild):u.appendChild(d),d.styleSheet?d.styleSheet.cssText=e:d.appendChild(document.createTextNode(e)),a[o]=!0}const d=(e,t,o)=>{let r=null;return function(...l){const n=()=>{r=null,o||e.apply(this,l)};o&&!r&&(e.apply(this,l),r=setTimeout(n,t)),o||(r&&clearTimeout(r),r=setTimeout(n,t))}},p="DEFAULT_TOOLTIP_ID",f={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},v={getTooltipData:()=>f},m=t.createContext(v);function y(e=p){return t.useContext(m).getTooltipData(e)}const h="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,w=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((e=>{const o=t.getPropertyValue(e);return"auto"===o||"scroll"===o}))},S=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(w(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},E=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:r=null,place:l="top",offset:n=10,strategy:s="absolute",middlewares:c=[o.offset(Number(n)),o.flip(),o.shift({padding:5})],border:i})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};if(null===t)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};const a=c;return r?(a.push(o.arrow({element:r,padding:5})),o.computePosition(e,t,{placement:l,strategy:s,middleware:a}).then((({x:e,y:t,placement:o,middlewareData:r})=>{var l,n;const s={left:`${e}px`,top:`${t}px`,border:i},{x:c,y:a}=null!==(l=r.arrow)&&void 0!==l?l:{x:0,y:0},u=null!==(n={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]])&&void 0!==n?n:"bottom",d=i&&{borderBottom:i,borderRight:i};let p=0;if(i){const e=`${i}`.match(/(\d+)px/);p=(null==e?void 0:e[1])?Number(e[1]):1}return{tooltipStyles:s,tooltipArrowStyles:{left:null!=c?`${c}px`:"",top:null!=a?`${a}px`:"",right:"",bottom:"",...d,[u]:`-${4+p}px`},place:o}}))):o.computePosition(e,t,{placement:"bottom",strategy:s,middleware:a}).then((({x:e,y:t,placement:o})=>({tooltipStyles:{left:`${e}px`,top:`${t}px`},tooltipArrowStyles:{},place:o})))};var b="core-styles-module_tooltip__3vRRp",g="core-styles-module_fixed__pcSol",_="core-styles-module_arrow__cvMwQ",A="core-styles-module_noArrow__xock6",T="core-styles-module_clickable__ZuTTB",R="core-styles-module_show__Nt9eE",O={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const L=({id:e,className:r,classNameArrow:l,variant:c="dark",anchorId:i,anchorSelect:a,place:u="top",offset:p=10,events:f=["hover"],openOnClick:v=!1,positionStrategy:m="absolute",middlewares:w,wrapper:L,delayShow:C=0,delayHide:x=0,float:k=!1,hidden:N=!1,noArrow:$=!1,clickable:I=!1,closeOnEsc:j=!1,closeOnScroll:B=!1,closeOnResize:D=!1,style:q,position:H,afterShow:M,afterHide:z,content:P,contentWrapperRef:W,isOpen:U,setIsOpen:F,activeAnchor:K,setActiveAnchor:X,border:Y,opacity:V,arrowColor:Z})=>{const G=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),ee=t.useRef(null),[te,oe]=t.useState(u),[re,le]=t.useState({}),[ne,se]=t.useState({}),[ce,ie]=t.useState(!1),[ae,ue]=t.useState(!1),de=t.useRef(!1),pe=t.useRef(null),{anchorRefs:fe,setActiveAnchor:ve}=y(e),me=t.useRef(!1),[ye,he]=t.useState([]),we=t.useRef(!1),Se=v||f.includes("click");h((()=>(we.current=!0,()=>{we.current=!1})),[]),t.useEffect((()=>{if(!ce){const e=setTimeout((()=>{ue(!1)}),150);return()=>{clearTimeout(e)}}return()=>null}),[ce]);const Ee=e=>{we.current&&(e&&ue(!0),setTimeout((()=>{we.current&&(null==F||F(e),void 0===U&&ie(e))}),10))};t.useEffect((()=>{if(void 0===U)return()=>null;U&&ue(!0);const e=setTimeout((()=>{ie(U)}),10);return()=>{clearTimeout(e)}}),[U]),t.useEffect((()=>{ce!==de.current&&(de.current=ce,ce?null==M||M():null==z||z())}),[ce]);const be=(e=x)=>{ee.current&&clearTimeout(ee.current),ee.current=setTimeout((()=>{me.current||Ee(!1)}),e)},ge=e=>{var t;if(!e)return;const o=null!==(t=e.currentTarget)&&void 0!==t?t:e.target;if(!(null==o?void 0:o.isConnected))return X(null),void ve({current:null});C?(Q.current&&clearTimeout(Q.current),Q.current=setTimeout((()=>{Ee(!0)}),C)):Ee(!0),X(o),ve({current:o}),ee.current&&clearTimeout(ee.current)},_e=()=>{I?be(x||100):x?be():Ee(!1),Q.current&&clearTimeout(Q.current)},Ae=({x:e,y:t})=>{E({place:u,offset:p,elementReference:{getBoundingClientRect:()=>({x:e,y:t,width:0,height:0,top:t,left:e,right:e,bottom:t})},tooltipReference:G.current,tooltipArrowReference:J.current,strategy:m,middlewares:w,border:Y}).then((e=>{Object.keys(e.tooltipStyles).length&&le(e.tooltipStyles),Object.keys(e.tooltipArrowStyles).length&&se(e.tooltipArrowStyles),oe(e.place)}))},Te=e=>{if(!e)return;const t=e,o={x:t.clientX,y:t.clientY};Ae(o),pe.current=o},Re=e=>{ge(e),x&&be()},Oe=e=>{var t;[document.querySelector(`[id='${i}']`),...ye].some((t=>null==t?void 0:t.contains(e.target)))||(null===(t=G.current)||void 0===t?void 0:t.contains(e.target))||(Ee(!1),Q.current&&clearTimeout(Q.current))},Le=d(ge,50,!0),Ce=d(_e,50,!0),xe=t.useCallback((()=>{H?Ae(H):k?pe.current&&Ae(pe.current):(null==K?void 0:K.isConnected)&&E({place:u,offset:p,elementReference:K,tooltipReference:G.current,tooltipArrowReference:J.current,strategy:m,middlewares:w,border:Y}).then((e=>{we.current&&(Object.keys(e.tooltipStyles).length&&le(e.tooltipStyles),Object.keys(e.tooltipArrowStyles).length&&se(e.tooltipArrowStyles),oe(e.place))}))}),[ce,K,P,q,u,p,m,H,k]);t.useEffect((()=>{var e,t;const r=new Set(fe);ye.forEach((e=>{r.add({current:e})}));const l=document.querySelector(`[id='${i}']`);l&&r.add({current:l});const n=()=>{Ee(!1)},s=S(K),c=S(G.current);B&&(window.addEventListener("scroll",n),null==s||s.addEventListener("scroll",n),null==c||c.addEventListener("scroll",n));let a=null;D?window.addEventListener("resize",n):K&&G.current&&(a=o.autoUpdate(K,G.current,xe,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const u=e=>{"Escape"===e.key&&Ee(!1)};j&&window.addEventListener("keydown",u);const d=[];Se?(window.addEventListener("click",Oe),d.push({event:"click",listener:Re})):(d.push({event:"mouseenter",listener:Le},{event:"mouseleave",listener:Ce},{event:"focus",listener:Le},{event:"blur",listener:Ce}),k&&d.push({event:"mousemove",listener:Te}));const p=()=>{me.current=!0},f=()=>{me.current=!1,_e()};return I&&!Se&&(null===(e=G.current)||void 0===e||e.addEventListener("mouseenter",p),null===(t=G.current)||void 0===t||t.addEventListener("mouseleave",f)),d.forEach((({event:e,listener:t})=>{r.forEach((o=>{var r;null===(r=o.current)||void 0===r||r.addEventListener(e,t)}))})),()=>{var e,t;B&&(window.removeEventListener("scroll",n),null==s||s.removeEventListener("scroll",n),null==c||c.removeEventListener("scroll",n)),D?window.removeEventListener("resize",n):null==a||a(),Se&&window.removeEventListener("click",Oe),j&&window.removeEventListener("keydown",u),I&&!Se&&(null===(e=G.current)||void 0===e||e.removeEventListener("mouseenter",p),null===(t=G.current)||void 0===t||t.removeEventListener("mouseleave",f)),d.forEach((({event:e,listener:t})=>{r.forEach((o=>{var r;null===(r=o.current)||void 0===r||r.removeEventListener(e,t)}))}))}}),[K,xe,ae,fe,ye,j,f]),t.useEffect((()=>{let t=null!=a?a:"";!t&&e&&(t=`[data-tooltip-id='${e}']`);const o=new MutationObserver((o=>{const r=[],l=[];o.forEach((o=>{if("attributes"===o.type&&"data-tooltip-id"===o.attributeName){o.target.getAttribute("data-tooltip-id")===e&&r.push(o.target)}if("childList"===o.type){if(K){const e=[...o.removedNodes].filter((e=>1===e.nodeType));if(t)try{l.push(...e.filter((e=>e.matches(t)))),l.push(...e.flatMap((e=>[...e.querySelectorAll(t)])))}catch(e){}e.some((e=>{var t;return!!(null===(t=null==e?void 0:e.contains)||void 0===t?void 0:t.call(e,K))&&(ue(!1),Ee(!1),X(null),Q.current&&clearTimeout(Q.current),ee.current&&clearTimeout(ee.current),!0)}))}if(t)try{const e=[...o.addedNodes].filter((e=>1===e.nodeType));r.push(...e.filter((e=>e.matches(t)))),r.push(...e.flatMap((e=>[...e.querySelectorAll(t)])))}catch(e){}}})),(r.length||l.length)&&he((e=>[...e.filter((e=>l.includes(e))),...r]))}));return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"]}),()=>{o.disconnect()}}),[e,a,K]),t.useEffect((()=>{xe()}),[xe]),t.useEffect((()=>{if(!(null==W?void 0:W.current))return()=>null;const e=new ResizeObserver((()=>{xe()}));return e.observe(W.current),()=>{e.disconnect()}}),[P,null==W?void 0:W.current]),t.useEffect((()=>{var e;const t=document.querySelector(`[id='${i}']`),o=[...ye,t];K&&o.includes(K)||X(null!==(e=ye[0])&&void 0!==e?e:t)}),[i,ye,K]),t.useEffect((()=>()=>{Q.current&&clearTimeout(Q.current),ee.current&&clearTimeout(ee.current)}),[]),t.useEffect((()=>{let t=a;if(!t&&e&&(t=`[data-tooltip-id='${e}']`),t)try{const e=Array.from(document.querySelectorAll(t));he(e)}catch(e){he([])}}),[e,a]);const ke=!N&&P&&ce&&Object.keys(re).length>0;return ae?n.default.createElement(L,{id:e,role:"tooltip",className:s.default("react-tooltip",b,O.tooltip,O[c],r,`react-tooltip__place-${te}`,{"react-tooltip__show":ke,[R]:ke,[g]:"fixed"===m,[T]:I}),style:{...q,...re,opacity:void 0!==V&&ke?V:void 0},ref:G},P,n.default.createElement(L,{className:s.default("react-tooltip-arrow",_,O.arrow,l,{[A]:$}),style:{...ne,background:Z?`linear-gradient(to right bottom, transparent 50%, ${Z} 50%)`:void 0},ref:J})):null},C=({content:e})=>n.default.createElement("span",{dangerouslySetInnerHTML:{__html:e}});"undefined"!=typeof window&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||u({css:`:root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9}.core-styles-module_tooltip__3vRRp{visibility:hidden;position:absolute;top:0;left:0;pointer-events:none;opacity:0;transition:opacity 0.3s ease-out;will-change:opacity,visibility}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{visibility:visible;opacity:var(--rt-opacity)}`,type:"core"}),e.detail.disableBase||u({css:`
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@floating-ui/dom"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/dom","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactTooltip={},e.React,e.FloatingUIDOM,e.classNames)}(this,(function(e,t,o,r){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=l(t),s=l(r);const c="react-tooltip-core-styles",i="react-tooltip-base-styles",a={core:!1,base:!1};function u({css:e,id:t=i,type:o="base",ref:r}){var l,n;if(!e||"undefined"==typeof document||a[o])return;if("core"===o&&"undefined"!=typeof process&&(null===(l=null===process||void 0===process?void 0:process.env)||void 0===l?void 0:l.REACT_TOOLTIP_DISABLE_CORE_STYLES))return;if("base"!==o&&"undefined"!=typeof process&&(null===(n=null===process||void 0===process?void 0:process.env)||void 0===n?void 0:n.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;"core"===o&&(t=c),r||(r={});const{insertAt:s}=r;if(document.getElementById(t))return void console.warn(`[react-tooltip] Element with id '${t}' already exists. Call \`removeStyle()\` first`);const u=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.id=t,d.type="text/css","top"===s&&u.firstChild?u.insertBefore(d,u.firstChild):u.appendChild(d),d.styleSheet?d.styleSheet.cssText=e:d.appendChild(document.createTextNode(e)),a[o]=!0}const d=(e,t,o)=>{let r=null;return function(...l){const n=()=>{r=null,o||e.apply(this,l)};o&&!r&&(e.apply(this,l),r=setTimeout(n,t)),o||(r&&clearTimeout(r),r=setTimeout(n,t))}},p="DEFAULT_TOOLTIP_ID",f={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},v={getTooltipData:()=>f},m=t.createContext(v);function y(e=p){return t.useContext(m).getTooltipData(e)}const h="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,w=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((e=>{const o=t.getPropertyValue(e);return"auto"===o||"scroll"===o}))},S=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(w(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},E=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:r=null,place:l="top",offset:n=10,strategy:s="absolute",middlewares:c=[o.offset(Number(n)),o.flip(),o.shift({padding:5})],border:i})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};if(null===t)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};const a=c;return r?(a.push(o.arrow({element:r,padding:5})),o.computePosition(e,t,{placement:l,strategy:s,middleware:a}).then((({x:e,y:t,placement:o,middlewareData:r})=>{var l,n;const s={left:`${e}px`,top:`${t}px`,border:i},{x:c,y:a}=null!==(l=r.arrow)&&void 0!==l?l:{x:0,y:0},u=null!==(n={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]])&&void 0!==n?n:"bottom",d=i&&{borderBottom:i,borderRight:i};let p=0;if(i){const e=`${i}`.match(/(\d+)px/);p=(null==e?void 0:e[1])?Number(e[1]):1}return{tooltipStyles:s,tooltipArrowStyles:{left:null!=c?`${c}px`:"",top:null!=a?`${a}px`:"",right:"",bottom:"",...d,[u]:`-${4+p}px`},place:o}}))):o.computePosition(e,t,{placement:"bottom",strategy:s,middleware:a}).then((({x:e,y:t,placement:o})=>({tooltipStyles:{left:`${e}px`,top:`${t}px`},tooltipArrowStyles:{},place:o})))};var b="core-styles-module_tooltip__3vRRp",g="core-styles-module_fixed__pcSol",_="core-styles-module_arrow__cvMwQ",A="core-styles-module_noArrow__xock6",T="core-styles-module_clickable__ZuTTB",R="core-styles-module_show__Nt9eE",O={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const L=({id:e,className:r,classNameArrow:l,variant:c="dark",anchorId:i,anchorSelect:a,place:u="top",offset:p=10,events:f=["hover"],openOnClick:v=!1,positionStrategy:m="absolute",middlewares:w,wrapper:L,delayShow:C=0,delayHide:x=0,float:k=!1,hidden:N=!1,noArrow:$=!1,clickable:I=!1,closeOnEsc:j=!1,closeOnScroll:B=!1,closeOnResize:D=!1,style:q,position:H,afterShow:M,afterHide:z,content:P,contentWrapperRef:W,isOpen:U,setIsOpen:F,activeAnchor:K,setActiveAnchor:X,border:Y,opacity:V,arrowColor:Z})=>{const G=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),ee=t.useRef(null),[te,oe]=t.useState(u),[re,le]=t.useState({}),[ne,se]=t.useState({}),[ce,ie]=t.useState(!1),[ae,ue]=t.useState(!1),de=t.useRef(!1),pe=t.useRef(null),{anchorRefs:fe,setActiveAnchor:ve}=y(e),me=t.useRef(!1),[ye,he]=t.useState([]),we=t.useRef(!1),Se=v||f.includes("click");h((()=>(we.current=!0,()=>{we.current=!1})),[]),t.useEffect((()=>{if(!ce){const e=setTimeout((()=>{ue(!1)}),150);return()=>{clearTimeout(e)}}return()=>null}),[ce]);const Ee=e=>{we.current&&(e&&ue(!0),setTimeout((()=>{we.current&&(null==F||F(e),void 0===U&&ie(e))}),10))};t.useEffect((()=>{if(void 0===U)return()=>null;U&&ue(!0);const e=setTimeout((()=>{ie(U)}),10);return()=>{clearTimeout(e)}}),[U]),t.useEffect((()=>{ce!==de.current&&(de.current=ce,ce?null==M||M():null==z||z())}),[ce]);const be=(e=x)=>{ee.current&&clearTimeout(ee.current),ee.current=setTimeout((()=>{me.current||Ee(!1)}),e)},ge=e=>{var t;if(!e)return;const o=null!==(t=e.currentTarget)&&void 0!==t?t:e.target;if(!(null==o?void 0:o.isConnected))return X(null),void ve({current:null});C?(Q.current&&clearTimeout(Q.current),Q.current=setTimeout((()=>{Ee(!0)}),C)):Ee(!0),X(o),ve({current:o}),ee.current&&clearTimeout(ee.current)},_e=()=>{I?be(x||100):x?be():Ee(!1),Q.current&&clearTimeout(Q.current)},Ae=({x:e,y:t})=>{E({place:u,offset:p,elementReference:{getBoundingClientRect:()=>({x:e,y:t,width:0,height:0,top:t,left:e,right:e,bottom:t})},tooltipReference:G.current,tooltipArrowReference:J.current,strategy:m,middlewares:w,border:Y}).then((e=>{Object.keys(e.tooltipStyles).length&&le(e.tooltipStyles),Object.keys(e.tooltipArrowStyles).length&&se(e.tooltipArrowStyles),oe(e.place)}))},Te=e=>{if(!e)return;const t=e,o={x:t.clientX,y:t.clientY};Ae(o),pe.current=o},Re=e=>{ge(e),x&&be()},Oe=e=>{var t;[document.querySelector(`[id='${i}']`),...ye].some((t=>null==t?void 0:t.contains(e.target)))||(null===(t=G.current)||void 0===t?void 0:t.contains(e.target))||(Ee(!1),Q.current&&clearTimeout(Q.current))},Le=d(ge,50,!0),Ce=d(_e,50,!0),xe=t.useCallback((()=>{H?Ae(H):k?pe.current&&Ae(pe.current):(null==K?void 0:K.isConnected)&&E({place:u,offset:p,elementReference:K,tooltipReference:G.current,tooltipArrowReference:J.current,strategy:m,middlewares:w,border:Y}).then((e=>{we.current&&(Object.keys(e.tooltipStyles).length&&le(e.tooltipStyles),Object.keys(e.tooltipArrowStyles).length&&se(e.tooltipArrowStyles),oe(e.place))}))}),[ce,K,P,q,u,p,m,H,k]);t.useEffect((()=>{var e,t;const r=new Set(fe);ye.forEach((e=>{r.add({current:e})}));const l=document.querySelector(`[id='${i}']`);l&&r.add({current:l});const n=()=>{Ee(!1)},s=S(K),c=S(G.current);B&&(window.addEventListener("scroll",n),null==s||s.addEventListener("scroll",n),null==c||c.addEventListener("scroll",n));let a=null;D?window.addEventListener("resize",n):K&&G.current&&(a=o.autoUpdate(K,G.current,xe,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const u=e=>{"Escape"===e.key&&Ee(!1)};j&&window.addEventListener("keydown",u);const d=[];Se?(window.addEventListener("click",Oe),d.push({event:"click",listener:Re})):(d.push({event:"mouseenter",listener:Le},{event:"mouseleave",listener:Ce},{event:"focus",listener:Le},{event:"blur",listener:Ce}),k&&d.push({event:"mousemove",listener:Te}));const p=()=>{me.current=!0},f=()=>{me.current=!1,_e()};return I&&!Se&&(null===(e=G.current)||void 0===e||e.addEventListener("mouseenter",p),null===(t=G.current)||void 0===t||t.addEventListener("mouseleave",f)),d.forEach((({event:e,listener:t})=>{r.forEach((o=>{var r;null===(r=o.current)||void 0===r||r.addEventListener(e,t)}))})),()=>{var e,t;B&&(window.removeEventListener("scroll",n),null==s||s.removeEventListener("scroll",n),null==c||c.removeEventListener("scroll",n)),D?window.removeEventListener("resize",n):null==a||a(),Se&&window.removeEventListener("click",Oe),j&&window.removeEventListener("keydown",u),I&&!Se&&(null===(e=G.current)||void 0===e||e.removeEventListener("mouseenter",p),null===(t=G.current)||void 0===t||t.removeEventListener("mouseleave",f)),d.forEach((({event:e,listener:t})=>{r.forEach((o=>{var r;null===(r=o.current)||void 0===r||r.removeEventListener(e,t)}))}))}}),[K,xe,ae,fe,ye,j,f]),t.useEffect((()=>{let t=null!=a?a:"";!t&&e&&(t=`[data-tooltip-id='${e}']`);const o=new MutationObserver((o=>{const r=[],l=[];o.forEach((o=>{if("attributes"===o.type&&"data-tooltip-id"===o.attributeName){o.target.getAttribute("data-tooltip-id")===e&&r.push(o.target)}if("childList"===o.type){if(K){const e=[...o.removedNodes].filter((e=>1===e.nodeType));if(t)try{l.push(...e.filter((e=>e.matches(t)))),l.push(...e.flatMap((e=>[...e.querySelectorAll(t)])))}catch(e){}e.some((e=>{var t;return!!(null===(t=null==e?void 0:e.contains)||void 0===t?void 0:t.call(e,K))&&(ue(!1),Ee(!1),X(null),Q.current&&clearTimeout(Q.current),ee.current&&clearTimeout(ee.current),!0)}))}if(t)try{const e=[...o.addedNodes].filter((e=>1===e.nodeType));r.push(...e.filter((e=>e.matches(t)))),r.push(...e.flatMap((e=>[...e.querySelectorAll(t)])))}catch(e){}}})),(r.length||l.length)&&he((e=>[...e.filter((e=>!l.includes(e))),...r]))}));return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"]}),()=>{o.disconnect()}}),[e,a,K]),t.useEffect((()=>{xe()}),[xe]),t.useEffect((()=>{if(!(null==W?void 0:W.current))return()=>null;const e=new ResizeObserver((()=>{xe()}));return e.observe(W.current),()=>{e.disconnect()}}),[P,null==W?void 0:W.current]),t.useEffect((()=>{var e;const t=document.querySelector(`[id='${i}']`),o=[...ye,t];K&&o.includes(K)||X(null!==(e=ye[0])&&void 0!==e?e:t)}),[i,ye,K]),t.useEffect((()=>()=>{Q.current&&clearTimeout(Q.current),ee.current&&clearTimeout(ee.current)}),[]),t.useEffect((()=>{let t=a;if(!t&&e&&(t=`[data-tooltip-id='${e}']`),t)try{const e=Array.from(document.querySelectorAll(t));he(e)}catch(e){he([])}}),[e,a]);const ke=!N&&P&&ce&&Object.keys(re).length>0;return ae?n.default.createElement(L,{id:e,role:"tooltip",className:s.default("react-tooltip",b,O.tooltip,O[c],r,`react-tooltip__place-${te}`,{"react-tooltip__show":ke,[R]:ke,[g]:"fixed"===m,[T]:I}),style:{...q,...re,opacity:void 0!==V&&ke?V:void 0},ref:G},P,n.default.createElement(L,{className:s.default("react-tooltip-arrow",_,O.arrow,l,{[A]:$}),style:{...ne,background:Z?`linear-gradient(to right bottom, transparent 50%, ${Z} 50%)`:void 0},ref:J})):null},C=({content:e})=>n.default.createElement("span",{dangerouslySetInnerHTML:{__html:e}});"undefined"!=typeof window&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||u({css:`:root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9}.core-styles-module_tooltip__3vRRp{visibility:hidden;position:absolute;top:0;left:0;pointer-events:none;opacity:0;transition:opacity 0.3s ease-out;will-change:opacity,visibility}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{visibility:visible;opacity:var(--rt-opacity)}`,type:"core"}),e.detail.disableBase||u({css:`
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:8px;height:8px}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})})),e.Tooltip=({id:e,anchorId:o,anchorSelect:r,content:l,html:s,render:c,className:i,classNameArrow:a,variant:u="dark",place:d="top",offset:p=10,wrapper:f="div",children:v=null,events:m=["hover"],openOnClick:h=!1,positionStrategy:w="absolute",middlewares:S,delayShow:E=0,delayHide:b=0,float:g=!1,hidden:_=!1,noArrow:A=!1,clickable:T=!1,closeOnEsc:R=!1,closeOnScroll:O=!1,closeOnResize:x=!1,style:k,position:N,isOpen:$,disableStyleInjection:I=!1,border:j,opacity:B,arrowColor:D,setIsOpen:q,afterShow:H,afterHide:M})=>{const[z,P]=t.useState(l),[W,U]=t.useState(s),[F,K]=t.useState(d),[X,Y]=t.useState(u),[V,Z]=t.useState(p),[G,J]=t.useState(E),[Q,ee]=t.useState(b),[te,oe]=t.useState(g),[re,le]=t.useState(_),[ne,se]=t.useState(f),[ce,ie]=t.useState(m),[ae,ue]=t.useState(w),[de,pe]=t.useState(null),fe=t.useRef(I),{anchorRefs:ve,activeAnchor:me}=y(e),ye=e=>null==e?void 0:e.getAttributeNames().reduce(((t,o)=>{var r;if(o.startsWith("data-tooltip-")){t[o.replace(/^data-tooltip-/,"")]=null!==(r=null==e?void 0:e.getAttribute(o))&&void 0!==r?r:null}return t}),{}),he=e=>{const t={place:e=>{var t;K(null!==(t=e)&&void 0!==t?t:d)},content:e=>{P(null!=e?e:l)},html:e=>{U(null!=e?e:s)},variant:e=>{var t;Y(null!==(t=e)&&void 0!==t?t:u)},offset:e=>{Z(null===e?p:Number(e))},wrapper:e=>{var t;se(null!==(t=e)&&void 0!==t?t:f)},events:e=>{const t=null==e?void 0:e.split(" ");ie(null!=t?t:m)},"position-strategy":e=>{var t;ue(null!==(t=e)&&void 0!==t?t:w)},"delay-show":e=>{J(null===e?E:Number(e))},"delay-hide":e=>{ee(null===e?b:Number(e))},float:e=>{oe(null===e?g:"true"===e)},hidden:e=>{le(null===e?_:"true"===e)}};Object.values(t).forEach((e=>e(null))),Object.entries(e).forEach((([e,o])=>{var r;null===(r=t[e])||void 0===r||r.call(t,o)}))};t.useEffect((()=>{P(l)}),[l]),t.useEffect((()=>{U(s)}),[s]),t.useEffect((()=>{K(d)}),[d]),t.useEffect((()=>{Y(u)}),[u]),t.useEffect((()=>{Z(p)}),[p]),t.useEffect((()=>{J(E)}),[E]),t.useEffect((()=>{ee(b)}),[b]),t.useEffect((()=>{oe(g)}),[g]),t.useEffect((()=>{le(_)}),[_]),t.useEffect((()=>{ue(w)}),[w]),t.useEffect((()=>{fe.current!==I&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[I]),t.useEffect((()=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:"core"===I,disableBase:I}}))}),[]),t.useEffect((()=>{var t;const l=new Set(ve);let n=r;if(!n&&e&&(n=`[data-tooltip-id='${e}']`),n)try{document.querySelectorAll(n).forEach((e=>{l.add({current:e})}))}catch(e){console.warn(`[react-tooltip] "${n}" is not a valid CSS selector`)}const s=document.querySelector(`[id='${o}']`);if(s&&l.add({current:s}),!l.size)return()=>null;const c=null!==(t=null!=de?de:s)&&void 0!==t?t:me.current,i=new MutationObserver((e=>{e.forEach((e=>{var t;if(!c||"attributes"!==e.type||!(null===(t=e.attributeName)||void 0===t?void 0:t.startsWith("data-tooltip-")))return;const o=ye(c);he(o)}))})),a={attributes:!0,childList:!1,subtree:!1};if(c){const e=ye(c);he(e),i.observe(c,a)}return()=>{i.disconnect()}}),[ve,me,de,o,r]),t.useEffect((()=>{(null==k?void 0:k.border)&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),j&&!CSS.supports("border",`${j}`)&&console.warn(`[react-tooltip] "${j}" is not a valid \`border\`.`),(null==k?void 0:k.opacity)&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),B&&!CSS.supports("opacity",`${B}`)&&console.warn(`[react-tooltip] "${B}" is not a valid \`opacity\`.`)}),[]);let we=v;const Se=t.useRef(null);if(c){const e=c({content:null!=z?z:null,activeAnchor:de});we=e?n.default.createElement("div",{ref:Se,className:"react-tooltip-content-wrapper"},e):null}else z&&(we=z);W&&(we=n.default.createElement(C,{content:W}));const Ee={id:e,anchorId:o,anchorSelect:r,className:i,classNameArrow:a,content:we,contentWrapperRef:Se,place:F,variant:X,offset:V,wrapper:ne,events:ce,openOnClick:h,positionStrategy:ae,middlewares:S,delayShow:G,delayHide:Q,float:te,hidden:re,noArrow:A,clickable:T,closeOnEsc:R,closeOnScroll:O,closeOnResize:x,style:k,position:N,isOpen:$,border:j,opacity:B,arrowColor:D,setIsOpen:q,afterShow:H,afterHide:M,activeAnchor:de,setActiveAnchor:e=>pe(e)};return n.default.createElement(L,{...Ee})},e.TooltipProvider=({children:e})=>{const[o,r]=t.useState({[p]:new Set}),[l,s]=t.useState({[p]:{current:null}}),c=(e,...t)=>{r((o=>{var r;const l=null!==(r=o[e])&&void 0!==r?r:new Set;return t.forEach((e=>l.add(e))),{...o,[e]:new Set(l)}}))},i=(e,...t)=>{r((o=>{const r=o[e];return r?(t.forEach((e=>r.delete(e))),{...o}):o}))},a=t.useCallback(((e=p)=>{var t,r;return{anchorRefs:null!==(t=o[e])&&void 0!==t?t:new Set,activeAnchor:null!==(r=l[e])&&void 0!==r?r:{current:null},attach:(...t)=>c(e,...t),detach:(...t)=>i(e,...t),setActiveAnchor:t=>((e,t)=>{s((o=>{var r;return(null===(r=o[e])||void 0===r?void 0:r.current)===t.current?o:{...o,[e]:t}}))})(e,t)}}),[o,l,c,i]),u=t.useMemo((()=>({getTooltipData:a})),[a]);return n.default.createElement(m.Provider,{value:u},e)},e.TooltipWrapper=({tooltipId:e,children:o,className:r,place:l,content:c,html:i,variant:a,offset:u,wrapper:d,events:p,positionStrategy:f,delayShow:v,delayHide:m})=>{const{attach:h,detach:w}=y(e),S=t.useRef(null);return t.useEffect((()=>(h(S),()=>{w(S)})),[]),n.default.createElement("span",{ref:S,className:s.default("react-tooltip-wrapper",r),"data-tooltip-place":l,"data-tooltip-content":c,"data-tooltip-html":i,"data-tooltip-variant":a,"data-tooltip-offset":u,"data-tooltip-wrapper":d,"data-tooltip-events":p,"data-tooltip-position-strategy":f,"data-tooltip-delay-show":v,"data-tooltip-delay-hide":m},o)},e.removeStyle=function({type:e="base",id:t=i}={}){if(!a[e])return;"core"===e&&(t=c);const o=document.getElementById(t);"style"===(null==o?void 0:o.tagName)?null==o||o.remove():console.warn(`[react-tooltip] Failed to remove 'style' element with id '${t}'. Call \`injectStyle()\` first`),a[e]=!1},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "react-tooltip",
"version": "5.21.6",
"version": "5.21.7-beta.1110.0",
"description": "react tooltip component",

@@ -5,0 +5,0 @@ "scripts": {

@@ -64,3 +64,3 @@ # react-tooltip

<a href="https://frigade.com/?source=react-tooltip">
<img alt="Frigade" style="height: 250px" src="docs/static/img/sponsors/frigade.png" />
<img alt="Frigade" style="height: 250px;" src="docs/static/img/sponsors/frigade.png" />
</a>

@@ -73,3 +73,3 @@

<a href="https://dopt.com/?source=react-tooltip">
<img alt="Dopt" style="height: 200px" src="docs/static/img/sponsors/dopt.png" />
<img alt="Dopt" style="height: 200px; width: 200px;" src="docs/static/img/sponsors/dopt.png" />
</a>

@@ -76,0 +76,0 @@

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

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

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