You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@nivo/tooltip

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

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

{"version":3,"file":"nivo-tooltip.cjs.js","sources":["../src/TooltipWrapper.tsx","../src/Chip.tsx","../src/BasicTooltip.tsx","../src/TableTooltip.tsx","../src/CrosshairLine.tsx","../src/Crosshair.tsx","../src/context.ts","../src/hooks.ts","../src/Tooltip.tsx","../src/TooltipProvider.tsx"],"sourcesContent":["import { memo, useRef, PropsWithChildren, CSSProperties } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport {\n useTheme,\n useMotionConfig,\n // @ts-ignore\n useMeasure,\n} from '@nivo/core'\nimport { TooltipStateContextDataVisible } from './context'\n\nconst TOOLTIP_OFFSET = 14\n\nconst tooltipStyle: Partial<CSSProperties> = {\n pointerEvents: 'none',\n position: 'absolute',\n zIndex: 10,\n top: 0,\n left: 0,\n}\n\nconst translate = (x: number, y: number) => `translate(${x}px, ${y}px)`\n\ninterface TooltipWrapperProps {\n position: TooltipStateContextDataVisible['position']\n anchor: TooltipStateContextDataVisible['anchor']\n}\n\nexport const TooltipWrapper = memo<PropsWithChildren<TooltipWrapperProps>>(\n ({ position, anchor, children }) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const [measureRef, bounds] = useMeasure()\n const previousPosition = useRef<[number, number] | false>(false)\n\n let to = undefined\n let immediate = false\n const hasDimension = bounds.width > 0 && bounds.height > 0\n\n let x = Math.round(position[0])\n let y = Math.round(position[1])\n\n if (hasDimension) {\n if (anchor === 'top') {\n x -= bounds.width / 2\n y -= bounds.height + TOOLTIP_OFFSET\n } else if (anchor === 'right') {\n x += TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'bottom') {\n x -= bounds.width / 2\n y += TOOLTIP_OFFSET\n } else if (anchor === 'left') {\n x -= bounds.width + TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'center') {\n x -= bounds.width / 2\n y -= bounds.height / 2\n }\n\n to = {\n transform: translate(x, y),\n }\n\n if (!previousPosition.current) {\n immediate = true\n }\n\n previousPosition.current = [x, y]\n }\n\n const animatedProps = useSpring<{\n transform: string\n }>({\n to,\n config: springConfig,\n immediate: !animate || immediate,\n })\n\n const style = {\n ...tooltipStyle,\n ...theme.tooltip.wrapper,\n transform: animatedProps.transform ?? translate(x, y),\n opacity: animatedProps.transform ? 1 : 0,\n }\n\n return (\n <animated.div ref={measureRef} style={style}>\n {children}\n </animated.div>\n )\n }\n)\n\nTooltipWrapper.displayName = 'TooltipWrapper'\n","import { CSSProperties, memo } from 'react'\n\ninterface ChipProps {\n size?: number\n color: string\n style?: CSSProperties\n}\n\nexport const Chip = memo<ChipProps>(({ size = 12, color, style = {} }) => (\n <span style={{ display: 'block', width: size, height: size, background: color, ...style }} />\n))\n","import { memo, ReactNode } from 'react'\nimport { useTheme, ValueFormat, useValueFormatter } from '@nivo/core'\nimport { Chip } from './Chip'\n\nexport interface BasicTooltipProps {\n id: ReactNode\n value?: number | string | Date\n format?: ValueFormat<number | string | Date>\n color?: string\n enableChip?: boolean\n /**\n * @deprecated This should be replaced by custom tooltip components.\n */\n renderContent?: () => JSX.Element\n}\n\nexport const BasicTooltip = memo<BasicTooltipProps>(\n ({ id, value: _value, format, enableChip = false, color, renderContent }) => {\n const theme = useTheme()\n const formatValue = useValueFormatter<number | string | Date>(format)\n\n let content: JSX.Element\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n let value = _value\n if (formatValue !== undefined && value !== undefined) {\n value = formatValue(value)\n }\n content = (\n <div style={theme.tooltip.basic}>\n {enableChip && <Chip color={color!} style={theme.tooltip.chip} />}\n {value !== undefined ? (\n <span>\n {id}: <strong>{`${value}`}</strong>\n </span>\n ) : (\n id\n )}\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n }\n)\n","import { CSSProperties, memo, ReactNode } from 'react'\nimport { useTheme } from '@nivo/core'\n\nconst tableStyle = {\n width: '100%',\n borderCollapse: 'collapse' as CSSProperties['borderCollapse'],\n}\n\ninterface TableTooltipProps {\n title?: ReactNode\n renderContent?: () => JSX.Element\n rows?: ReactNode[][]\n}\n\nexport const TableTooltip = memo(({ title, rows = [], renderContent }: TableTooltipProps) => {\n const theme = useTheme()\n\n if (!rows.length) return null\n\n let content\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n content = (\n <div>\n {title && title}\n <table style={{ ...tableStyle, ...theme.tooltip.table }}>\n <tbody>\n {rows.map((row, i) => (\n <tr key={i}>\n {row.map((column, j) => (\n <td key={j} style={theme.tooltip.tableCell}>\n {column}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n})\n\nTableTooltip.displayName = 'TableTooltip'\n","import { CSSProperties, memo, useMemo } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport { useTheme, useMotionConfig } from '@nivo/core'\n\ninterface CrosshairLineProps {\n x0: number\n x1: number\n y0: number\n y1: number\n}\n\nexport const CrosshairLine = memo(({ x0, x1, y0, y1 }: CrosshairLineProps) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const style = useMemo(\n () => ({\n ...theme.crosshair.line,\n pointerEvents: 'none' as CSSProperties['pointerEvents'],\n }),\n [theme.crosshair.line]\n )\n\n const animatedProps = useSpring({\n x1: x0,\n x2: x1,\n y1: y0,\n y2: y1,\n config: springConfig,\n immediate: !animate,\n })\n\n return <animated.line {...animatedProps} fill=\"none\" style={style} />\n})\n\nCrosshairLine.displayName = 'CrosshairLine'\n","import { memo } from 'react'\nimport { CrosshairLine } from './CrosshairLine'\nimport { CrosshairType } from './types'\n\ninterface CrosshairProps {\n width: number\n height: number\n type: CrosshairType\n x: number\n y: number\n}\n\nexport const Crosshair = memo(({ width, height, type, x, y }: CrosshairProps) => {\n let xLine\n let yLine\n if (type === 'cross') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n } else if (type === 'top-left') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'top') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n } else if (type === 'top-right') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'right') {\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom-right') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n } else if (type === 'bottom-left') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'left') {\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'x') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n } else if (type === 'y') {\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n }\n\n return (\n <>\n {xLine && <CrosshairLine x0={xLine.x0} x1={xLine.x1} y0={xLine.y0} y1={xLine.y1} />}\n {yLine && <CrosshairLine x0={yLine.x0} x1={yLine.x1} y0={yLine.y0} y1={yLine.y1} />}\n </>\n )\n})\n\nCrosshair.displayName = 'Crosshair'\n","import { createContext, MouseEvent, TouchEvent } from 'react'\nimport { TooltipAnchor } from './types'\n\nexport interface TooltipActionsContextData {\n showTooltipAt: (\n content: JSX.Element,\n position: [number, number],\n anchor?: TooltipAnchor\n ) => void\n showTooltipFromEvent: (\n content: JSX.Element,\n event: MouseEvent | TouchEvent,\n anchor?: TooltipAnchor\n ) => void\n hideTooltip: () => void\n}\n\nconst defaultActions: TooltipActionsContextData = {\n showTooltipAt: () => {},\n showTooltipFromEvent: () => {},\n hideTooltip: () => {},\n}\n\nexport const TooltipActionsContext = createContext<TooltipActionsContextData>(defaultActions)\n\nexport interface TooltipStateContextDataVisible {\n isVisible: true\n position: [number, number]\n content: JSX.Element\n anchor: TooltipAnchor\n}\n\nexport interface TooltipStateContextDataHidden {\n isVisible: false\n position: [null, null]\n content: null\n anchor: null\n}\n\nexport type TooltipStateContextData = TooltipStateContextDataVisible | TooltipStateContextDataHidden\n\nexport const hiddenTooltipState: TooltipStateContextDataHidden = {\n isVisible: false,\n position: [null, null],\n content: null,\n anchor: null,\n}\n\nexport const TooltipStateContext = createContext<TooltipStateContextData>(hiddenTooltipState)\n","import {\n useState,\n useContext,\n useCallback,\n MutableRefObject,\n MouseEvent,\n TouchEvent,\n useMemo,\n} from 'react'\nimport {\n TooltipActionsContext,\n TooltipActionsContextData,\n TooltipStateContext,\n TooltipStateContextData,\n hiddenTooltipState,\n} from './context'\nimport { TooltipAnchor } from './types'\n\nexport const useTooltipHandlers = (container: MutableRefObject<HTMLDivElement>) => {\n const [state, setState] = useState<TooltipStateContextData>(hiddenTooltipState)\n\n const showTooltipAt: TooltipActionsContextData['showTooltipAt'] = useCallback(\n (content: JSX.Element, [x, y]: [number, number], anchor: TooltipAnchor = 'top') => {\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [setState]\n )\n\n const showTooltipFromEvent: TooltipActionsContextData['showTooltipFromEvent'] = useCallback(\n (content: JSX.Element, event: MouseEvent | TouchEvent, anchor: TooltipAnchor = 'top') => {\n const bounds = container.current.getBoundingClientRect()\n const offsetWidth = container.current.offsetWidth\n // In a normal situation mouse enter / mouse leave events\n // capture the position ok. But when the chart is inside a scaled\n // element with a CSS transform like: `transform: scale(2);`\n // tooltip are not positioned ok.\n // Comparing original width `offsetWidth` agains scaled\n // width give us the scaling factor to calculate\n // ok mouse position\n const scaling = offsetWidth === bounds.width ? 1 : offsetWidth / bounds.width\n const { clientX, clientY } = 'touches' in event ? event.touches[0] : event\n const x = (clientX - bounds.left) * scaling\n const y = (clientY - bounds.top) * scaling\n\n if (anchor === 'left' || anchor === 'right') {\n if (x < bounds.width / 2) anchor = 'right'\n else anchor = 'left'\n }\n\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [container, setState]\n )\n\n const hideTooltip = useCallback(() => {\n setState(hiddenTooltipState)\n }, [setState])\n\n const actions: TooltipActionsContextData = useMemo(() => {\n return {\n showTooltipAt,\n showTooltipFromEvent,\n hideTooltip,\n }\n }, [showTooltipAt, showTooltipFromEvent, hideTooltip])\n\n return {\n actions,\n state,\n }\n}\n\nexport const useTooltip = () => {\n const context = useContext(TooltipActionsContext)\n if (context === undefined) {\n throw new Error('useTooltip must be used within a TooltipProvider')\n }\n\n return context\n}\n\nexport const useTooltipState = () => {\n const context = useContext(TooltipStateContext)\n if (context === undefined) {\n throw new Error('useTooltipState must be used within a TooltipProvider')\n }\n\n return context\n}\n","import { useTooltipState } from './hooks'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TooltipStateContextData, TooltipStateContextDataVisible } from './context'\n\nexport const isVisibleTooltipState = (\n state: TooltipStateContextData\n): state is TooltipStateContextDataVisible => state.isVisible\n\nexport const Tooltip = () => {\n const state = useTooltipState()\n\n if (!isVisibleTooltipState(state)) {\n return null\n }\n\n return (\n <TooltipWrapper position={state.position} anchor={state.anchor}>\n {state.content}\n </TooltipWrapper>\n )\n}\n","import { PropsWithChildren, MutableRefObject } from 'react'\nimport { TooltipActionsContext, TooltipStateContext } from './context'\nimport { useTooltipHandlers } from './hooks'\n\ninterface TooltipProviderProps {\n container: MutableRefObject<HTMLDivElement>\n}\n\nexport const TooltipProvider = ({\n container,\n children,\n}: PropsWithChildren<TooltipProviderProps>) => {\n const { actions, state } = useTooltipHandlers(container)\n\n return (\n <TooltipActionsContext.Provider value={actions}>\n <TooltipStateContext.Provider value={state}>{children}</TooltipStateContext.Provider>\n </TooltipActionsContext.Provider>\n )\n}\n"],"names":["tooltipStyle","pointerEvents","position","zIndex","top","left","translate","x","y","TooltipWrapper","memo","_ref","_animatedProps$transf","anchor","children","theme","useTheme","_useMotionConfig","useMotionConfig","animate","springConfig","config","_useMeasure","useMeasure","measureRef","bounds","previousPosition","useRef","to","undefined","immediate","hasDimension","width","height","Math","round","transform","current","animatedProps","useSpring","style","_extends","tooltip","wrapper","opacity","_jsx","jsx","animated","div","ref","displayName","Chip","_ref$size","size","color","_ref$style","display","background","BasicTooltip","content","id","_value","value","format","_ref$enableChip","enableChip","renderContent","formatValue","useValueFormatter","_jsxs","jsxs","basic","chip","container","tableStyle","borderCollapse","TableTooltip","title","_ref$rows","rows","length","table","map","row","i","column","j","tableCell","CrosshairLine","x0","x1","y0","y1","useMemo","crosshair","line","x2","y2","fill","Crosshair","xLine","yLine","type","_Fragment","TooltipActionsContext","createContext","showTooltipAt","showTooltipFromEvent","hideTooltip","hiddenTooltipState","isVisible","TooltipStateContext","useTooltipHandlers","_useState","useState","state","setState","useCallback","event","getBoundingClientRect","offsetWidth","scaling","_ref2","touches","clientX","clientY","actions","useTooltipState","context","useContext","Error","isVisibleTooltipState","_useTooltipHandlers","Provider"],"mappings":"kVAUA,IAEMA,EAAuC,CACzCC,cAAe,OACfC,SAAU,WACVC,OAAQ,GACRC,IAAK,EACLC,KAAM,GAGJC,EAAY,SAACC,EAAWC,GAAS,MAAkBD,aAAAA,SAAQC,EAAC,KAAA,EAOrDC,EAAiBC,EAAAA,MA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AQH,EAARG,SAEAsH,EAA2BpB,EAAmBvC,GAAtCqD,EAAOM,EAAPN,QAASX,EAAKiB,EAALjB,MAEjB,OACItE,EAAAC,IAAC0D,EAAsB6B,SAAQ,CAACvE,MAAOgE,EAAQhH,SAC3C+B,EAAAA,IAACkE,EAAoBsB,SAAQ,CAACvE,MAAOqD,EAAMrG,SAAEA,KAGzD,yIF+D0B,WACtB,IAAMkH,EAAUC,aAAWzB,GAC3B,QAAgB3E,IAAZmG,EACA,MAAM,IAAIE,MAAM,oDAGpB,OAAOF,CACX"}
{"version":3,"file":"nivo-tooltip.cjs.js","sources":["../src/TooltipWrapper.tsx","../src/Chip.tsx","../src/BasicTooltip.tsx","../src/TableTooltip.tsx","../src/CrosshairLine.tsx","../src/Crosshair.tsx","../src/context.ts","../src/hooks.ts","../src/Tooltip.tsx","../src/TooltipProvider.tsx"],"sourcesContent":["import { memo, useRef, PropsWithChildren, CSSProperties } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport {\n useMotionConfig,\n // @ts-ignore\n useMeasure,\n} from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\nimport { TooltipStateContextDataVisible } from './context'\n\nconst TOOLTIP_OFFSET = 14\n\nconst tooltipStyle: Partial<CSSProperties> = {\n pointerEvents: 'none',\n position: 'absolute',\n zIndex: 10,\n top: 0,\n left: 0,\n}\n\nconst translate = (x: number, y: number) => `translate(${x}px, ${y}px)`\n\ninterface TooltipWrapperProps {\n position: TooltipStateContextDataVisible['position']\n anchor: TooltipStateContextDataVisible['anchor']\n}\n\nexport const TooltipWrapper = memo<PropsWithChildren<TooltipWrapperProps>>(\n ({ position, anchor, children }) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const [measureRef, bounds] = useMeasure()\n const previousPosition = useRef<[number, number] | false>(false)\n\n let to = undefined\n let immediate = false\n const hasDimension = bounds.width > 0 && bounds.height > 0\n\n let x = Math.round(position[0])\n let y = Math.round(position[1])\n\n if (hasDimension) {\n if (anchor === 'top') {\n x -= bounds.width / 2\n y -= bounds.height + TOOLTIP_OFFSET\n } else if (anchor === 'right') {\n x += TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'bottom') {\n x -= bounds.width / 2\n y += TOOLTIP_OFFSET\n } else if (anchor === 'left') {\n x -= bounds.width + TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'center') {\n x -= bounds.width / 2\n y -= bounds.height / 2\n }\n\n to = {\n transform: translate(x, y),\n }\n\n if (!previousPosition.current) {\n immediate = true\n }\n\n previousPosition.current = [x, y]\n }\n\n const animatedProps = useSpring<{\n transform: string\n }>({\n to,\n config: springConfig,\n immediate: !animate || immediate,\n })\n\n const { basic, chip, container, table, tableCell, tableCellValue, ...defaultStyle } =\n theme.tooltip\n\n const style = {\n ...tooltipStyle,\n ...defaultStyle,\n transform: animatedProps.transform ?? translate(x, y),\n opacity: animatedProps.transform ? 1 : 0,\n }\n\n return (\n <animated.div ref={measureRef} style={style}>\n {children}\n </animated.div>\n )\n }\n)\n\nTooltipWrapper.displayName = 'TooltipWrapper'\n","import { CSSProperties, memo } from 'react'\n\ninterface ChipProps {\n size?: number\n color: string\n style?: CSSProperties\n}\n\nexport const Chip = memo<ChipProps>(({ size = 12, color, style = {} }) => (\n <span style={{ display: 'block', width: size, height: size, background: color, ...style }} />\n))\n","import { memo, ReactNode } from 'react'\nimport { ValueFormat, useValueFormatter } from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\nimport { Chip } from './Chip'\n\nexport interface BasicTooltipProps {\n id: ReactNode\n value?: number | string | Date\n format?: ValueFormat<number | string | Date>\n color?: string\n enableChip?: boolean\n /**\n * @deprecated This should be replaced by custom tooltip components.\n */\n renderContent?: () => JSX.Element\n}\n\nexport const BasicTooltip = memo<BasicTooltipProps>(\n ({ id, value: _value, format, enableChip = false, color, renderContent }) => {\n const theme = useTheme()\n const formatValue = useValueFormatter<number | string | Date>(format)\n\n let content: JSX.Element\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n let value = _value\n if (formatValue !== undefined && value !== undefined) {\n value = formatValue(value)\n }\n content = (\n <div style={theme.tooltip.basic}>\n {enableChip && <Chip color={color!} style={theme.tooltip.chip} />}\n {value !== undefined ? (\n <span>\n {id}: <strong>{`${value}`}</strong>\n </span>\n ) : (\n id\n )}\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n }\n)\n","import { CSSProperties, memo, ReactNode } from 'react'\nimport { useTheme } from '@nivo/theming'\n\nconst tableStyle = {\n width: '100%',\n borderCollapse: 'collapse' as CSSProperties['borderCollapse'],\n}\n\ninterface TableTooltipProps {\n title?: ReactNode\n renderContent?: () => JSX.Element\n rows?: ReactNode[][]\n}\n\nexport const TableTooltip = memo(({ title, rows = [], renderContent }: TableTooltipProps) => {\n const theme = useTheme()\n\n if (!rows.length) return null\n\n let content\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n content = (\n <div>\n {title && title}\n <table style={{ ...tableStyle, ...theme.tooltip.table }}>\n <tbody>\n {rows.map((row, i) => (\n <tr key={i}>\n {row.map((column, j) => (\n <td key={j} style={theme.tooltip.tableCell}>\n {column}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n})\n\nTableTooltip.displayName = 'TableTooltip'\n","import { CSSProperties, memo, useMemo } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport { useMotionConfig } from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\n\ninterface CrosshairLineProps {\n x0: number\n x1: number\n y0: number\n y1: number\n}\n\nexport const CrosshairLine = memo(({ x0, x1, y0, y1 }: CrosshairLineProps) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const style = useMemo(\n () => ({\n ...theme.crosshair.line,\n pointerEvents: 'none' as CSSProperties['pointerEvents'],\n }),\n [theme.crosshair.line]\n )\n\n const animatedProps = useSpring({\n x1: x0,\n x2: x1,\n y1: y0,\n y2: y1,\n config: springConfig,\n immediate: !animate,\n })\n\n return <animated.line {...animatedProps} fill=\"none\" style={style} />\n})\n\nCrosshairLine.displayName = 'CrosshairLine'\n","import { memo } from 'react'\nimport { CrosshairLine } from './CrosshairLine'\nimport { CrosshairType } from './types'\n\ninterface CrosshairProps {\n width: number\n height: number\n type: CrosshairType\n x: number\n y: number\n}\n\nexport const Crosshair = memo(({ width, height, type, x, y }: CrosshairProps) => {\n let xLine\n let yLine\n if (type === 'cross') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n } else if (type === 'top-left') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'top') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n } else if (type === 'top-right') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'right') {\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom-right') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n } else if (type === 'bottom-left') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'left') {\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'x') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n } else if (type === 'y') {\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n }\n\n return (\n <>\n {xLine && <CrosshairLine x0={xLine.x0} x1={xLine.x1} y0={xLine.y0} y1={xLine.y1} />}\n {yLine && <CrosshairLine x0={yLine.x0} x1={yLine.x1} y0={yLine.y0} y1={yLine.y1} />}\n </>\n )\n})\n\nCrosshair.displayName = 'Crosshair'\n","import { createContext, MouseEvent, TouchEvent } from 'react'\nimport { TooltipAnchor } from './types'\n\nexport interface TooltipActionsContextData {\n showTooltipAt: (\n content: JSX.Element,\n position: [number, number],\n anchor?: TooltipAnchor\n ) => void\n showTooltipFromEvent: (\n content: JSX.Element,\n event: MouseEvent | TouchEvent,\n anchor?: TooltipAnchor\n ) => void\n hideTooltip: () => void\n}\n\nconst defaultActions: TooltipActionsContextData = {\n showTooltipAt: () => {},\n showTooltipFromEvent: () => {},\n hideTooltip: () => {},\n}\n\nexport const TooltipActionsContext = createContext<TooltipActionsContextData>(defaultActions)\n\nexport interface TooltipStateContextDataVisible {\n isVisible: true\n position: [number, number]\n content: JSX.Element\n anchor: TooltipAnchor\n}\n\nexport interface TooltipStateContextDataHidden {\n isVisible: false\n position: [null, null]\n content: null\n anchor: null\n}\n\nexport type TooltipStateContextData = TooltipStateContextDataVisible | TooltipStateContextDataHidden\n\nexport const hiddenTooltipState: TooltipStateContextDataHidden = {\n isVisible: false,\n position: [null, null],\n content: null,\n anchor: null,\n}\n\nexport const TooltipStateContext = createContext<TooltipStateContextData>(hiddenTooltipState)\n","import {\n useState,\n useContext,\n useCallback,\n MutableRefObject,\n MouseEvent,\n TouchEvent,\n useMemo,\n} from 'react'\nimport {\n TooltipActionsContext,\n TooltipActionsContextData,\n TooltipStateContext,\n TooltipStateContextData,\n hiddenTooltipState,\n} from './context'\nimport { TooltipAnchor } from './types'\n\nexport const useTooltipHandlers = (container: MutableRefObject<HTMLDivElement>) => {\n const [state, setState] = useState<TooltipStateContextData>(hiddenTooltipState)\n\n const showTooltipAt: TooltipActionsContextData['showTooltipAt'] = useCallback(\n (content: JSX.Element, [x, y]: [number, number], anchor: TooltipAnchor = 'top') => {\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [setState]\n )\n\n const showTooltipFromEvent: TooltipActionsContextData['showTooltipFromEvent'] = useCallback(\n (content: JSX.Element, event: MouseEvent | TouchEvent, anchor: TooltipAnchor = 'top') => {\n const bounds = container.current.getBoundingClientRect()\n const offsetWidth = container.current.offsetWidth\n // In a normal situation mouse enter / mouse leave events\n // capture the position ok. But when the chart is inside a scaled\n // element with a CSS transform like: `transform: scale(2);`\n // tooltip are not positioned ok.\n // Comparing original width `offsetWidth` agains scaled\n // width give us the scaling factor to calculate\n // ok mouse position\n const scaling = offsetWidth === bounds.width ? 1 : offsetWidth / bounds.width\n const { clientX, clientY } = 'touches' in event ? event.touches[0] : event\n const x = (clientX - bounds.left) * scaling\n const y = (clientY - bounds.top) * scaling\n\n if (anchor === 'left' || anchor === 'right') {\n if (x < bounds.width / 2) anchor = 'right'\n else anchor = 'left'\n }\n\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [container, setState]\n )\n\n const hideTooltip = useCallback(() => {\n setState(hiddenTooltipState)\n }, [setState])\n\n const actions: TooltipActionsContextData = useMemo(() => {\n return {\n showTooltipAt,\n showTooltipFromEvent,\n hideTooltip,\n }\n }, [showTooltipAt, showTooltipFromEvent, hideTooltip])\n\n return {\n actions,\n state,\n }\n}\n\nexport const useTooltip = () => {\n const context = useContext(TooltipActionsContext)\n if (context === undefined) {\n throw new Error('useTooltip must be used within a TooltipProvider')\n }\n\n return context\n}\n\nexport const useTooltipState = () => {\n const context = useContext(TooltipStateContext)\n if (context === undefined) {\n throw new Error('useTooltipState must be used within a TooltipProvider')\n }\n\n return context\n}\n","import { useTooltipState } from './hooks'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TooltipStateContextData, TooltipStateContextDataVisible } from './context'\n\nexport const isVisibleTooltipState = (\n state: TooltipStateContextData\n): state is TooltipStateContextDataVisible => state.isVisible\n\nexport const Tooltip = () => {\n const state = useTooltipState()\n\n if (!isVisibleTooltipState(state)) {\n return null\n }\n\n return (\n <TooltipWrapper position={state.position} anchor={state.anchor}>\n {state.content}\n </TooltipWrapper>\n )\n}\n","import { PropsWithChildren, MutableRefObject } from 'react'\nimport { TooltipActionsContext, TooltipStateContext } from './context'\nimport { useTooltipHandlers } from './hooks'\n\ninterface TooltipProviderProps {\n container: MutableRefObject<HTMLDivElement>\n}\n\nexport const TooltipProvider = ({\n container,\n children,\n}: PropsWithChildren<TooltipProviderProps>) => {\n const { actions, state } = useTooltipHandlers(container)\n\n return (\n <TooltipActionsContext.Provider value={actions}>\n <TooltipStateContext.Provider value={state}>{children}</TooltipStateContext.Provider>\n </TooltipActionsContext.Provider>\n )\n}\n"],"names":["tooltipStyle","pointerEvents","position","zIndex","top","left","translate","x","y","TooltipWrapper","memo","_ref","_animatedProps$transf","anchor","children","theme","useTheme","_useMotionConfig","useMotionConfig","animate","springConfig","config","_useMeasure","useMeasure","measureRef","bounds","previousPosition","useRef","to","undefined","immediate","hasDimension","width","height","Math","round","transform","current","animatedProps","useSpring","_theme$tooltip","tooltip","basic","chip","container","table","tableCell","tableCellValue","defaultStyle","_objectWithoutPropertiesLoose","_excluded","style","_extends","opacity","_jsx","jsx","animated","div","ref","displayName","Chip","_ref$size","size","color","_ref$style","display","background","BasicTooltip","content","id","_value","value","format","_ref$enableChip","enableChip","renderContent","formatValue","useValueFormatter","_jsxs","jsxs","tableStyle","borderCollapse","TableTooltip","title","_ref$rows","rows","length","map","row","i","column","j","CrosshairLine","x0","x1","y0","y1","useMemo","crosshair","line","x2","y2","fill","Crosshair","xLine","yLine","type","_Fragment","TooltipActionsContext","createContext","showTooltipAt","showTooltipFromEvent","hideTooltip","hiddenTooltipState","isVisible","TooltipStateContext","useTooltipHandlers","_useState","useState","state","setState","useCallback","event","getBoundingClientRect","offsetWidth","scaling","_ref2","touches","clientX","clientY","actions","useTooltipState","context","useContext","Error","isVisibleTooltipState","_useTooltipHandlers","Provider"],"mappings":"qbAYMA,EAAuC,CACzCC,cAAe,OACfC,SAAU,WACVC,OAAQ,GACRC,IAAK,EACLC,KAAM,GAGJC,EAAY,SAACC,EAAWC,GAAS,MAAkBD,aAAAA,SAAQC,EAAC,KAAA,EAOrDC,EAAiBC,EAAAA,MAC1B,SAAAC,GAAoC,IAAAC,EA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C1DyG,EAAMnD,UALJ,IAQf,0DCZ+B,SAAHzD,GAGmB,IAF3CiC,EAASjC,EAATiC,UACA9B,EAAQH,EAARG,SAEA0H,EAA2BpB,EAAmBxE,GAAtCsF,EAAOM,EAAPN,QAASX,EAAKiB,EAALjB,MAEjB,OACIjE,EAAAC,IAACqD,EAAsB6B,SAAQ,CAAClE,MAAO2D,EAAQpH,SAC3CwC,EAAAA,IAAC6D,EAAoBsB,SAAQ,CAAClE,MAAOgD,EAAMzG,SAAEA,KAGzD,yIF+D0B,WACtB,IAAMsH,EAAUC,aAAWzB,GAC3B,QAAgB/E,IAAZuG,EACA,MAAM,IAAIE,MAAM,oDAGpB,OAAOF,CACX"}

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

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

{"version":3,"file":"nivo-tooltip.mjs","sources":["../src/TooltipWrapper.tsx","../src/Chip.tsx","../src/BasicTooltip.tsx","../src/TableTooltip.tsx","../src/CrosshairLine.tsx","../src/Crosshair.tsx","../src/context.ts","../src/hooks.ts","../src/Tooltip.tsx","../src/TooltipProvider.tsx"],"sourcesContent":["import { memo, useRef, PropsWithChildren, CSSProperties } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport {\n useTheme,\n useMotionConfig,\n // @ts-ignore\n useMeasure,\n} from '@nivo/core'\nimport { TooltipStateContextDataVisible } from './context'\n\nconst TOOLTIP_OFFSET = 14\n\nconst tooltipStyle: Partial<CSSProperties> = {\n pointerEvents: 'none',\n position: 'absolute',\n zIndex: 10,\n top: 0,\n left: 0,\n}\n\nconst translate = (x: number, y: number) => `translate(${x}px, ${y}px)`\n\ninterface TooltipWrapperProps {\n position: TooltipStateContextDataVisible['position']\n anchor: TooltipStateContextDataVisible['anchor']\n}\n\nexport const TooltipWrapper = memo<PropsWithChildren<TooltipWrapperProps>>(\n ({ position, anchor, children }) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const [measureRef, bounds] = useMeasure()\n const previousPosition = useRef<[number, number] | false>(false)\n\n let to = undefined\n let immediate = false\n const hasDimension = bounds.width > 0 && bounds.height > 0\n\n let x = Math.round(position[0])\n let y = Math.round(position[1])\n\n if (hasDimension) {\n if (anchor === 'top') {\n x -= bounds.width / 2\n y -= bounds.height + TOOLTIP_OFFSET\n } else if (anchor === 'right') {\n x += TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'bottom') {\n x -= bounds.width / 2\n y += TOOLTIP_OFFSET\n } else if (anchor === 'left') {\n x -= bounds.width + TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'center') {\n x -= bounds.width / 2\n y -= bounds.height / 2\n }\n\n to = {\n transform: translate(x, y),\n }\n\n if (!previousPosition.current) {\n immediate = true\n }\n\n previousPosition.current = [x, y]\n }\n\n const animatedProps = useSpring<{\n transform: string\n }>({\n to,\n config: springConfig,\n immediate: !animate || immediate,\n })\n\n const style = {\n ...tooltipStyle,\n ...theme.tooltip.wrapper,\n transform: animatedProps.transform ?? translate(x, y),\n opacity: animatedProps.transform ? 1 : 0,\n }\n\n return (\n <animated.div ref={measureRef} style={style}>\n {children}\n </animated.div>\n )\n }\n)\n\nTooltipWrapper.displayName = 'TooltipWrapper'\n","import { CSSProperties, memo } from 'react'\n\ninterface ChipProps {\n size?: number\n color: string\n style?: CSSProperties\n}\n\nexport const Chip = memo<ChipProps>(({ size = 12, color, style = {} }) => (\n <span style={{ display: 'block', width: size, height: size, background: color, ...style }} />\n))\n","import { memo, ReactNode } from 'react'\nimport { useTheme, ValueFormat, useValueFormatter } from '@nivo/core'\nimport { Chip } from './Chip'\n\nexport interface BasicTooltipProps {\n id: ReactNode\n value?: number | string | Date\n format?: ValueFormat<number | string | Date>\n color?: string\n enableChip?: boolean\n /**\n * @deprecated This should be replaced by custom tooltip components.\n */\n renderContent?: () => JSX.Element\n}\n\nexport const BasicTooltip = memo<BasicTooltipProps>(\n ({ id, value: _value, format, enableChip = false, color, renderContent }) => {\n const theme = useTheme()\n const formatValue = useValueFormatter<number | string | Date>(format)\n\n let content: JSX.Element\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n let value = _value\n if (formatValue !== undefined && value !== undefined) {\n value = formatValue(value)\n }\n content = (\n <div style={theme.tooltip.basic}>\n {enableChip && <Chip color={color!} style={theme.tooltip.chip} />}\n {value !== undefined ? (\n <span>\n {id}: <strong>{`${value}`}</strong>\n </span>\n ) : (\n id\n )}\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n }\n)\n","import { CSSProperties, memo, ReactNode } from 'react'\nimport { useTheme } from '@nivo/core'\n\nconst tableStyle = {\n width: '100%',\n borderCollapse: 'collapse' as CSSProperties['borderCollapse'],\n}\n\ninterface TableTooltipProps {\n title?: ReactNode\n renderContent?: () => JSX.Element\n rows?: ReactNode[][]\n}\n\nexport const TableTooltip = memo(({ title, rows = [], renderContent }: TableTooltipProps) => {\n const theme = useTheme()\n\n if (!rows.length) return null\n\n let content\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n content = (\n <div>\n {title && title}\n <table style={{ ...tableStyle, ...theme.tooltip.table }}>\n <tbody>\n {rows.map((row, i) => (\n <tr key={i}>\n {row.map((column, j) => (\n <td key={j} style={theme.tooltip.tableCell}>\n {column}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n})\n\nTableTooltip.displayName = 'TableTooltip'\n","import { CSSProperties, memo, useMemo } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport { useTheme, useMotionConfig } from '@nivo/core'\n\ninterface CrosshairLineProps {\n x0: number\n x1: number\n y0: number\n y1: number\n}\n\nexport const CrosshairLine = memo(({ x0, x1, y0, y1 }: CrosshairLineProps) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const style = useMemo(\n () => ({\n ...theme.crosshair.line,\n pointerEvents: 'none' as CSSProperties['pointerEvents'],\n }),\n [theme.crosshair.line]\n )\n\n const animatedProps = useSpring({\n x1: x0,\n x2: x1,\n y1: y0,\n y2: y1,\n config: springConfig,\n immediate: !animate,\n })\n\n return <animated.line {...animatedProps} fill=\"none\" style={style} />\n})\n\nCrosshairLine.displayName = 'CrosshairLine'\n","import { memo } from 'react'\nimport { CrosshairLine } from './CrosshairLine'\nimport { CrosshairType } from './types'\n\ninterface CrosshairProps {\n width: number\n height: number\n type: CrosshairType\n x: number\n y: number\n}\n\nexport const Crosshair = memo(({ width, height, type, x, y }: CrosshairProps) => {\n let xLine\n let yLine\n if (type === 'cross') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n } else if (type === 'top-left') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'top') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n } else if (type === 'top-right') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'right') {\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom-right') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n } else if (type === 'bottom-left') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'left') {\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'x') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n } else if (type === 'y') {\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n }\n\n return (\n <>\n {xLine && <CrosshairLine x0={xLine.x0} x1={xLine.x1} y0={xLine.y0} y1={xLine.y1} />}\n {yLine && <CrosshairLine x0={yLine.x0} x1={yLine.x1} y0={yLine.y0} y1={yLine.y1} />}\n </>\n )\n})\n\nCrosshair.displayName = 'Crosshair'\n","import { createContext, MouseEvent, TouchEvent } from 'react'\nimport { TooltipAnchor } from './types'\n\nexport interface TooltipActionsContextData {\n showTooltipAt: (\n content: JSX.Element,\n position: [number, number],\n anchor?: TooltipAnchor\n ) => void\n showTooltipFromEvent: (\n content: JSX.Element,\n event: MouseEvent | TouchEvent,\n anchor?: TooltipAnchor\n ) => void\n hideTooltip: () => void\n}\n\nconst defaultActions: TooltipActionsContextData = {\n showTooltipAt: () => {},\n showTooltipFromEvent: () => {},\n hideTooltip: () => {},\n}\n\nexport const TooltipActionsContext = createContext<TooltipActionsContextData>(defaultActions)\n\nexport interface TooltipStateContextDataVisible {\n isVisible: true\n position: [number, number]\n content: JSX.Element\n anchor: TooltipAnchor\n}\n\nexport interface TooltipStateContextDataHidden {\n isVisible: false\n position: [null, null]\n content: null\n anchor: null\n}\n\nexport type TooltipStateContextData = TooltipStateContextDataVisible | TooltipStateContextDataHidden\n\nexport const hiddenTooltipState: TooltipStateContextDataHidden = {\n isVisible: false,\n position: [null, null],\n content: null,\n anchor: null,\n}\n\nexport const TooltipStateContext = createContext<TooltipStateContextData>(hiddenTooltipState)\n","import {\n useState,\n useContext,\n useCallback,\n MutableRefObject,\n MouseEvent,\n TouchEvent,\n useMemo,\n} from 'react'\nimport {\n TooltipActionsContext,\n TooltipActionsContextData,\n TooltipStateContext,\n TooltipStateContextData,\n hiddenTooltipState,\n} from './context'\nimport { TooltipAnchor } from './types'\n\nexport const useTooltipHandlers = (container: MutableRefObject<HTMLDivElement>) => {\n const [state, setState] = useState<TooltipStateContextData>(hiddenTooltipState)\n\n const showTooltipAt: TooltipActionsContextData['showTooltipAt'] = useCallback(\n (content: JSX.Element, [x, y]: [number, number], anchor: TooltipAnchor = 'top') => {\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [setState]\n )\n\n const showTooltipFromEvent: TooltipActionsContextData['showTooltipFromEvent'] = useCallback(\n (content: JSX.Element, event: MouseEvent | TouchEvent, anchor: TooltipAnchor = 'top') => {\n const bounds = container.current.getBoundingClientRect()\n const offsetWidth = container.current.offsetWidth\n // In a normal situation mouse enter / mouse leave events\n // capture the position ok. But when the chart is inside a scaled\n // element with a CSS transform like: `transform: scale(2);`\n // tooltip are not positioned ok.\n // Comparing original width `offsetWidth` agains scaled\n // width give us the scaling factor to calculate\n // ok mouse position\n const scaling = offsetWidth === bounds.width ? 1 : offsetWidth / bounds.width\n const { clientX, clientY } = 'touches' in event ? event.touches[0] : event\n const x = (clientX - bounds.left) * scaling\n const y = (clientY - bounds.top) * scaling\n\n if (anchor === 'left' || anchor === 'right') {\n if (x < bounds.width / 2) anchor = 'right'\n else anchor = 'left'\n }\n\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [container, setState]\n )\n\n const hideTooltip = useCallback(() => {\n setState(hiddenTooltipState)\n }, [setState])\n\n const actions: TooltipActionsContextData = useMemo(() => {\n return {\n showTooltipAt,\n showTooltipFromEvent,\n hideTooltip,\n }\n }, [showTooltipAt, showTooltipFromEvent, hideTooltip])\n\n return {\n actions,\n state,\n }\n}\n\nexport const useTooltip = () => {\n const context = useContext(TooltipActionsContext)\n if (context === undefined) {\n throw new Error('useTooltip must be used within a TooltipProvider')\n }\n\n return context\n}\n\nexport const useTooltipState = () => {\n const context = useContext(TooltipStateContext)\n if (context === undefined) {\n throw new Error('useTooltipState must be used within a TooltipProvider')\n }\n\n return context\n}\n","import { useTooltipState } from './hooks'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TooltipStateContextData, TooltipStateContextDataVisible } from './context'\n\nexport const isVisibleTooltipState = (\n state: TooltipStateContextData\n): state is TooltipStateContextDataVisible => state.isVisible\n\nexport const Tooltip = () => {\n const state = useTooltipState()\n\n if (!isVisibleTooltipState(state)) {\n return null\n }\n\n return (\n <TooltipWrapper position={state.position} anchor={state.anchor}>\n {state.content}\n </TooltipWrapper>\n )\n}\n","import { PropsWithChildren, MutableRefObject } from 'react'\nimport { TooltipActionsContext, TooltipStateContext } from './context'\nimport { useTooltipHandlers } from './hooks'\n\ninterface TooltipProviderProps {\n container: MutableRefObject<HTMLDivElement>\n}\n\nexport const TooltipProvider = ({\n container,\n children,\n}: PropsWithChildren<TooltipProviderProps>) => {\n const { actions, state } = useTooltipHandlers(container)\n\n return (\n <TooltipActionsContext.Provider value={actions}>\n <TooltipStateContext.Provider value={state}>{children}</TooltipStateContext.Provider>\n </TooltipActionsContext.Provider>\n )\n}\n"],"names":["tooltipStyle","pointerEvents","position","zIndex","top","left","translate","x","y","TooltipWrapper","memo","_ref","_animatedProps$transf","anchor","children","theme","useTheme","_useMotionConfig","useMotionConfig","animate","springConfig","config","_useMeasure","useMeasure","measureRef","bounds","previousPosition","useRef","to","undefined","immediate","hasDimension","width","height","Math","round","transform","current","animatedProps","useSpring","style","_extends","tooltip","wrapper","opacity","_jsx","animated","div","ref","displayName","Chip","_ref$size","size","color","_ref$style","display","background","BasicTooltip","content","id","_value","value","format","_ref$enableChip","enableChip","renderContent","formatValue","useValueFormatter","_jsxs","basic","chip","container","tableStyle","borderCollapse","TableTooltip","title","_ref$rows","rows","length","table","map","row","i","column","j","tableCell","CrosshairLine","x0","x1","y0","y1","useMemo","crosshair","line","x2","y2","fill","Crosshair","xLine","yLine","type","_Fragment","TooltipActionsContext","createContext","showTooltipAt","showTooltipFromEvent","hideTooltip","hiddenTooltipState","isVisible","TooltipStateContext","useTooltipHandlers","_useState","useState","state","setState","useCallback","event","getBoundingClientRect","offsetWidth","scaling","_ref2","touches","clientX","clientY","actions","useTooltip","context","useContext","Error","useTooltipState","isVisibleTooltipState","Tooltip","TooltipProvider","_useTooltipHandlers","Provider"],"mappings":"8iBAUA,IAEMA,EAAuC,CACzCC,cAAe,OACfC,SAAU,WACVC,OAAQ,GACRC,IAAK,EACLC,KAAM,GAGJC,EAAY,SAACC,EAAWC,GAAS,MAAkBD,aAAAA,SAAQC,EAAC,KAAA,EAOrDC,EAAiBC,GAC1B,SAAAC,GAAoC,IAAAC,EAAjCV,EAAQS,EAART,SAAUW,EAAMF,EAANE,OAAQC,EAAQH,EAARG,SACXC,EAAQC,IACdC,EAA0CC,IAAlCC,EAAOF,EAAPE,QAAiBC,EAAYH,EAApBI,OACjBC,EAA6BC,IAAtBC,EAAUF,EAAA,GAAEG,EAAMH,EAAA,GACnBI,EAAmBC,GAAiC,GAEtDC,OAAKC,EACLC,GAAY,EACVC,EAAeN,EAAOO,MAAQ,GAAKP,EAAOQ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,OAAAA,EACA6C,QAAAA,GAER,GACA,CAACa,EAAW2C,IAGVR,EAAcS,GAAY,WAC5BD,EAASP,EACb,GAAG,CAACO,IAUJ,MAAO,CACHU,QATuCjC,GAAQ,WAC/C,MAAO,CACHa,cAAAA,EACAC,qBAAAA,EACAC,YAAAA,EAEP,GAAE,CAACF,EAAeC,EAAsBC,IAIrCO,MAAAA,EAER,EAEaY,EAAa,WACtB,IAAMC,EAAUC,EAAWzB,GAC3B,QAAgBzE,IAAZiG,EACA,MAAM,IAAIE,MAAM,oDAGpB,OAAOF,CACX,EAEaG,EAAkB,WAC3B,IAAMH,EAAUC,EAAWlB,GAC3B,QAAgBhF,IAAZiG,EACA,MAAM,IAAIE,MAAM,yDAGpB,OAAOF,CACX,EC9FaI,EAAwB,SACjCjB,GAA8B,OACYA,EAAML,SAAS,EAEhDuB,EAAU,WACnB,IAAMlB,EAAQgB,IAEd,OAAKC,EAAsBjB,GAKvBpE,EAACpC,EAAc,CAACP,SAAU+G,EAAM/G,SAAUW,OAAQoG,EAAMpG,OAAOC,SAC1DmG,EAAMvD,UALJ,IAQf,ECZa0E,EAAkB,SAAHzH,GAGmB,IAF3C4D,EAAS5D,EAAT4D,UACAzD,EAAQH,EAARG,SAEAuH,EAA2BvB,EAAmBvC,GAAtCqD,EAAOS,EAAPT,QAASX,EAAKoB,EAALpB,MAEjB,OACIpE,EAACyD,EAAsBgC,SAAQ,CAACzE,MAAO+D,EAAQ9G,SAC3C+B,EAACgE,EAAoByB,SAAQ,CAACzE,MAAOoD,EAAMnG,SAAEA,KAGzD"}
{"version":3,"file":"nivo-tooltip.mjs","sources":["../src/TooltipWrapper.tsx","../src/Chip.tsx","../src/BasicTooltip.tsx","../src/TableTooltip.tsx","../src/CrosshairLine.tsx","../src/Crosshair.tsx","../src/context.ts","../src/hooks.ts","../src/Tooltip.tsx","../src/TooltipProvider.tsx"],"sourcesContent":["import { memo, useRef, PropsWithChildren, CSSProperties } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport {\n useMotionConfig,\n // @ts-ignore\n useMeasure,\n} from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\nimport { TooltipStateContextDataVisible } from './context'\n\nconst TOOLTIP_OFFSET = 14\n\nconst tooltipStyle: Partial<CSSProperties> = {\n pointerEvents: 'none',\n position: 'absolute',\n zIndex: 10,\n top: 0,\n left: 0,\n}\n\nconst translate = (x: number, y: number) => `translate(${x}px, ${y}px)`\n\ninterface TooltipWrapperProps {\n position: TooltipStateContextDataVisible['position']\n anchor: TooltipStateContextDataVisible['anchor']\n}\n\nexport const TooltipWrapper = memo<PropsWithChildren<TooltipWrapperProps>>(\n ({ position, anchor, children }) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const [measureRef, bounds] = useMeasure()\n const previousPosition = useRef<[number, number] | false>(false)\n\n let to = undefined\n let immediate = false\n const hasDimension = bounds.width > 0 && bounds.height > 0\n\n let x = Math.round(position[0])\n let y = Math.round(position[1])\n\n if (hasDimension) {\n if (anchor === 'top') {\n x -= bounds.width / 2\n y -= bounds.height + TOOLTIP_OFFSET\n } else if (anchor === 'right') {\n x += TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'bottom') {\n x -= bounds.width / 2\n y += TOOLTIP_OFFSET\n } else if (anchor === 'left') {\n x -= bounds.width + TOOLTIP_OFFSET\n y -= bounds.height / 2\n } else if (anchor === 'center') {\n x -= bounds.width / 2\n y -= bounds.height / 2\n }\n\n to = {\n transform: translate(x, y),\n }\n\n if (!previousPosition.current) {\n immediate = true\n }\n\n previousPosition.current = [x, y]\n }\n\n const animatedProps = useSpring<{\n transform: string\n }>({\n to,\n config: springConfig,\n immediate: !animate || immediate,\n })\n\n const { basic, chip, container, table, tableCell, tableCellValue, ...defaultStyle } =\n theme.tooltip\n\n const style = {\n ...tooltipStyle,\n ...defaultStyle,\n transform: animatedProps.transform ?? translate(x, y),\n opacity: animatedProps.transform ? 1 : 0,\n }\n\n return (\n <animated.div ref={measureRef} style={style}>\n {children}\n </animated.div>\n )\n }\n)\n\nTooltipWrapper.displayName = 'TooltipWrapper'\n","import { CSSProperties, memo } from 'react'\n\ninterface ChipProps {\n size?: number\n color: string\n style?: CSSProperties\n}\n\nexport const Chip = memo<ChipProps>(({ size = 12, color, style = {} }) => (\n <span style={{ display: 'block', width: size, height: size, background: color, ...style }} />\n))\n","import { memo, ReactNode } from 'react'\nimport { ValueFormat, useValueFormatter } from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\nimport { Chip } from './Chip'\n\nexport interface BasicTooltipProps {\n id: ReactNode\n value?: number | string | Date\n format?: ValueFormat<number | string | Date>\n color?: string\n enableChip?: boolean\n /**\n * @deprecated This should be replaced by custom tooltip components.\n */\n renderContent?: () => JSX.Element\n}\n\nexport const BasicTooltip = memo<BasicTooltipProps>(\n ({ id, value: _value, format, enableChip = false, color, renderContent }) => {\n const theme = useTheme()\n const formatValue = useValueFormatter<number | string | Date>(format)\n\n let content: JSX.Element\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n let value = _value\n if (formatValue !== undefined && value !== undefined) {\n value = formatValue(value)\n }\n content = (\n <div style={theme.tooltip.basic}>\n {enableChip && <Chip color={color!} style={theme.tooltip.chip} />}\n {value !== undefined ? (\n <span>\n {id}: <strong>{`${value}`}</strong>\n </span>\n ) : (\n id\n )}\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n }\n)\n","import { CSSProperties, memo, ReactNode } from 'react'\nimport { useTheme } from '@nivo/theming'\n\nconst tableStyle = {\n width: '100%',\n borderCollapse: 'collapse' as CSSProperties['borderCollapse'],\n}\n\ninterface TableTooltipProps {\n title?: ReactNode\n renderContent?: () => JSX.Element\n rows?: ReactNode[][]\n}\n\nexport const TableTooltip = memo(({ title, rows = [], renderContent }: TableTooltipProps) => {\n const theme = useTheme()\n\n if (!rows.length) return null\n\n let content\n if (typeof renderContent === 'function') {\n content = renderContent()\n } else {\n content = (\n <div>\n {title && title}\n <table style={{ ...tableStyle, ...theme.tooltip.table }}>\n <tbody>\n {rows.map((row, i) => (\n <tr key={i}>\n {row.map((column, j) => (\n <td key={j} style={theme.tooltip.tableCell}>\n {column}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n }\n\n return <div style={theme.tooltip.container}>{content}</div>\n})\n\nTableTooltip.displayName = 'TableTooltip'\n","import { CSSProperties, memo, useMemo } from 'react'\nimport { useSpring, animated } from '@react-spring/web'\nimport { useMotionConfig } from '@nivo/core'\nimport { useTheme } from '@nivo/theming'\n\ninterface CrosshairLineProps {\n x0: number\n x1: number\n y0: number\n y1: number\n}\n\nexport const CrosshairLine = memo(({ x0, x1, y0, y1 }: CrosshairLineProps) => {\n const theme = useTheme()\n const { animate, config: springConfig } = useMotionConfig()\n const style = useMemo(\n () => ({\n ...theme.crosshair.line,\n pointerEvents: 'none' as CSSProperties['pointerEvents'],\n }),\n [theme.crosshair.line]\n )\n\n const animatedProps = useSpring({\n x1: x0,\n x2: x1,\n y1: y0,\n y2: y1,\n config: springConfig,\n immediate: !animate,\n })\n\n return <animated.line {...animatedProps} fill=\"none\" style={style} />\n})\n\nCrosshairLine.displayName = 'CrosshairLine'\n","import { memo } from 'react'\nimport { CrosshairLine } from './CrosshairLine'\nimport { CrosshairType } from './types'\n\ninterface CrosshairProps {\n width: number\n height: number\n type: CrosshairType\n x: number\n y: number\n}\n\nexport const Crosshair = memo(({ width, height, type, x, y }: CrosshairProps) => {\n let xLine\n let yLine\n if (type === 'cross') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n } else if (type === 'top-left') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'top') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n } else if (type === 'top-right') {\n xLine = { x0: x, x1: x, y0: 0, y1: y }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'right') {\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom-right') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: x, x1: width, y0: y, y1: y }\n } else if (type === 'bottom') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n } else if (type === 'bottom-left') {\n xLine = { x0: x, x1: x, y0: y, y1: height }\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'left') {\n yLine = { x0: 0, x1: x, y0: y, y1: y }\n } else if (type === 'x') {\n xLine = { x0: x, x1: x, y0: 0, y1: height }\n } else if (type === 'y') {\n yLine = { x0: 0, x1: width, y0: y, y1: y }\n }\n\n return (\n <>\n {xLine && <CrosshairLine x0={xLine.x0} x1={xLine.x1} y0={xLine.y0} y1={xLine.y1} />}\n {yLine && <CrosshairLine x0={yLine.x0} x1={yLine.x1} y0={yLine.y0} y1={yLine.y1} />}\n </>\n )\n})\n\nCrosshair.displayName = 'Crosshair'\n","import { createContext, MouseEvent, TouchEvent } from 'react'\nimport { TooltipAnchor } from './types'\n\nexport interface TooltipActionsContextData {\n showTooltipAt: (\n content: JSX.Element,\n position: [number, number],\n anchor?: TooltipAnchor\n ) => void\n showTooltipFromEvent: (\n content: JSX.Element,\n event: MouseEvent | TouchEvent,\n anchor?: TooltipAnchor\n ) => void\n hideTooltip: () => void\n}\n\nconst defaultActions: TooltipActionsContextData = {\n showTooltipAt: () => {},\n showTooltipFromEvent: () => {},\n hideTooltip: () => {},\n}\n\nexport const TooltipActionsContext = createContext<TooltipActionsContextData>(defaultActions)\n\nexport interface TooltipStateContextDataVisible {\n isVisible: true\n position: [number, number]\n content: JSX.Element\n anchor: TooltipAnchor\n}\n\nexport interface TooltipStateContextDataHidden {\n isVisible: false\n position: [null, null]\n content: null\n anchor: null\n}\n\nexport type TooltipStateContextData = TooltipStateContextDataVisible | TooltipStateContextDataHidden\n\nexport const hiddenTooltipState: TooltipStateContextDataHidden = {\n isVisible: false,\n position: [null, null],\n content: null,\n anchor: null,\n}\n\nexport const TooltipStateContext = createContext<TooltipStateContextData>(hiddenTooltipState)\n","import {\n useState,\n useContext,\n useCallback,\n MutableRefObject,\n MouseEvent,\n TouchEvent,\n useMemo,\n} from 'react'\nimport {\n TooltipActionsContext,\n TooltipActionsContextData,\n TooltipStateContext,\n TooltipStateContextData,\n hiddenTooltipState,\n} from './context'\nimport { TooltipAnchor } from './types'\n\nexport const useTooltipHandlers = (container: MutableRefObject<HTMLDivElement>) => {\n const [state, setState] = useState<TooltipStateContextData>(hiddenTooltipState)\n\n const showTooltipAt: TooltipActionsContextData['showTooltipAt'] = useCallback(\n (content: JSX.Element, [x, y]: [number, number], anchor: TooltipAnchor = 'top') => {\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [setState]\n )\n\n const showTooltipFromEvent: TooltipActionsContextData['showTooltipFromEvent'] = useCallback(\n (content: JSX.Element, event: MouseEvent | TouchEvent, anchor: TooltipAnchor = 'top') => {\n const bounds = container.current.getBoundingClientRect()\n const offsetWidth = container.current.offsetWidth\n // In a normal situation mouse enter / mouse leave events\n // capture the position ok. But when the chart is inside a scaled\n // element with a CSS transform like: `transform: scale(2);`\n // tooltip are not positioned ok.\n // Comparing original width `offsetWidth` agains scaled\n // width give us the scaling factor to calculate\n // ok mouse position\n const scaling = offsetWidth === bounds.width ? 1 : offsetWidth / bounds.width\n const { clientX, clientY } = 'touches' in event ? event.touches[0] : event\n const x = (clientX - bounds.left) * scaling\n const y = (clientY - bounds.top) * scaling\n\n if (anchor === 'left' || anchor === 'right') {\n if (x < bounds.width / 2) anchor = 'right'\n else anchor = 'left'\n }\n\n setState({\n isVisible: true,\n position: [x, y],\n anchor,\n content,\n })\n },\n [container, setState]\n )\n\n const hideTooltip = useCallback(() => {\n setState(hiddenTooltipState)\n }, [setState])\n\n const actions: TooltipActionsContextData = useMemo(() => {\n return {\n showTooltipAt,\n showTooltipFromEvent,\n hideTooltip,\n }\n }, [showTooltipAt, showTooltipFromEvent, hideTooltip])\n\n return {\n actions,\n state,\n }\n}\n\nexport const useTooltip = () => {\n const context = useContext(TooltipActionsContext)\n if (context === undefined) {\n throw new Error('useTooltip must be used within a TooltipProvider')\n }\n\n return context\n}\n\nexport const useTooltipState = () => {\n const context = useContext(TooltipStateContext)\n if (context === undefined) {\n throw new Error('useTooltipState must be used within a TooltipProvider')\n }\n\n return context\n}\n","import { useTooltipState } from './hooks'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TooltipStateContextData, TooltipStateContextDataVisible } from './context'\n\nexport const isVisibleTooltipState = (\n state: TooltipStateContextData\n): state is TooltipStateContextDataVisible => state.isVisible\n\nexport const Tooltip = () => {\n const state = useTooltipState()\n\n if (!isVisibleTooltipState(state)) {\n return null\n }\n\n return (\n <TooltipWrapper position={state.position} anchor={state.anchor}>\n {state.content}\n </TooltipWrapper>\n )\n}\n","import { PropsWithChildren, MutableRefObject } from 'react'\nimport { TooltipActionsContext, TooltipStateContext } from './context'\nimport { useTooltipHandlers } from './hooks'\n\ninterface TooltipProviderProps {\n container: MutableRefObject<HTMLDivElement>\n}\n\nexport const TooltipProvider = ({\n container,\n children,\n}: PropsWithChildren<TooltipProviderProps>) => {\n const { actions, state } = useTooltipHandlers(container)\n\n return (\n <TooltipActionsContext.Provider value={actions}>\n <TooltipStateContext.Provider value={state}>{children}</TooltipStateContext.Provider>\n </TooltipActionsContext.Provider>\n )\n}\n"],"names":["tooltipStyle","pointerEvents","position","zIndex","top","left","translate","x","y","TooltipWrapper","memo","_ref","_animatedProps$transf","anchor","children","theme","useTheme","_useMotionConfig","useMotionConfig","animate","springConfig","config","_useMeasure","useMeasure","measureRef","bounds","previousPosition","useRef","to","undefined","immediate","hasDimension","width","height","Math","round","transform","current","animatedProps","useSpring","_theme$tooltip","tooltip","basic","chip","container","table","tableCell","tableCellValue","defaultStyle","_objectWithoutPropertiesLoose","_excluded","style","_extends","opacity","_jsx","animated","div","ref","displayName","Chip","_ref$size","size","color","_ref$style","display","background","BasicTooltip","content","id","_value","value","format","_ref$enableChip","enableChip","renderContent","formatValue","useValueFormatter","_jsxs","tableStyle","borderCollapse","TableTooltip","title","_ref$rows","rows","length","map","row","i","column","j","CrosshairLine","x0","x1","y0","y1","useMemo","crosshair","line","x2","y2","fill","Crosshair","xLine","yLine","type","_Fragment","TooltipActionsContext","createContext","showTooltipAt","showTooltipFromEvent","hideTooltip","hiddenTooltipState","isVisible","TooltipStateContext","useTooltipHandlers","_useState","useState","state","setState","useCallback","event","getBoundingClientRect","offsetWidth","scaling","_ref2","touches","clientX","clientY","actions","useTooltip","context","useContext","Error","useTooltipState","isVisibleTooltipState","Tooltip","TooltipProvider","_useTooltipHandlers","Provider"],"mappings":"ipBAYMA,EAAuC,CACzCC,cAAe,OACfC,SAAU,WACVC,OAAQ,GACRC,IAAK,EACLC,KAAM,GAGJC,EAAY,SAACC,EAAWC,GAAS,MAAkBD,aAAAA,SAAQC,EAAC,KAAA,EAOrDC,EAAiBC,GAC1B,SAAAC,GAAoC,IAAAC,EAAjCV,EAAQS,EAART,SAAUW,EAAMF,EAANE,OAAQC,EAAQH,EAARG,SACXC,EAAQC,IACdC,EAA0CC,IAAlCC,EAAOF,EAAPE,QAAiBC,EAAYH,EAApBI,OACjBC,EAA6BC,IAAtBC,EAAUF,EAAA,GAAEG,EAAMH,EAAA,GACnBI,EAAmBC,GAAiC,GAEtDC,OAAKC,EACLC,GAAY,EACVC,EAAeN,EAAOO,MAAQ,GAAKP,EAAOQ,OAAS,EAErD1B,EAAI2B,KAAKC,MAAMjC,EAAS,IACxBM,EAAI0B,KAAKC,MAAMjC,EAAS,IAExB6B,IACe,QAAXlB,GACAN,GAAKkB,EAAOO,MAAQ,EACpBxB,GAAKiB,EAAOQ,OAlCL,IAmCW,UAAXpB,GACPN,GApCO,GAqCPC,GAAKiB,EAAOQ,OAAS,GACH,WAAXpB,GACPN,GAAKkB,EAAOO,MAAQ,EACpBxB,GAxCO,IAyCW,SAAXK,GACPN,GAAKkB,EAA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,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAA;CACpC;AAED,eAAO,MAAM,YAAY,yDA6BxB,CAAA"}
{"version":3,"file":"BasicTooltip.d.ts","sourceRoot":"","sources":["../../src/BasicTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAA;AAI3D,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,SAAS,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAA;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAA;CACpC;AAED,eAAO,MAAM,YAAY,yDA6BxB,CAAA"}

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

{"version":3,"file":"CrosshairLine.d.ts","sourceRoot":"","sources":["../../src/CrosshairLine.tsx"],"names":[],"mappings":";AAIA,UAAU,kBAAkB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,aAAa,2DAA6B,kBAAkB,6CAqBvE,CAAA"}
{"version":3,"file":"CrosshairLine.d.ts","sourceRoot":"","sources":["../../src/CrosshairLine.tsx"],"names":[],"mappings":";AAKA,UAAU,kBAAkB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,aAAa,2DAA6B,kBAAkB,6CAqBvE,CAAA"}

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

{"version":3,"file":"TooltipWrapper.d.ts","sourceRoot":"","sources":["../../src/TooltipWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAiB,MAAM,OAAO,CAAA;AAQtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAA;AAc1D,UAAU,mBAAmB;IACzB,QAAQ,EAAE,8BAA8B,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,CAAA;CACnD;AAED,eAAO,MAAM,cAAc,8EAgE1B,CAAA"}
{"version":3,"file":"TooltipWrapper.d.ts","sourceRoot":"","sources":["../../src/TooltipWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAiB,MAAM,OAAO,CAAA;AAQtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAA;AAc1D,UAAU,mBAAmB;IACzB,QAAQ,EAAE,8BAA8B,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,EAAE,8BAA8B,CAAC,QAAQ,CAAC,CAAA;CACnD;AAED,eAAO,MAAM,cAAc,8EAmE1B,CAAA"}
{
"name": "@nivo/tooltip",
"version": "0.91.0",
"version": "0.92.0",
"license": "MIT",

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

"dependencies": {
"@nivo/core": "0.91.0",
"@nivo/core": "0.92.0",
"@nivo/theming": "0.92.0",
"@react-spring/web": "9.4.5 || ^9.7.2"

@@ -41,3 +42,3 @@ },

},
"gitHead": "86df5a86eff7da91a6c90e7fca8d2126196e5b44"
"gitHead": "21dcc7f512262e41fe1ea2ad920f03ed46c9a9b6"
}