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

@nivo/tooltip

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/tooltip - npm Package Compare versions

Comparing version 0.85.1 to 0.86.0

2

./dist/nivo-tooltip.cjs.js

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

"use strict";var t=require("react"),e=require("@react-spring/web"),o=require("@nivo/core"),i=require("react/jsx-runtime");function n(){return n=Object.assign?Object.assign.bind():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},n.apply(this,arguments)}var r={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 S=e.useSpring({to:g,config:y,immediate:!d||T}),M=n({},r,x.tooltip,{transform:null!=(a=S.transform)?a:s(w,C),opacity:S.transform?1:0});return i.jsx(e.animated.div,{ref:v,style:M,children:p})}));l.displayName="TooltipWrapper";var a=t.memo((function(t){var e=t.size,o=void 0===e?12:e,r=t.color,s=t.style,l=void 0===s?{}:s;return i.jsx("span",{style:n({display:"block",width:o,height:o,background:r},l)})})),u=t.memo((function(t){var e,n=t.id,r=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=r;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:[n,": ",i.jsx("strong",{children:""+d})]}):n]})}return i.jsx("div",{style:x.tooltip.container,children:e})})),c={width:"100%",borderCollapse:"collapse"},p=t.memo((function(t){var e,r=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:[r&&r,i.jsx("table",{style:n({},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(r){var s=r.x0,l=r.x1,a=r.y0,u=r.y1,c=o.useTheme(),p=o.useMotionConfig(),x=p.animate,h=p.config,d=t.useMemo((function(){return n({},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,n({},y,{fill:"none",style:d}))}));x.displayName="CrosshairLine";var h=t.memo((function(t){var e,o,n=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:n,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:n,y0:a,y1:a}):"right"===s?o={x0:l,x1:n,y0:a,y1:a}:"bottom-right"===s?(e={x0:l,x1:l,y0:a,y1:r},o={x0:l,x1:n,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:n,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],n=o[1],r=t.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=t.useCallback((function(t,o,i){void 0===i&&(i="top");var r=e.current.getBoundingClientRect(),s=e.current.offsetWidth,l=s===r.width?1:s/r.width,a="touches"in o?o.touches[0]:o,u=a.clientX,c=a.clientY,p=(u-r.left)*l,x=(c-r.top)*l;"left"!==i&&"right"!==i||(i=p<r.width/2?"right":"left"),n({isVisible:!0,position:[p,x],anchor:i,content:t})}),[e,n]),l=t.useCallback((function(){n(y)}),[n]);return{actions:t.useMemo((function(){return{showTooltipAt:r,showTooltipFromEvent:s,hideTooltip:l}}),[r,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,n=v(e),r=n.actions,s=n.state;return i.jsx(d.Provider,{value:r,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";var t=require("react"),e=require("@react-spring/web"),o=require("@nivo/core"),i=require("react/jsx-runtime");function r(){return r=Object.assign?Object.assign.bind():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,w=m.width>0&&m.height>0,j=Math.round(u[0]),C=Math.round(u[1]);w&&("top"===c?(j-=m.width/2,C-=m.height+14):"right"===c?(j+=14,C-=m.height/2):"bottom"===c?(j-=m.width/2,C+=14):"left"===c?(j-=m.width+14,C-=m.height/2):"center"===c&&(j-=m.width/2,C-=m.height/2),g={transform:s(j,C)},b.current||(T=!0),b.current=[j,C]);var S=e.useSpring({to:g,config:y,immediate:!d||T}),M=r({},n,x.tooltip.wrapper,{transform:null!=(a=S.transform)?a:s(j,C),opacity:S.transform?1:0});return i.jsx(e.animated.div,{ref:v,style:M,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="touches"in o?o.touches[0]:o,u=a.clientX,c=a.clientY,p=(u-n.left)*l,x=(c-n.top)*l;"left"!==i&&"right"!==i||(i=p<n.width/2?"right":"left"),r({isVisible:!0,position:[p,x],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 @@

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

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

"dependencies": {
"@nivo/core": "0.85.1",
"@nivo/core": "0.86.0",
"@react-spring/web": "9.4.5 || ^9.7.2"

@@ -34,3 +34,3 @@ },

},
"gitHead": "06bb46f82832d132c4e1bce56f57d056eba2a5fd"
"gitHead": "6996fc1a0f0d3ee20ec002316e4d0d3aeddbd4ed"
}

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