Socket
Socket
Sign inDemoInstall

@nivo/tooltip

Package Overview
Dependencies
29
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.79.0 to 0.80.0

2

dist/nivo-tooltip.cjs.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("@react-spring/web"),o=require("@nivo/core"),i=require("react/jsx-runtime");function r(){return r=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},r.apply(this,arguments)}var n={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},s=function(t,e){return"translate("+t+"px, "+e+"px)"},l=t.memo((function(l){var a,u=l.position,c=l.anchor,p=l.children,x=o.useTheme(),h=o.useMotionConfig(),d=h.animate,y=h.config,f=o.useMeasure(),v=f[0],m=f[1],b=t.useRef(!1),g=void 0,T=!1,j=m.width>0&&m.height>0,w=Math.round(u[0]),C=Math.round(u[1]);j&&("top"===c?(w-=m.width/2,C-=m.height+14):"right"===c?(w+=14,C-=m.height/2):"bottom"===c?(w-=m.width/2,C+=14):"left"===c?(w-=m.width+14,C-=m.height/2):"center"===c&&(w-=m.width/2,C-=m.height/2),g={transform:s(w,C)},b.current||(T=!0),b.current=[w,C]);var M=e.useSpring({to:g,config:y,immediate:!d||T}),S=r({},n,x.tooltip,{transform:null!=(a=M.transform)?a:s(w,C)});return i.jsx(e.animated.div,{ref:v,style:S,children:p})}));l.displayName="TooltipWrapper";var a=t.memo((function(t){var e=t.size,o=void 0===e?12:e,n=t.color,s=t.style,l=void 0===s?{}:s;return i.jsx("span",{style:r({display:"block",width:o,height:o,background:n},l)})})),u=t.memo((function(t){var e,r=t.id,n=t.value,s=t.format,l=t.enableChip,u=void 0!==l&&l,c=t.color,p=t.renderContent,x=o.useTheme(),h=o.useValueFormatter(s);if("function"==typeof p)e=p();else{var d=n;void 0!==h&&void 0!==d&&(d=h(d)),e=i.jsxs("div",{style:x.tooltip.basic,children:[u&&i.jsx(a,{color:c,style:x.tooltip.chip}),void 0!==d?i.jsxs("span",{children:[r,": ",i.jsx("strong",{children:""+d})]}):r]})}return i.jsx("div",{style:x.tooltip.container,children:e})})),c={width:"100%",borderCollapse:"collapse"},p=t.memo((function(t){var e,n=t.title,s=t.rows,l=void 0===s?[]:s,a=t.renderContent,u=o.useTheme();return l.length?(e="function"==typeof a?a():i.jsxs("div",{children:[n&&n,i.jsx("table",{style:r({},c,u.tooltip.table),children:i.jsx("tbody",{children:l.map((function(t,e){return i.jsx("tr",{children:t.map((function(t,e){return i.jsx("td",{style:u.tooltip.tableCell,children:t},e)}))},e)}))})})]}),i.jsx("div",{style:u.tooltip.container,children:e})):null}));p.displayName="TableTooltip";var x=t.memo((function(n){var s=n.x0,l=n.x1,a=n.y0,u=n.y1,c=o.useTheme(),p=o.useMotionConfig(),x=p.animate,h=p.config,d=t.useMemo((function(){return r({},c.crosshair.line,{pointerEvents:"none"})}),[c.crosshair.line]),y=e.useSpring({x1:s,x2:l,y1:a,y2:u,config:h,immediate:!x});return i.jsx(e.animated.line,r({},y,{fill:"none",style:d}))}));x.displayName="CrosshairLine";var h=t.memo((function(t){var e,o,r=t.width,n=t.height,s=t.type,l=t.x,a=t.y;return"cross"===s?(e={x0:l,x1:l,y0:0,y1:n},o={x0:0,x1:r,y0:a,y1:a}):"top-left"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:0,x1:l,y0:a,y1:a}):"top"===s?e={x0:l,x1:l,y0:0,y1:a}:"top-right"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:l,x1:r,y0:a,y1:a}):"right"===s?o={x0:l,x1:r,y0:a,y1:a}:"bottom-right"===s?(e={x0:l,x1:l,y0:a,y1:n},o={x0:l,x1:r,y0:a,y1:a}):"bottom"===s?e={x0:l,x1:l,y0:a,y1:n}:"bottom-left"===s?(e={x0:l,x1:l,y0:a,y1:n},o={x0:0,x1:l,y0:a,y1:a}):"left"===s?o={x0:0,x1:l,y0:a,y1:a}:"x"===s?e={x0:l,x1:l,y0:0,y1:n}:"y"===s&&(o={x0:0,x1:r,y0:a,y1:a}),i.jsxs(i.Fragment,{children:[e&&i.jsx(x,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1}),o&&i.jsx(x,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1})]})}));h.displayName="Crosshair";var d=t.createContext({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),y={isVisible:!1,position:[null,null],content:null,anchor:null},f=t.createContext(y),v=function(e){var o=t.useState(y),i=o[0],r=o[1],n=t.useCallback((function(t,e,o){var i=e[0],n=e[1];void 0===o&&(o="top"),r({isVisible:!0,position:[i,n],anchor:o,content:t})}),[r]),s=t.useCallback((function(t,o,i){void 0===i&&(i="top");var n=e.current.getBoundingClientRect(),s=o.clientX-n.left,l=o.clientY-n.top;"left"!==i&&"right"!==i||(i=s<n.width/2?"right":"left"),r({isVisible:!0,position:[s,l],anchor:i,content:t})}),[e,r]),l=t.useCallback((function(){r(y)}),[r]);return{actions:t.useMemo((function(){return{showTooltipAt:n,showTooltipFromEvent:s,hideTooltip:l}}),[n,s,l]),state:i}},m=function(){var e=t.useContext(f);if(void 0===e)throw new Error("useTooltipState must be used within a TooltipProvider");return e},b=function(t){return t.isVisible};exports.BasicTooltip=u,exports.Chip=a,exports.Crosshair=h,exports.TableTooltip=p,exports.Tooltip=function(){var t=m();return b(t)?i.jsx(l,{position:t.position,anchor:t.anchor,children:t.content}):null},exports.TooltipActionsContext=d,exports.TooltipProvider=function(t){var e=t.container,o=t.children,r=v(e),n=r.actions,s=r.state;return i.jsx(d.Provider,{value:n,children:i.jsx(f.Provider,{value:s,children:o})})},exports.TooltipStateContext=f,exports.TooltipWrapper=l,exports.hiddenTooltipState=y,exports.isVisibleTooltipState=b,exports.useTooltip=function(){var e=t.useContext(d);if(void 0===e)throw new Error("useTooltip must be used within a TooltipProvider");return e},exports.useTooltipHandlers=v,exports.useTooltipState=m;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("@react-spring/web"),o=require("@nivo/core"),i=require("react/jsx-runtime");function r(){return r=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},r.apply(this,arguments)}var n={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},s=function(t,e){return"translate("+t+"px, "+e+"px)"},l=t.memo((function(l){var a,u=l.position,c=l.anchor,p=l.children,x=o.useTheme(),h=o.useMotionConfig(),d=h.animate,y=h.config,f=o.useMeasure(),v=f[0],m=f[1],b=t.useRef(!1),g=void 0,T=!1,j=m.width>0&&m.height>0,w=Math.round(u[0]),C=Math.round(u[1]);j&&("top"===c?(w-=m.width/2,C-=m.height+14):"right"===c?(w+=14,C-=m.height/2):"bottom"===c?(w-=m.width/2,C+=14):"left"===c?(w-=m.width+14,C-=m.height/2):"center"===c&&(w-=m.width/2,C-=m.height/2),g={transform:s(w,C)},b.current||(T=!0),b.current=[w,C]);var M=e.useSpring({to:g,config:y,immediate:!d||T}),S=r({},n,x.tooltip,{transform:null!=(a=M.transform)?a:s(w,C)});return i.jsx(e.animated.div,{ref:v,style:S,children:p})}));l.displayName="TooltipWrapper";var a=t.memo((function(t){var e=t.size,o=void 0===e?12:e,n=t.color,s=t.style,l=void 0===s?{}:s;return i.jsx("span",{style:r({display:"block",width:o,height:o,background:n},l)})})),u=t.memo((function(t){var e,r=t.id,n=t.value,s=t.format,l=t.enableChip,u=void 0!==l&&l,c=t.color,p=t.renderContent,x=o.useTheme(),h=o.useValueFormatter(s);if("function"==typeof p)e=p();else{var d=n;void 0!==h&&void 0!==d&&(d=h(d)),e=i.jsxs("div",{style:x.tooltip.basic,children:[u&&i.jsx(a,{color:c,style:x.tooltip.chip}),void 0!==d?i.jsxs("span",{children:[r,": ",i.jsx("strong",{children:""+d})]}):r]})}return i.jsx("div",{style:x.tooltip.container,children:e})})),c={width:"100%",borderCollapse:"collapse"},p=t.memo((function(t){var e,n=t.title,s=t.rows,l=void 0===s?[]:s,a=t.renderContent,u=o.useTheme();return l.length?(e="function"==typeof a?a():i.jsxs("div",{children:[n&&n,i.jsx("table",{style:r({},c,u.tooltip.table),children:i.jsx("tbody",{children:l.map((function(t,e){return i.jsx("tr",{children:t.map((function(t,e){return i.jsx("td",{style:u.tooltip.tableCell,children:t},e)}))},e)}))})})]}),i.jsx("div",{style:u.tooltip.container,children:e})):null}));p.displayName="TableTooltip";var x=t.memo((function(n){var s=n.x0,l=n.x1,a=n.y0,u=n.y1,c=o.useTheme(),p=o.useMotionConfig(),x=p.animate,h=p.config,d=t.useMemo((function(){return r({},c.crosshair.line,{pointerEvents:"none"})}),[c.crosshair.line]),y=e.useSpring({x1:s,x2:l,y1:a,y2:u,config:h,immediate:!x});return i.jsx(e.animated.line,r({},y,{fill:"none",style:d}))}));x.displayName="CrosshairLine";var h=t.memo((function(t){var e,o,r=t.width,n=t.height,s=t.type,l=t.x,a=t.y;return"cross"===s?(e={x0:l,x1:l,y0:0,y1:n},o={x0:0,x1:r,y0:a,y1:a}):"top-left"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:0,x1:l,y0:a,y1:a}):"top"===s?e={x0:l,x1:l,y0:0,y1:a}:"top-right"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:l,x1:r,y0:a,y1:a}):"right"===s?o={x0:l,x1:r,y0:a,y1:a}:"bottom-right"===s?(e={x0:l,x1:l,y0:a,y1:n},o={x0:l,x1:r,y0:a,y1:a}):"bottom"===s?e={x0:l,x1:l,y0:a,y1:n}:"bottom-left"===s?(e={x0:l,x1:l,y0:a,y1:n},o={x0:0,x1:l,y0:a,y1:a}):"left"===s?o={x0:0,x1:l,y0:a,y1:a}:"x"===s?e={x0:l,x1:l,y0:0,y1:n}:"y"===s&&(o={x0:0,x1:r,y0:a,y1:a}),i.jsxs(i.Fragment,{children:[e&&i.jsx(x,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1}),o&&i.jsx(x,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1})]})}));h.displayName="Crosshair";var d=t.createContext({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),y={isVisible:!1,position:[null,null],content:null,anchor:null},f=t.createContext(y),v=function(e){var o=t.useState(y),i=o[0],r=o[1],n=t.useCallback((function(t,e,o){var i=e[0],n=e[1];void 0===o&&(o="top"),r({isVisible:!0,position:[i,n],anchor:o,content:t})}),[r]),s=t.useCallback((function(t,o,i){void 0===i&&(i="top");var n=e.current.getBoundingClientRect(),s=e.current.offsetWidth,l=s===n.width?1:s/n.width,a=(o.clientX-n.left)*l,u=(o.clientY-n.top)*l;"left"!==i&&"right"!==i||(i=a<n.width/2?"right":"left"),r({isVisible:!0,position:[a,u],anchor:i,content:t})}),[e,r]),l=t.useCallback((function(){r(y)}),[r]);return{actions:t.useMemo((function(){return{showTooltipAt:n,showTooltipFromEvent:s,hideTooltip:l}}),[n,s,l]),state:i}},m=function(){var e=t.useContext(f);if(void 0===e)throw new Error("useTooltipState must be used within a TooltipProvider");return e},b=function(t){return t.isVisible};exports.BasicTooltip=u,exports.Chip=a,exports.Crosshair=h,exports.TableTooltip=p,exports.Tooltip=function(){var t=m();return b(t)?i.jsx(l,{position:t.position,anchor:t.anchor,children:t.content}):null},exports.TooltipActionsContext=d,exports.TooltipProvider=function(t){var e=t.container,o=t.children,r=v(e),n=r.actions,s=r.state;return i.jsx(d.Provider,{value:n,children:i.jsx(f.Provider,{value:s,children:o})})},exports.TooltipStateContext=f,exports.TooltipWrapper=l,exports.hiddenTooltipState=y,exports.isVisibleTooltipState=b,exports.useTooltip=function(){var e=t.useContext(d);if(void 0===e)throw new Error("useTooltip must be used within a TooltipProvider");return e},exports.useTooltipHandlers=v,exports.useTooltipState=m;
//# sourceMappingURL=nivo-tooltip.cjs.js.map

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

import{memo as t,useRef as o,useMemo as i,createContext as n,useState as r,useCallback as e,useContext as l}from"react";import{useSpring as a,animated as c}from"@react-spring/web";import{useTheme as s,useMotionConfig as h,useMeasure as u,useValueFormatter as d}from"@nivo/core";import{jsx as y,jsxs as p,Fragment as f}from"react/jsx-runtime";function v(){return v=Object.assign||function(t){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},v.apply(this,arguments)}var x={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},m=function(t,o){return"translate("+t+"px, "+o+"px)"},g=t((function(t){var i,n=t.position,r=t.anchor,e=t.children,l=s(),d=h(),p=d.animate,f=d.config,g=u(),b=g[0],w=g[1],T=o(!1),C=void 0,E=!1,P=w.width>0&&w.height>0,N=Math.round(n[0]),V=Math.round(n[1]);P&&("top"===r?(N-=w.width/2,V-=w.height+14):"right"===r?(N+=14,V-=w.height/2):"bottom"===r?(N-=w.width/2,V+=14):"left"===r?(N-=w.width+14,V-=w.height/2):"center"===r&&(N-=w.width/2,V-=w.height/2),C={transform:m(N,V)},T.current||(E=!0),T.current=[N,V]);var j=a({to:C,config:f,immediate:!p||E}),O=v({},x,l.tooltip,{transform:null!=(i=j.transform)?i:m(N,V)});return y(c.div,{ref:b,style:O,children:e})}));g.displayName="TooltipWrapper";var b=t((function(t){var o=t.size,i=void 0===o?12:o,n=t.color,r=t.style;return y("span",{style:v({display:"block",width:i,height:i,background:n},void 0===r?{}:r)})})),w=t((function(t){var o,i=t.id,n=t.value,r=t.format,e=t.enableChip,l=void 0!==e&&e,a=t.color,c=t.renderContent,h=s(),u=d(r);if("function"==typeof c)o=c();else{var f=n;void 0!==u&&void 0!==f&&(f=u(f)),o=p("div",{style:h.tooltip.basic,children:[l&&y(b,{color:a,style:h.tooltip.chip}),void 0!==f?p("span",{children:[i,": ",y("strong",{children:""+f})]}):i]})}return y("div",{style:h.tooltip.container,children:o})})),T={width:"100%",borderCollapse:"collapse"},C=t((function(t){var o,i=t.title,n=t.rows,r=void 0===n?[]:n,e=t.renderContent,l=s();return r.length?(o="function"==typeof e?e():p("div",{children:[i&&i,y("table",{style:v({},T,l.tooltip.table),children:y("tbody",{children:r.map((function(t,o){return y("tr",{children:t.map((function(t,o){return y("td",{style:l.tooltip.tableCell,children:t},o)}))},o)}))})})]}),y("div",{style:l.tooltip.container,children:o})):null}));C.displayName="TableTooltip";var E=t((function(t){var o=t.x0,n=t.x1,r=t.y0,e=t.y1,l=s(),u=h(),d=u.animate,p=u.config,f=i((function(){return v({},l.crosshair.line,{pointerEvents:"none"})}),[l.crosshair.line]),x=a({x1:o,x2:n,y1:r,y2:e,config:p,immediate:!d});return y(c.line,v({},x,{fill:"none",style:f}))}));E.displayName="CrosshairLine";var P=t((function(t){var o,i,n=t.width,r=t.height,e=t.type,l=t.x,a=t.y;return"cross"===e?(o={x0:l,x1:l,y0:0,y1:r},i={x0:0,x1:n,y0:a,y1:a}):"top-left"===e?(o={x0:l,x1:l,y0:0,y1:a},i={x0:0,x1:l,y0:a,y1:a}):"top"===e?o={x0:l,x1:l,y0:0,y1:a}:"top-right"===e?(o={x0:l,x1:l,y0:0,y1:a},i={x0:l,x1:n,y0:a,y1:a}):"right"===e?i={x0:l,x1:n,y0:a,y1:a}:"bottom-right"===e?(o={x0:l,x1:l,y0:a,y1:r},i={x0:l,x1:n,y0:a,y1:a}):"bottom"===e?o={x0:l,x1:l,y0:a,y1:r}:"bottom-left"===e?(o={x0:l,x1:l,y0:a,y1:r},i={x0:0,x1:l,y0:a,y1:a}):"left"===e?i={x0:0,x1:l,y0:a,y1:a}:"x"===e?o={x0:l,x1:l,y0:0,y1:r}:"y"===e&&(i={x0:0,x1:n,y0:a,y1:a}),p(f,{children:[o&&y(E,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1}),i&&y(E,{x0:i.x0,x1:i.x1,y0:i.y0,y1:i.y1})]})}));P.displayName="Crosshair";var N=n({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),V={isVisible:!1,position:[null,null],content:null,anchor:null},j=n(V),O=function(t){var o=r(V),n=o[0],l=o[1],a=e((function(t,o,i){var n=o[0],r=o[1];void 0===i&&(i="top"),l({isVisible:!0,position:[n,r],anchor:i,content:t})}),[l]),c=e((function(o,i,n){void 0===n&&(n="top");var r=t.current.getBoundingClientRect(),e=i.clientX-r.left,a=i.clientY-r.top;"left"!==n&&"right"!==n||(n=e<r.width/2?"right":"left"),l({isVisible:!0,position:[e,a],anchor:n,content:o})}),[t,l]),s=e((function(){l(V)}),[l]);return{actions:i((function(){return{showTooltipAt:a,showTooltipFromEvent:c,hideTooltip:s}}),[a,c,s]),state:n}},k=function(){var t=l(N);if(void 0===t)throw new Error("useTooltip must be used within a TooltipProvider");return t},z=function(){var t=l(j);if(void 0===t)throw new Error("useTooltipState must be used within a TooltipProvider");return t},A=function(t){return t.isVisible},F=function(){var t=z();return A(t)?y(g,{position:t.position,anchor:t.anchor,children:t.content}):null},M=function(t){var o=t.container,i=t.children,n=O(o),r=n.actions,e=n.state;return y(N.Provider,{value:r,children:y(j.Provider,{value:e,children:i})})};export{w as BasicTooltip,b as Chip,P as Crosshair,C as TableTooltip,F as Tooltip,N as TooltipActionsContext,M as TooltipProvider,j as TooltipStateContext,g as TooltipWrapper,V as hiddenTooltipState,A as isVisibleTooltipState,k as useTooltip,O as useTooltipHandlers,z as useTooltipState};
import{memo as t,useRef as i,useMemo as o,createContext as n,useState as r,useCallback as e,useContext as l}from"react";import{useSpring as a,animated as c}from"@react-spring/web";import{useTheme as h,useMotionConfig as s,useMeasure as d,useValueFormatter as u}from"@nivo/core";import{jsx as y,jsxs as p,Fragment as f}from"react/jsx-runtime";function v(){return v=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var o=arguments[i];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},v.apply(this,arguments)}var x={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},m=function(t,i){return"translate("+t+"px, "+i+"px)"},g=t((function(t){var o,n=t.position,r=t.anchor,e=t.children,l=h(),u=s(),p=u.animate,f=u.config,g=d(),b=g[0],w=g[1],T=i(!1),C=void 0,E=!1,P=w.width>0&&w.height>0,N=Math.round(n[0]),V=Math.round(n[1]);P&&("top"===r?(N-=w.width/2,V-=w.height+14):"right"===r?(N+=14,V-=w.height/2):"bottom"===r?(N-=w.width/2,V+=14):"left"===r?(N-=w.width+14,V-=w.height/2):"center"===r&&(N-=w.width/2,V-=w.height/2),C={transform:m(N,V)},T.current||(E=!0),T.current=[N,V]);var j=a({to:C,config:f,immediate:!p||E}),O=v({},x,l.tooltip,{transform:null!=(o=j.transform)?o:m(N,V)});return y(c.div,{ref:b,style:O,children:e})}));g.displayName="TooltipWrapper";var b=t((function(t){var i=t.size,o=void 0===i?12:i,n=t.color,r=t.style;return y("span",{style:v({display:"block",width:o,height:o,background:n},void 0===r?{}:r)})})),w=t((function(t){var i,o=t.id,n=t.value,r=t.format,e=t.enableChip,l=void 0!==e&&e,a=t.color,c=t.renderContent,s=h(),d=u(r);if("function"==typeof c)i=c();else{var f=n;void 0!==d&&void 0!==f&&(f=d(f)),i=p("div",{style:s.tooltip.basic,children:[l&&y(b,{color:a,style:s.tooltip.chip}),void 0!==f?p("span",{children:[o,": ",y("strong",{children:""+f})]}):o]})}return y("div",{style:s.tooltip.container,children:i})})),T={width:"100%",borderCollapse:"collapse"},C=t((function(t){var i,o=t.title,n=t.rows,r=void 0===n?[]:n,e=t.renderContent,l=h();return r.length?(i="function"==typeof e?e():p("div",{children:[o&&o,y("table",{style:v({},T,l.tooltip.table),children:y("tbody",{children:r.map((function(t,i){return y("tr",{children:t.map((function(t,i){return y("td",{style:l.tooltip.tableCell,children:t},i)}))},i)}))})})]}),y("div",{style:l.tooltip.container,children:i})):null}));C.displayName="TableTooltip";var E=t((function(t){var i=t.x0,n=t.x1,r=t.y0,e=t.y1,l=h(),d=s(),u=d.animate,p=d.config,f=o((function(){return v({},l.crosshair.line,{pointerEvents:"none"})}),[l.crosshair.line]),x=a({x1:i,x2:n,y1:r,y2:e,config:p,immediate:!u});return y(c.line,v({},x,{fill:"none",style:f}))}));E.displayName="CrosshairLine";var P=t((function(t){var i,o,n=t.width,r=t.height,e=t.type,l=t.x,a=t.y;return"cross"===e?(i={x0:l,x1:l,y0:0,y1:r},o={x0:0,x1:n,y0:a,y1:a}):"top-left"===e?(i={x0:l,x1:l,y0:0,y1:a},o={x0:0,x1:l,y0:a,y1:a}):"top"===e?i={x0:l,x1:l,y0:0,y1:a}:"top-right"===e?(i={x0:l,x1:l,y0:0,y1:a},o={x0:l,x1:n,y0:a,y1:a}):"right"===e?o={x0:l,x1:n,y0:a,y1:a}:"bottom-right"===e?(i={x0:l,x1:l,y0:a,y1:r},o={x0:l,x1:n,y0:a,y1:a}):"bottom"===e?i={x0:l,x1:l,y0:a,y1:r}:"bottom-left"===e?(i={x0:l,x1:l,y0:a,y1:r},o={x0:0,x1:l,y0:a,y1:a}):"left"===e?o={x0:0,x1:l,y0:a,y1:a}:"x"===e?i={x0:l,x1:l,y0:0,y1:r}:"y"===e&&(o={x0:0,x1:n,y0:a,y1:a}),p(f,{children:[i&&y(E,{x0:i.x0,x1:i.x1,y0:i.y0,y1:i.y1}),o&&y(E,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1})]})}));P.displayName="Crosshair";var N=n({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),V={isVisible:!1,position:[null,null],content:null,anchor:null},j=n(V),O=function(t){var i=r(V),n=i[0],l=i[1],a=e((function(t,i,o){var n=i[0],r=i[1];void 0===o&&(o="top"),l({isVisible:!0,position:[n,r],anchor:o,content:t})}),[l]),c=e((function(i,o,n){void 0===n&&(n="top");var r=t.current.getBoundingClientRect(),e=t.current.offsetWidth,a=e===r.width?1:e/r.width,c=(o.clientX-r.left)*a,h=(o.clientY-r.top)*a;"left"!==n&&"right"!==n||(n=c<r.width/2?"right":"left"),l({isVisible:!0,position:[c,h],anchor:n,content:i})}),[t,l]),h=e((function(){l(V)}),[l]);return{actions:o((function(){return{showTooltipAt:a,showTooltipFromEvent:c,hideTooltip:h}}),[a,c,h]),state:n}},k=function(){var t=l(N);if(void 0===t)throw new Error("useTooltip must be used within a TooltipProvider");return t},z=function(){var t=l(j);if(void 0===t)throw new Error("useTooltipState must be used within a TooltipProvider");return t},A=function(t){return t.isVisible},F=function(){var t=z();return A(t)?y(g,{position:t.position,anchor:t.anchor,children:t.content}):null},M=function(t){var i=t.container,o=t.children,n=O(i),r=n.actions,e=n.state;return y(N.Provider,{value:r,children:y(j.Provider,{value:e,children:o})})};export{w as BasicTooltip,b as Chip,P as Crosshair,C as TableTooltip,F as Tooltip,N as TooltipActionsContext,M as TooltipProvider,j as TooltipStateContext,g as TooltipWrapper,V as hiddenTooltipState,A as isVisibleTooltipState,k as useTooltip,O as useTooltipHandlers,z as useTooltipState};
//# sourceMappingURL=nivo-tooltip.es.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("@react-spring/web"),require("@nivo/core"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","@react-spring/web","@nivo/core","react/jsx-runtime"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).nivo=t.nivo||{},t.React,t["@react-spring/web"],t.nivo,t["react/jsx-runtime"])}(this,(function(t,e,o,i,n){"use strict";function r(){return r=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},r.apply(this,arguments)}var s={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},l=function(t,e){return"translate("+t+"px, "+e+"px)"},a=e.memo((function(t){var a,u=t.position,c=t.anchor,p=t.children,d=i.useTheme(),h=i.useMotionConfig(),x=h.animate,y=h.config,f=i.useMeasure(),v=f[0],m=f[1],b=e.useRef(!1),g=void 0,T=!1,j=m.width>0&&m.height>0,w=Math.round(u[0]),C=Math.round(u[1]);j&&("top"===c?(w-=m.width/2,C-=m.height+14):"right"===c?(w+=14,C-=m.height/2):"bottom"===c?(w-=m.width/2,C+=14):"left"===c?(w-=m.width+14,C-=m.height/2):"center"===c&&(w-=m.width/2,C-=m.height/2),g={transform:l(w,C)},b.current||(T=!0),b.current=[w,C]);var M=o.useSpring({to:g,config:y,immediate:!x||T}),S=r({},s,d.tooltip,{transform:null!=(a=M.transform)?a:l(w,C)});return n.jsx(o.animated.div,{ref:v,style:S,children:p})}));a.displayName="TooltipWrapper";var u=e.memo((function(t){var e=t.size,o=void 0===e?12:e,i=t.color,s=t.style,l=void 0===s?{}:s;return n.jsx("span",{style:r({display:"block",width:o,height:o,background:i},l)})})),c=e.memo((function(t){var e,o=t.id,r=t.value,s=t.format,l=t.enableChip,a=void 0!==l&&l,c=t.color,p=t.renderContent,d=i.useTheme(),h=i.useValueFormatter(s);if("function"==typeof p)e=p();else{var x=r;void 0!==h&&void 0!==x&&(x=h(x)),e=n.jsxs("div",{style:d.tooltip.basic,children:[a&&n.jsx(u,{color:c,style:d.tooltip.chip}),void 0!==x?n.jsxs("span",{children:[o,": ",n.jsx("strong",{children:""+x})]}):o]})}return n.jsx("div",{style:d.tooltip.container,children:e})})),p={width:"100%",borderCollapse:"collapse"},d=e.memo((function(t){var e,o=t.title,s=t.rows,l=void 0===s?[]:s,a=t.renderContent,u=i.useTheme();return l.length?(e="function"==typeof a?a():n.jsxs("div",{children:[o&&o,n.jsx("table",{style:r({},p,u.tooltip.table),children:n.jsx("tbody",{children:l.map((function(t,e){return n.jsx("tr",{children:t.map((function(t,e){return n.jsx("td",{style:u.tooltip.tableCell,children:t},e)}))},e)}))})})]}),n.jsx("div",{style:u.tooltip.container,children:e})):null}));d.displayName="TableTooltip";var h=e.memo((function(t){var s=t.x0,l=t.x1,a=t.y0,u=t.y1,c=i.useTheme(),p=i.useMotionConfig(),d=p.animate,h=p.config,x=e.useMemo((function(){return r({},c.crosshair.line,{pointerEvents:"none"})}),[c.crosshair.line]),y=o.useSpring({x1:s,x2:l,y1:a,y2:u,config:h,immediate:!d});return n.jsx(o.animated.line,r({},y,{fill:"none",style:x}))}));h.displayName="CrosshairLine";var x=e.memo((function(t){var e,o,i=t.width,r=t.height,s=t.type,l=t.x,a=t.y;return"cross"===s?(e={x0:l,x1:l,y0:0,y1:r},o={x0:0,x1:i,y0:a,y1:a}):"top-left"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:0,x1:l,y0:a,y1:a}):"top"===s?e={x0:l,x1:l,y0:0,y1:a}:"top-right"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:l,x1:i,y0:a,y1:a}):"right"===s?o={x0:l,x1:i,y0:a,y1:a}:"bottom-right"===s?(e={x0:l,x1:l,y0:a,y1:r},o={x0:l,x1:i,y0:a,y1:a}):"bottom"===s?e={x0:l,x1:l,y0:a,y1:r}:"bottom-left"===s?(e={x0:l,x1:l,y0:a,y1:r},o={x0:0,x1:l,y0:a,y1:a}):"left"===s?o={x0:0,x1:l,y0:a,y1:a}:"x"===s?e={x0:l,x1:l,y0:0,y1:r}:"y"===s&&(o={x0:0,x1:i,y0:a,y1:a}),n.jsxs(n.Fragment,{children:[e&&n.jsx(h,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1}),o&&n.jsx(h,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1})]})}));x.displayName="Crosshair";var y=e.createContext({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),f={isVisible:!1,position:[null,null],content:null,anchor:null},v=e.createContext(f),m=function(t){var o=e.useState(f),i=o[0],n=o[1],r=e.useCallback((function(t,e,o){var i=e[0],r=e[1];void 0===o&&(o="top"),n({isVisible:!0,position:[i,r],anchor:o,content:t})}),[n]),s=e.useCallback((function(e,o,i){void 0===i&&(i="top");var r=t.current.getBoundingClientRect(),s=o.clientX-r.left,l=o.clientY-r.top;"left"!==i&&"right"!==i||(i=s<r.width/2?"right":"left"),n({isVisible:!0,position:[s,l],anchor:i,content:e})}),[t,n]),l=e.useCallback((function(){n(f)}),[n]);return{actions:e.useMemo((function(){return{showTooltipAt:r,showTooltipFromEvent:s,hideTooltip:l}}),[r,s,l]),state:i}},b=function(){var t=e.useContext(v);if(void 0===t)throw new Error("useTooltipState must be used within a TooltipProvider");return t},g=function(t){return t.isVisible};t.BasicTooltip=c,t.Chip=u,t.Crosshair=x,t.TableTooltip=d,t.Tooltip=function(){var t=b();return g(t)?n.jsx(a,{position:t.position,anchor:t.anchor,children:t.content}):null},t.TooltipActionsContext=y,t.TooltipProvider=function(t){var e=t.container,o=t.children,i=m(e),r=i.actions,s=i.state;return n.jsx(y.Provider,{value:r,children:n.jsx(v.Provider,{value:s,children:o})})},t.TooltipStateContext=v,t.TooltipWrapper=a,t.hiddenTooltipState=f,t.isVisibleTooltipState=g,t.useTooltip=function(){var t=e.useContext(y);if(void 0===t)throw new Error("useTooltip must be used within a TooltipProvider");return t},t.useTooltipHandlers=m,t.useTooltipState=b,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("@react-spring/web"),require("@nivo/core"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","@react-spring/web","@nivo/core","react/jsx-runtime"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).nivo=t.nivo||{},t.React,t["@react-spring/web"],t.nivo,t["react/jsx-runtime"])}(this,(function(t,e,o,i,n){"use strict";function r(){return r=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},r.apply(this,arguments)}var s={pointerEvents:"none",position:"absolute",zIndex:10,top:0,left:0},l=function(t,e){return"translate("+t+"px, "+e+"px)"},a=e.memo((function(t){var a,u=t.position,c=t.anchor,d=t.children,p=i.useTheme(),h=i.useMotionConfig(),x=h.animate,y=h.config,f=i.useMeasure(),v=f[0],m=f[1],b=e.useRef(!1),g=void 0,T=!1,j=m.width>0&&m.height>0,w=Math.round(u[0]),C=Math.round(u[1]);j&&("top"===c?(w-=m.width/2,C-=m.height+14):"right"===c?(w+=14,C-=m.height/2):"bottom"===c?(w-=m.width/2,C+=14):"left"===c?(w-=m.width+14,C-=m.height/2):"center"===c&&(w-=m.width/2,C-=m.height/2),g={transform:l(w,C)},b.current||(T=!0),b.current=[w,C]);var M=o.useSpring({to:g,config:y,immediate:!x||T}),S=r({},s,p.tooltip,{transform:null!=(a=M.transform)?a:l(w,C)});return n.jsx(o.animated.div,{ref:v,style:S,children:d})}));a.displayName="TooltipWrapper";var u=e.memo((function(t){var e=t.size,o=void 0===e?12:e,i=t.color,s=t.style,l=void 0===s?{}:s;return n.jsx("span",{style:r({display:"block",width:o,height:o,background:i},l)})})),c=e.memo((function(t){var e,o=t.id,r=t.value,s=t.format,l=t.enableChip,a=void 0!==l&&l,c=t.color,d=t.renderContent,p=i.useTheme(),h=i.useValueFormatter(s);if("function"==typeof d)e=d();else{var x=r;void 0!==h&&void 0!==x&&(x=h(x)),e=n.jsxs("div",{style:p.tooltip.basic,children:[a&&n.jsx(u,{color:c,style:p.tooltip.chip}),void 0!==x?n.jsxs("span",{children:[o,": ",n.jsx("strong",{children:""+x})]}):o]})}return n.jsx("div",{style:p.tooltip.container,children:e})})),d={width:"100%",borderCollapse:"collapse"},p=e.memo((function(t){var e,o=t.title,s=t.rows,l=void 0===s?[]:s,a=t.renderContent,u=i.useTheme();return l.length?(e="function"==typeof a?a():n.jsxs("div",{children:[o&&o,n.jsx("table",{style:r({},d,u.tooltip.table),children:n.jsx("tbody",{children:l.map((function(t,e){return n.jsx("tr",{children:t.map((function(t,e){return n.jsx("td",{style:u.tooltip.tableCell,children:t},e)}))},e)}))})})]}),n.jsx("div",{style:u.tooltip.container,children:e})):null}));p.displayName="TableTooltip";var h=e.memo((function(t){var s=t.x0,l=t.x1,a=t.y0,u=t.y1,c=i.useTheme(),d=i.useMotionConfig(),p=d.animate,h=d.config,x=e.useMemo((function(){return r({},c.crosshair.line,{pointerEvents:"none"})}),[c.crosshair.line]),y=o.useSpring({x1:s,x2:l,y1:a,y2:u,config:h,immediate:!p});return n.jsx(o.animated.line,r({},y,{fill:"none",style:x}))}));h.displayName="CrosshairLine";var x=e.memo((function(t){var e,o,i=t.width,r=t.height,s=t.type,l=t.x,a=t.y;return"cross"===s?(e={x0:l,x1:l,y0:0,y1:r},o={x0:0,x1:i,y0:a,y1:a}):"top-left"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:0,x1:l,y0:a,y1:a}):"top"===s?e={x0:l,x1:l,y0:0,y1:a}:"top-right"===s?(e={x0:l,x1:l,y0:0,y1:a},o={x0:l,x1:i,y0:a,y1:a}):"right"===s?o={x0:l,x1:i,y0:a,y1:a}:"bottom-right"===s?(e={x0:l,x1:l,y0:a,y1:r},o={x0:l,x1:i,y0:a,y1:a}):"bottom"===s?e={x0:l,x1:l,y0:a,y1:r}:"bottom-left"===s?(e={x0:l,x1:l,y0:a,y1:r},o={x0:0,x1:l,y0:a,y1:a}):"left"===s?o={x0:0,x1:l,y0:a,y1:a}:"x"===s?e={x0:l,x1:l,y0:0,y1:r}:"y"===s&&(o={x0:0,x1:i,y0:a,y1:a}),n.jsxs(n.Fragment,{children:[e&&n.jsx(h,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1}),o&&n.jsx(h,{x0:o.x0,x1:o.x1,y0:o.y0,y1:o.y1})]})}));x.displayName="Crosshair";var y=e.createContext({showTooltipAt:function(){},showTooltipFromEvent:function(){},hideTooltip:function(){}}),f={isVisible:!1,position:[null,null],content:null,anchor:null},v=e.createContext(f),m=function(t){var o=e.useState(f),i=o[0],n=o[1],r=e.useCallback((function(t,e,o){var i=e[0],r=e[1];void 0===o&&(o="top"),n({isVisible:!0,position:[i,r],anchor:o,content:t})}),[n]),s=e.useCallback((function(e,o,i){void 0===i&&(i="top");var r=t.current.getBoundingClientRect(),s=t.current.offsetWidth,l=s===r.width?1:s/r.width,a=(o.clientX-r.left)*l,u=(o.clientY-r.top)*l;"left"!==i&&"right"!==i||(i=a<r.width/2?"right":"left"),n({isVisible:!0,position:[a,u],anchor:i,content:e})}),[t,n]),l=e.useCallback((function(){n(f)}),[n]);return{actions:e.useMemo((function(){return{showTooltipAt:r,showTooltipFromEvent:s,hideTooltip:l}}),[r,s,l]),state:i}},b=function(){var t=e.useContext(v);if(void 0===t)throw new Error("useTooltipState must be used within a TooltipProvider");return t},g=function(t){return t.isVisible};t.BasicTooltip=c,t.Chip=u,t.Crosshair=x,t.TableTooltip=p,t.Tooltip=function(){var t=b();return g(t)?n.jsx(a,{position:t.position,anchor:t.anchor,children:t.content}):null},t.TooltipActionsContext=y,t.TooltipProvider=function(t){var e=t.container,o=t.children,i=m(e),r=i.actions,s=i.state;return n.jsx(y.Provider,{value:r,children:n.jsx(v.Provider,{value:s,children:o})})},t.TooltipStateContext=v,t.TooltipWrapper=a,t.hiddenTooltipState=f,t.isVisibleTooltipState=g,t.useTooltip=function(){var t=e.useContext(y);if(void 0===t)throw new Error("useTooltip must be used within a TooltipProvider");return t},t.useTooltipHandlers=m,t.useTooltipState=b,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=nivo-tooltip.umd.js.map
{
"name": "@nivo/tooltip",
"version": "0.79.0",
"version": "0.80.0",
"license": "MIT",

@@ -24,9 +24,9 @@ "author": {

"dependencies": {
"@react-spring/web": "9.3.1"
"@react-spring/web": "9.4.5"
},
"devDependencies": {
"@nivo/core": "0.79.0"
"@nivo/core": "0.80.0"
},
"peerDependencies": {
"@nivo/core": "0.79.0"
"@nivo/core": "0.80.0"
},

@@ -36,3 +36,3 @@ "publishConfig": {

},
"gitHead": "c9d8f198962d242872a0267e304f950eb57e2ec4"
"gitHead": "df352b82a7d3b7938fb3a1bd9be3f602cbc8a67f"
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc