@nivo/voronoi
Advanced tools
Comparing version 0.86.0 to 0.87.0
@@ -1,2 +0,2 @@ | ||
"use strict";var n=require("react"),e=require("@nivo/core"),o=require("d3-scale"),i=require("d3-delaunay"),r=require("react/jsx-runtime");function t(){return t=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])}return n},t.apply(this,arguments)}var l={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},u=function(n){return"function"==typeof n?n:function(e){return e[n]}},a=function(n){var e=n.points,o=n.x,i=void 0===o?"x":o,r=n.y,t=void 0===r?"y":r,l=u(i),a=u(t);return e.map((function(n){return[l(n),a(n)]}))},s=function(n){var e=n.points,o=n.width,r=n.height,t=n.debug,l=i.Delaunay.from(e),u=t?l.voronoi([0,0,o,r]):void 0;return{delaunay:l,voronoi:u}},d=function(e){var o=e.points,i=e.x,r=e.y,t=e.width,l=e.height,u=e.debug,d=n.useMemo((function(){return a({points:o,x:i,y:r})}),[o,i,r]);return n.useMemo((function(){return s({points:d,width:t,height:l,debug:u})}),[d,t,l,u])},c=function(e){var r=e.data,t=e.width,l=e.height,u=e.xDomain,a=e.yDomain,s=n.useMemo((function(){return o.scaleLinear().domain(u).range([0,t])}),[u,t]),d=n.useMemo((function(){return o.scaleLinear().domain(a).range([0,l])}),[a,l]),c=n.useMemo((function(){return r.map((function(n){return{x:s(n.x),y:d(n.y),data:n}}))}),[r,s,d]);return n.useMemo((function(){var n=i.Delaunay.from(c.map((function(n){return[n.x,n.y]}))),e=n.voronoi([0,0,t,l]);return{points:c,delaunay:n,voronoi:e}}),[c,t,l])},h=function(e){var o=e.points,i=e.delaunay,r=e.voronoi;return n.useMemo((function(){return{points:o,delaunay:i,voronoi:r}}),[o,i,r])},v=["theme"],f=function(o){var i=o.data,t=o.width,u=o.height,a=o.margin,s=o.layers,d=void 0===s?l.layers:s,v=o.xDomain,f=void 0===v?l.xDomain:v,p=o.yDomain,b=void 0===p?l.yDomain:p,x=o.enableLinks,m=void 0===x?l.enableLinks:x,y=o.linkLineWidth,g=void 0===y?l.linkLineWidth:y,k=o.linkLineColor,C=void 0===k?l.linkLineColor:k,M=o.enableCells,j=void 0===M?l.enableCells:M,L=o.cellLineWidth,W=void 0===L?l.cellLineWidth:L,w=o.cellLineColor,D=void 0===w?l.cellLineColor:w,S=o.enablePoints,T=void 0===S?l.enableCells:S,P=o.pointSize,V=void 0===P?l.pointSize:P,O=o.pointColor,q=void 0===O?l.pointColor:O,E=o.role,R=void 0===E?l.role:E,z=e.useDimensions(t,u,a),A=z.outerWidth,F=z.outerHeight,H=z.margin,B=z.innerWidth,I=z.innerHeight,G=c({data:i,width:B,height:I,xDomain:f,yDomain:b}),J=G.points,K=G.delaunay,N=G.voronoi,Q={links:null,cells:null,points:null,bounds:null};m&&d.includes("links")&&(Q.links=r.jsx("path",{stroke:C,strokeWidth:g,fill:"none",d:K.render()},"links")),j&&d.includes("cells")&&(Q.cells=r.jsx("path",{d:N.render(),fill:"none",stroke:D,strokeWidth:W},"cells")),T&&d.includes("points")&&(Q.points=r.jsx("path",{stroke:"none",fill:q,d:K.renderPoints(void 0,V/2)},"points")),d.includes("bounds")&&(Q.bounds=r.jsx("path",{fill:"none",stroke:D,strokeWidth:W,d:N.renderBounds()},"bounds"));var U=h({points:J,delaunay:K,voronoi:N});return r.jsx(e.SvgWrapper,{width:A,height:F,margin:H,role:R,children:d.map((function(e,o){return void 0!==Q[e]?Q[e]:"function"==typeof e?r.jsx(n.Fragment,{children:n.createElement(e,U)},o):null}))})},p=function(n){var o=n.theme,i=function(n,e){if(null==n)return{};var o,i,r={},t=Object.keys(n);for(i=0;i<t.length;i++)o=t[i],e.indexOf(o)>=0||(r[o]=n[o]);return r}(n,v);return r.jsx(e.Container,{isInteractive:!1,animate:!1,theme:o,children:r.jsx(f,t({},i))})};exports.Mesh=function(o){var i=o.nodes,t=o.width,l=o.height,u=o.x,a=o.y,s=o.onMouseEnter,c=o.onMouseMove,h=o.onMouseLeave,v=o.onClick,f=o.onTouchStart,p=o.onTouchMove,b=o.onTouchEnd,x=o.enableTouchCrosshair,m=void 0!==x&&x,y=o.debug,g=n.useRef(null),k=n.useState(null),C=k[0],M=k[1],j=d({points:i,x:u,y:a,width:t,height:l,debug:y}),L=j.delaunay,W=j.voronoi,w=n.useMemo((function(){if(y&&W)return W.render()}),[y,W]),D=n.useCallback((function(n){if(!g.current)return[null,null];var o=e.getRelativeCursor(g.current,n),r=o[0],t=o[1],l=L.find(r,t);return[l,void 0!==l?i[l]:null]}),[L,i]),S=n.useCallback((function(n){if(!g.current)return[null,null];var o=e.getRelativeCursor(g.current,n),r=o[0],t=o[1],l=L.find(r,t);return[l,void 0!==l?i[l]:null]}),[L,i]),T=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==s||s(i,n))}),[D,M,s]),P=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==c||c(i,n))}),[D,M,c]),V=n.useCallback((function(n){if(M(null),h){var e=void 0;null!==C&&(e=i[C]),e&&h(e,n)}}),[M,C,h,i]),O=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==v||v(i,n))}),[D,M,v]),q=n.useCallback((function(n){var e=S(n),o=e[0],i=e[1];m&&M(o),i&&(null==f||f(i,n))}),[S,m,f]),E=n.useCallback((function(n){var e=S(n),o=e[0],i=e[1];m&&M(o),i&&(null==p||p(i,n))}),[S,m,p]),R=n.useCallback((function(n){if(m&&M(null),b){var e=void 0;null!==C&&(e=i[C]),e&&b(e,n)}}),[m,b,C,i]);return r.jsxs("g",{ref:g,children:[y&&W&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:w,stroke:"red",strokeWidth:1,opacity:.75}),null!==C&&r.jsx("path",{fill:"pink",opacity:.35,d:W.renderCell(C)})]}),r.jsx("rect",{"data-ref":"mesh-interceptor",width:t,height:l,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:T,onMouseMove:P,onMouseLeave:V,onTouchStart:q,onTouchMove:E,onTouchEnd:R,onClick:O})]})},exports.ResponsiveVoronoi=function(n){return r.jsx(e.ResponsiveWrapper,{children:function(e){var o=e.width,i=e.height;return r.jsx(p,t({width:o,height:i},n))}})},exports.Voronoi=p,exports.computeMesh=s,exports.computeMeshPoints=a,exports.defaultVoronoiProps=l,exports.renderVoronoiCellToCanvas=function(n,e,o){n.save(),n.globalAlpha=.35,n.beginPath(),e.renderCell(o,n),n.fillStyle="red",n.fill(),n.restore()},exports.renderVoronoiToCanvas=function(n,e){n.save(),n.globalAlpha=.75,n.beginPath(),e.render(n),n.strokeStyle="red",n.lineWidth=1,n.stroke(),n.restore()},exports.useVoronoi=c,exports.useVoronoiLayerContext=h,exports.useVoronoiMesh=d; | ||
"use strict";var e=require("react"),o=require("@nivo/core"),n=require("d3-scale"),t=require("d3-delaunay"),i=require("@nivo/tooltip"),r=require("react/jsx-runtime");function l(){return l=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var n=arguments[o];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},l.apply(this,arguments)}var u={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},a=function(e){return[e.x,e.y]},s=o.defaultMargin,d="cursor",c="top",h=function(e){var o=e.points,n=e.getNodePosition,t=void 0===n?a:n,i=e.margin,r=void 0===i?s:i;return o.map((function(e){var o=t(e),n=o[0],i=o[1];return[n+r.left,i+r.top]}))},v=function(e){var o=e.points,n=e.width,i=e.height,r=e.margin,l=void 0===r?s:r,u=e.debug,a=t.Delaunay.from(o),d=u?a.voronoi([0,0,l.left+n+l.right,l.top+i+l.bottom]):void 0;return{points:o,delaunay:a,voronoi:d}},p=function(o){var n=o.points,t=o.getNodePosition,i=void 0===t?a:t,r=o.width,l=o.height,u=o.margin,d=void 0===u?s:u,c=o.debug;return e.useMemo((function(){return v({points:h({points:n,margin:d,getNodePosition:i}),width:r,height:l,margin:d,debug:c})}),[n,r,l,d,c])},f=function(o){var i=o.data,r=o.width,l=o.height,u=o.xDomain,a=o.yDomain,s=e.useMemo((function(){return n.scaleLinear().domain(u).range([0,r])}),[u,r]),d=e.useMemo((function(){return n.scaleLinear().domain(a).range([0,l])}),[a,l]),c=e.useMemo((function(){return i.map((function(e){return{x:s(e.x),y:d(e.y),data:e}}))}),[i,s,d]);return e.useMemo((function(){var e=t.Delaunay.from(c.map((function(e){return[e.x,e.y]}))),o=e.voronoi([0,0,r,l]);return{points:c,delaunay:e,voronoi:o}}),[c,r,l])},g=function(o){var n=o.points,t=o.delaunay,i=o.voronoi;return e.useMemo((function(){return{points:n,delaunay:t,voronoi:i}}),[n,t,i])},m=function(n){var t=n.elementRef,r=n.nodes,l=n.getNodePosition,u=void 0===l?a:l,h=n.delaunay,v=n.setCurrent,p=n.margin,f=void 0===p?s:p,g=n.detectionRadius,m=void 0===g?1/0:g,M=n.isInteractive,b=void 0===M||M,k=n.onMouseEnter,C=n.onMouseMove,x=n.onMouseLeave,y=n.onClick,T=n.onTouchStart,L=n.onTouchMove,P=n.onTouchEnd,j=n.enableTouchCrosshair,E=void 0!==j&&j,w=n.tooltip,W=n.tooltipPosition,D=void 0===W?d:W,R=n.tooltipAnchor,S=void 0===R?c:R,A=e.useState(null),N=A[0],V=A[1],q=e.useRef(null);e.useEffect((function(){q.current=N}),[q,N]);var O=e.useCallback((function(e){if(!t.current)return null;var n=o.getRelativeCursor(t.current,e),i=n[0],l=n[1],a=h.find(i,l),s=void 0!==a?r[a]:null;if(s&&m!==1/0){var d=u(s),c=d[0],v=d[1];o.getDistance(i,l,c+f.left,v+f.top)>m&&(a=null,s=null)}return null===a||null===s?null:[a,s]}),[t,h,r,u,f,m]),I=i.useTooltip(),z=I.showTooltipAt,F=I.showTooltipFromEvent,H=I.hideTooltip,B=e.useMemo((function(){if(w)return"cursor"===D?function(e,o){F(w(e),o,S)}:function(e){var o=u(e),n=o[0],t=o[1];z(w(e),[n+f.left,t+f.top],S)}}),[z,F,w,D,S,u,f]),G=e.useCallback((function(e){var o=O(e);if(V(o),null==v||v(o?o[1]:null),o){var n=o[1];null==B||B(n,e),null==k||k(o[1],e)}}),[O,V,v,B,k]),J=e.useCallback((function(e){var o=O(e);if(V(o),o){var n=o[0],t=o[1];if(null==v||v(t),null==B||B(t,e),q.current){var i=q.current,r=i[0],l=i[1];n!==r?null==x||x(l,e):null==C||C(t,e)}else null==k||k(t,e)}else null==v||v(null),null==H||H(),q.current&&(null==x||x(q.current[1],e))}),[O,V,q,k,C,x,B,H]),K=e.useCallback((function(e){V(null),null==v||v(null),H(),x&&q.current&&x(q.current[1],e)}),[V,v,q,H,x]),Q=e.useCallback((function(e){var o=O(e);V(o),o&&(null==y||y(o[1],e))}),[O,V,y]),U=e.useCallback((function(e){var o=O(e);E&&(V(o),null==v||v(o?o[1]:null)),o&&(null==T||T(o[1],e))}),[O,V,v,E,T]),X=e.useCallback((function(e){var o=O(e);E&&(V(o),null==v||v(o?o[1]:null)),o&&(null==L||L(o[1],e))}),[O,V,v,E,L]),Y=e.useCallback((function(e){E&&(V(null),null==v||v(null)),P&&q.current&&P(q.current[1],e)}),[E,V,v,P,q]);return{current:N,handleMouseEnter:b?G:void 0,handleMouseMove:b?J:void 0,handleMouseLeave:b?K:void 0,handleClick:b?Q:void 0,handleTouchStart:b?U:void 0,handleTouchMove:b?X:void 0,handleTouchEnd:b?Y:void 0}},M=["theme"],b=function(n){var t=n.data,i=n.width,l=n.height,a=n.margin,s=n.layers,d=void 0===s?u.layers:s,c=n.xDomain,h=void 0===c?u.xDomain:c,v=n.yDomain,p=void 0===v?u.yDomain:v,m=n.enableLinks,M=void 0===m?u.enableLinks:m,b=n.linkLineWidth,k=void 0===b?u.linkLineWidth:b,C=n.linkLineColor,x=void 0===C?u.linkLineColor:C,y=n.enableCells,T=void 0===y?u.enableCells:y,L=n.cellLineWidth,P=void 0===L?u.cellLineWidth:L,j=n.cellLineColor,E=void 0===j?u.cellLineColor:j,w=n.enablePoints,W=void 0===w?u.enableCells:w,D=n.pointSize,R=void 0===D?u.pointSize:D,S=n.pointColor,A=void 0===S?u.pointColor:S,N=n.role,V=void 0===N?u.role:N,q=o.useDimensions(i,l,a),O=q.outerWidth,I=q.outerHeight,z=q.margin,F=q.innerWidth,H=q.innerHeight,B=f({data:t,width:F,height:H,xDomain:h,yDomain:p}),G=B.points,J=B.delaunay,K=B.voronoi,Q={links:null,cells:null,points:null,bounds:null};M&&d.includes("links")&&(Q.links=r.jsx("path",{stroke:x,strokeWidth:k,fill:"none",d:J.render()},"links")),T&&d.includes("cells")&&(Q.cells=r.jsx("path",{d:K.render(),fill:"none",stroke:E,strokeWidth:P},"cells")),W&&d.includes("points")&&(Q.points=r.jsx("path",{stroke:"none",fill:A,d:J.renderPoints(void 0,R/2)},"points")),d.includes("bounds")&&(Q.bounds=r.jsx("path",{fill:"none",stroke:E,strokeWidth:P,d:K.renderBounds()},"bounds"));var U=g({points:G,delaunay:J,voronoi:K});return r.jsx(o.SvgWrapper,{width:O,height:I,margin:z,role:V,children:d.map((function(o,n){return void 0!==Q[o]?Q[o]:"function"==typeof o?r.jsx(e.Fragment,{children:e.createElement(o,U)},n):null}))})},k=function(e){var n=e.theme,t=function(e,o){if(null==e)return{};var n,t,i={},r=Object.keys(e);for(t=0;t<r.length;t++)n=r[t],o.indexOf(n)>=0||(i[n]=e[n]);return i}(e,M);return r.jsx(o.Container,{isInteractive:!1,animate:!1,theme:n,children:r.jsx(b,l({},t))})},C=function(e,o){e.save(),e.globalAlpha=.75,e.beginPath(),o.render(e),e.strokeStyle="red",e.lineWidth=1,e.stroke(),e.restore()},x=function(e,o,n){e.save(),e.globalAlpha=.15,e.beginPath(),o.renderPoints(e,n),e.strokeStyle="red",e.lineWidth=1,e.stroke(),e.restore()},y=function(e,o,n){e.save(),e.globalAlpha=.35,e.beginPath(),o.renderCell(n,e),e.fillStyle="pink",e.fill(),e.restore()};exports.Mesh=function(o){var n=o.nodes,t=o.width,i=o.height,l=o.margin,u=void 0===l?s:l,a=o.getNodePosition,h=o.setCurrent,v=o.onMouseEnter,f=o.onMouseMove,g=o.onMouseLeave,M=o.onClick,b=o.onTouchStart,k=o.onTouchMove,C=o.onTouchEnd,x=o.enableTouchCrosshair,y=void 0!==x&&x,T=o.detectionRadius,L=void 0===T?1/0:T,P=o.tooltip,j=o.tooltipPosition,E=void 0===j?d:j,w=o.tooltipAnchor,W=void 0===w?c:w,D=o.debug,R=e.useRef(null),S=p({points:n,getNodePosition:a,width:t,height:i,margin:u,debug:D}),A=S.delaunay,N=S.voronoi,V=m({elementRef:R,nodes:n,delaunay:A,margin:u,detectionRadius:L,setCurrent:h,onMouseEnter:v,onMouseMove:f,onMouseLeave:g,onClick:M,onTouchStart:b,onTouchMove:k,onTouchEnd:C,enableTouchCrosshair:y,tooltip:P,tooltipPosition:E,tooltipAnchor:W}),q=V.current,O=V.handleMouseEnter,I=V.handleMouseMove,z=V.handleMouseLeave,F=V.handleClick,H=V.handleTouchStart,B=V.handleTouchMove,G=V.handleTouchEnd,J=e.useMemo((function(){if(D&&N)return N.render()}),[D,N]);return r.jsxs("g",{ref:R,transform:"translate("+-u.left+","+-u.top+")",children:[D&&N&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:J,stroke:"red",strokeWidth:1,opacity:.75}),L<1/0&&r.jsx("path",{stroke:"red",strokeWidth:.35,fill:"none",d:A.renderPoints(void 0,L)}),q&&r.jsx("path",{fill:"pink",opacity:.35,d:N.renderCell(q[0])})]}),r.jsx("rect",{"data-ref":"mesh-interceptor",width:u.left+t+u.right,height:u.top+i+u.bottom,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:O,onMouseMove:I,onMouseLeave:z,onTouchStart:H,onTouchMove:B,onTouchEnd:G,onClick:F})]})},exports.ResponsiveVoronoi=function(e){return r.jsx(o.ResponsiveWrapper,{children:function(o){var n=o.width,t=o.height;return r.jsx(k,l({width:n,height:t},e))}})},exports.Voronoi=k,exports.computeMesh=v,exports.computeMeshPoints=h,exports.defaultVoronoiProps=u,exports.renderDebugToCanvas=function(e,o){var n=o.delaunay,t=o.voronoi,i=o.detectionRadius,r=o.index;C(e,t),i<1/0&&x(e,n,i),null!==r&&y(e,t,r)},exports.renderDelaunayPointsToCanvas=x,exports.renderVoronoiCellToCanvas=y,exports.renderVoronoiToCanvas=C,exports.useMesh=function(e){var o=e.elementRef,n=e.nodes,t=e.getNodePosition,i=e.width,r=e.height,l=e.margin,u=void 0===l?s:l,a=e.isInteractive,h=void 0===a||a,v=e.detectionRadius,f=void 0===v?1/0:v,g=e.setCurrent,M=e.onMouseEnter,b=e.onMouseMove,k=e.onMouseLeave,C=e.onClick,x=e.tooltip,y=e.tooltipPosition,T=void 0===y?d:y,L=e.tooltipAnchor,P=void 0===L?c:L,j=e.debug,E=p({points:n,getNodePosition:t,width:i,height:r,margin:u,debug:void 0!==j&&j}),w=E.delaunay,W=E.voronoi,D=m({elementRef:o,nodes:n,margin:u,setCurrent:g,delaunay:w,detectionRadius:f,isInteractive:h,onMouseEnter:M,onMouseMove:b,onMouseLeave:k,onClick:C,tooltip:x,tooltipPosition:T,tooltipAnchor:P}),R=D.handleMouseEnter,S=D.handleMouseMove,A=D.handleMouseLeave,N=D.handleClick;return{delaunay:w,voronoi:W,current:D.current,handleMouseEnter:R,handleMouseMove:S,handleMouseLeave:A,handleClick:N}},exports.useMeshEvents=m,exports.useVoronoi=f,exports.useVoronoiLayerContext=g,exports.useVoronoiMesh=p; | ||
//# sourceMappingURL=nivo-voronoi.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var n=require("react"),e=require("@nivo/core"),o=require("d3-scale"),i=require("d3-delaunay"),r=require("react/jsx-runtime");function t(){return t=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])}return n},t.apply(this,arguments)}var l={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},u=function(n){return"function"==typeof n?n:function(e){return e[n]}},a=function(n){var e=n.points,o=n.x,i=void 0===o?"x":o,r=n.y,t=void 0===r?"y":r,l=u(i),a=u(t);return e.map((function(n){return[l(n),a(n)]}))},s=function(n){var e=n.points,o=n.width,r=n.height,t=n.debug,l=i.Delaunay.from(e),u=t?l.voronoi([0,0,o,r]):void 0;return{delaunay:l,voronoi:u}},d=function(e){var o=e.points,i=e.x,r=e.y,t=e.width,l=e.height,u=e.debug,d=n.useMemo((function(){return a({points:o,x:i,y:r})}),[o,i,r]);return n.useMemo((function(){return s({points:d,width:t,height:l,debug:u})}),[d,t,l,u])},c=function(e){var r=e.data,t=e.width,l=e.height,u=e.xDomain,a=e.yDomain,s=n.useMemo((function(){return o.scaleLinear().domain(u).range([0,t])}),[u,t]),d=n.useMemo((function(){return o.scaleLinear().domain(a).range([0,l])}),[a,l]),c=n.useMemo((function(){return r.map((function(n){return{x:s(n.x),y:d(n.y),data:n}}))}),[r,s,d]);return n.useMemo((function(){var n=i.Delaunay.from(c.map((function(n){return[n.x,n.y]}))),e=n.voronoi([0,0,t,l]);return{points:c,delaunay:n,voronoi:e}}),[c,t,l])},h=function(e){var o=e.points,i=e.delaunay,r=e.voronoi;return n.useMemo((function(){return{points:o,delaunay:i,voronoi:r}}),[o,i,r])},v=["theme"],f=function(o){var i=o.data,t=o.width,u=o.height,a=o.margin,s=o.layers,d=void 0===s?l.layers:s,v=o.xDomain,f=void 0===v?l.xDomain:v,p=o.yDomain,b=void 0===p?l.yDomain:p,x=o.enableLinks,m=void 0===x?l.enableLinks:x,y=o.linkLineWidth,g=void 0===y?l.linkLineWidth:y,k=o.linkLineColor,C=void 0===k?l.linkLineColor:k,M=o.enableCells,j=void 0===M?l.enableCells:M,L=o.cellLineWidth,W=void 0===L?l.cellLineWidth:L,w=o.cellLineColor,D=void 0===w?l.cellLineColor:w,S=o.enablePoints,T=void 0===S?l.enableCells:S,P=o.pointSize,V=void 0===P?l.pointSize:P,O=o.pointColor,q=void 0===O?l.pointColor:O,E=o.role,R=void 0===E?l.role:E,z=e.useDimensions(t,u,a),A=z.outerWidth,F=z.outerHeight,H=z.margin,B=z.innerWidth,I=z.innerHeight,G=c({data:i,width:B,height:I,xDomain:f,yDomain:b}),J=G.points,K=G.delaunay,N=G.voronoi,Q={links:null,cells:null,points:null,bounds:null};m&&d.includes("links")&&(Q.links=r.jsx("path",{stroke:C,strokeWidth:g,fill:"none",d:K.render()},"links")),j&&d.includes("cells")&&(Q.cells=r.jsx("path",{d:N.render(),fill:"none",stroke:D,strokeWidth:W},"cells")),T&&d.includes("points")&&(Q.points=r.jsx("path",{stroke:"none",fill:q,d:K.renderPoints(void 0,V/2)},"points")),d.includes("bounds")&&(Q.bounds=r.jsx("path",{fill:"none",stroke:D,strokeWidth:W,d:N.renderBounds()},"bounds"));var U=h({points:J,delaunay:K,voronoi:N});return r.jsx(e.SvgWrapper,{width:A,height:F,margin:H,role:R,children:d.map((function(e,o){return void 0!==Q[e]?Q[e]:"function"==typeof e?r.jsx(n.Fragment,{children:n.createElement(e,U)},o):null}))})},p=function(n){var o=n.theme,i=function(n,e){if(null==n)return{};var o,i,r={},t=Object.keys(n);for(i=0;i<t.length;i++)o=t[i],e.indexOf(o)>=0||(r[o]=n[o]);return r}(n,v);return r.jsx(e.Container,{isInteractive:!1,animate:!1,theme:o,children:r.jsx(f,t({},i))})};exports.Mesh=function(o){var i=o.nodes,t=o.width,l=o.height,u=o.x,a=o.y,s=o.onMouseEnter,c=o.onMouseMove,h=o.onMouseLeave,v=o.onClick,f=o.onTouchStart,p=o.onTouchMove,b=o.onTouchEnd,x=o.enableTouchCrosshair,m=void 0!==x&&x,y=o.debug,g=n.useRef(null),k=n.useState(null),C=k[0],M=k[1],j=d({points:i,x:u,y:a,width:t,height:l,debug:y}),L=j.delaunay,W=j.voronoi,w=n.useMemo((function(){if(y&&W)return W.render()}),[y,W]),D=n.useCallback((function(n){if(!g.current)return[null,null];var o=e.getRelativeCursor(g.current,n),r=o[0],t=o[1],l=L.find(r,t);return[l,void 0!==l?i[l]:null]}),[L,i]),S=n.useCallback((function(n){if(!g.current)return[null,null];var o=e.getRelativeCursor(g.current,n),r=o[0],t=o[1],l=L.find(r,t);return[l,void 0!==l?i[l]:null]}),[L,i]),T=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==s||s(i,n))}),[D,M,s]),P=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==c||c(i,n))}),[D,M,c]),V=n.useCallback((function(n){if(M(null),h){var e=void 0;null!==C&&(e=i[C]),e&&h(e,n)}}),[M,C,h,i]),O=n.useCallback((function(n){var e=D(n),o=e[0],i=e[1];M(o),i&&(null==v||v(i,n))}),[D,M,v]),q=n.useCallback((function(n){var e=S(n),o=e[0],i=e[1];m&&M(o),i&&(null==f||f(i,n))}),[S,m,f]),E=n.useCallback((function(n){var e=S(n),o=e[0],i=e[1];m&&M(o),i&&(null==p||p(i,n))}),[S,m,p]),R=n.useCallback((function(n){if(m&&M(null),b){var e=void 0;null!==C&&(e=i[C]),e&&b(e,n)}}),[m,b,C,i]);return r.jsxs("g",{ref:g,children:[y&&W&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:w,stroke:"red",strokeWidth:1,opacity:.75}),null!==C&&r.jsx("path",{fill:"pink",opacity:.35,d:W.renderCell(C)})]}),r.jsx("rect",{"data-ref":"mesh-interceptor",width:t,height:l,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:T,onMouseMove:P,onMouseLeave:V,onTouchStart:q,onTouchMove:E,onTouchEnd:R,onClick:O})]})},exports.ResponsiveVoronoi=function(n){return r.jsx(e.ResponsiveWrapper,{children:function(e){var o=e.width,i=e.height;return r.jsx(p,t({width:o,height:i},n))}})},exports.Voronoi=p,exports.computeMesh=s,exports.computeMeshPoints=a,exports.defaultVoronoiProps=l,exports.renderVoronoiCellToCanvas=function(n,e,o){n.save(),n.globalAlpha=.35,n.beginPath(),e.renderCell(o,n),n.fillStyle="red",n.fill(),n.restore()},exports.renderVoronoiToCanvas=function(n,e){n.save(),n.globalAlpha=.75,n.beginPath(),e.render(n),n.strokeStyle="red",n.lineWidth=1,n.stroke(),n.restore()},exports.useVoronoi=c,exports.useVoronoiLayerContext=h,exports.useVoronoiMesh=d; | ||
"use strict";var e=require("react"),o=require("@nivo/core"),n=require("d3-scale"),t=require("d3-delaunay"),i=require("@nivo/tooltip"),r=require("react/jsx-runtime");function l(){return l=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var n=arguments[o];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},l.apply(this,arguments)}var u={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},a=function(e){return[e.x,e.y]},s=o.defaultMargin,d="cursor",c="top",h=function(e){var o=e.points,n=e.getNodePosition,t=void 0===n?a:n,i=e.margin,r=void 0===i?s:i;return o.map((function(e){var o=t(e),n=o[0],i=o[1];return[n+r.left,i+r.top]}))},v=function(e){var o=e.points,n=e.width,i=e.height,r=e.margin,l=void 0===r?s:r,u=e.debug,a=t.Delaunay.from(o),d=u?a.voronoi([0,0,l.left+n+l.right,l.top+i+l.bottom]):void 0;return{points:o,delaunay:a,voronoi:d}},p=function(o){var n=o.points,t=o.getNodePosition,i=void 0===t?a:t,r=o.width,l=o.height,u=o.margin,d=void 0===u?s:u,c=o.debug;return e.useMemo((function(){return v({points:h({points:n,margin:d,getNodePosition:i}),width:r,height:l,margin:d,debug:c})}),[n,r,l,d,c])},f=function(o){var i=o.data,r=o.width,l=o.height,u=o.xDomain,a=o.yDomain,s=e.useMemo((function(){return n.scaleLinear().domain(u).range([0,r])}),[u,r]),d=e.useMemo((function(){return n.scaleLinear().domain(a).range([0,l])}),[a,l]),c=e.useMemo((function(){return i.map((function(e){return{x:s(e.x),y:d(e.y),data:e}}))}),[i,s,d]);return e.useMemo((function(){var e=t.Delaunay.from(c.map((function(e){return[e.x,e.y]}))),o=e.voronoi([0,0,r,l]);return{points:c,delaunay:e,voronoi:o}}),[c,r,l])},g=function(o){var n=o.points,t=o.delaunay,i=o.voronoi;return e.useMemo((function(){return{points:n,delaunay:t,voronoi:i}}),[n,t,i])},m=function(n){var t=n.elementRef,r=n.nodes,l=n.getNodePosition,u=void 0===l?a:l,h=n.delaunay,v=n.setCurrent,p=n.margin,f=void 0===p?s:p,g=n.detectionRadius,m=void 0===g?1/0:g,M=n.isInteractive,b=void 0===M||M,k=n.onMouseEnter,C=n.onMouseMove,x=n.onMouseLeave,y=n.onClick,T=n.onTouchStart,L=n.onTouchMove,P=n.onTouchEnd,j=n.enableTouchCrosshair,E=void 0!==j&&j,w=n.tooltip,W=n.tooltipPosition,D=void 0===W?d:W,R=n.tooltipAnchor,S=void 0===R?c:R,A=e.useState(null),N=A[0],V=A[1],q=e.useRef(null);e.useEffect((function(){q.current=N}),[q,N]);var O=e.useCallback((function(e){if(!t.current)return null;var n=o.getRelativeCursor(t.current,e),i=n[0],l=n[1],a=h.find(i,l),s=void 0!==a?r[a]:null;if(s&&m!==1/0){var d=u(s),c=d[0],v=d[1];o.getDistance(i,l,c+f.left,v+f.top)>m&&(a=null,s=null)}return null===a||null===s?null:[a,s]}),[t,h,r,u,f,m]),I=i.useTooltip(),z=I.showTooltipAt,F=I.showTooltipFromEvent,H=I.hideTooltip,B=e.useMemo((function(){if(w)return"cursor"===D?function(e,o){F(w(e),o,S)}:function(e){var o=u(e),n=o[0],t=o[1];z(w(e),[n+f.left,t+f.top],S)}}),[z,F,w,D,S,u,f]),G=e.useCallback((function(e){var o=O(e);if(V(o),null==v||v(o?o[1]:null),o){var n=o[1];null==B||B(n,e),null==k||k(o[1],e)}}),[O,V,v,B,k]),J=e.useCallback((function(e){var o=O(e);if(V(o),o){var n=o[0],t=o[1];if(null==v||v(t),null==B||B(t,e),q.current){var i=q.current,r=i[0],l=i[1];n!==r?null==x||x(l,e):null==C||C(t,e)}else null==k||k(t,e)}else null==v||v(null),null==H||H(),q.current&&(null==x||x(q.current[1],e))}),[O,V,q,k,C,x,B,H]),K=e.useCallback((function(e){V(null),null==v||v(null),H(),x&&q.current&&x(q.current[1],e)}),[V,v,q,H,x]),Q=e.useCallback((function(e){var o=O(e);V(o),o&&(null==y||y(o[1],e))}),[O,V,y]),U=e.useCallback((function(e){var o=O(e);E&&(V(o),null==v||v(o?o[1]:null)),o&&(null==T||T(o[1],e))}),[O,V,v,E,T]),X=e.useCallback((function(e){var o=O(e);E&&(V(o),null==v||v(o?o[1]:null)),o&&(null==L||L(o[1],e))}),[O,V,v,E,L]),Y=e.useCallback((function(e){E&&(V(null),null==v||v(null)),P&&q.current&&P(q.current[1],e)}),[E,V,v,P,q]);return{current:N,handleMouseEnter:b?G:void 0,handleMouseMove:b?J:void 0,handleMouseLeave:b?K:void 0,handleClick:b?Q:void 0,handleTouchStart:b?U:void 0,handleTouchMove:b?X:void 0,handleTouchEnd:b?Y:void 0}},M=["theme"],b=function(n){var t=n.data,i=n.width,l=n.height,a=n.margin,s=n.layers,d=void 0===s?u.layers:s,c=n.xDomain,h=void 0===c?u.xDomain:c,v=n.yDomain,p=void 0===v?u.yDomain:v,m=n.enableLinks,M=void 0===m?u.enableLinks:m,b=n.linkLineWidth,k=void 0===b?u.linkLineWidth:b,C=n.linkLineColor,x=void 0===C?u.linkLineColor:C,y=n.enableCells,T=void 0===y?u.enableCells:y,L=n.cellLineWidth,P=void 0===L?u.cellLineWidth:L,j=n.cellLineColor,E=void 0===j?u.cellLineColor:j,w=n.enablePoints,W=void 0===w?u.enableCells:w,D=n.pointSize,R=void 0===D?u.pointSize:D,S=n.pointColor,A=void 0===S?u.pointColor:S,N=n.role,V=void 0===N?u.role:N,q=o.useDimensions(i,l,a),O=q.outerWidth,I=q.outerHeight,z=q.margin,F=q.innerWidth,H=q.innerHeight,B=f({data:t,width:F,height:H,xDomain:h,yDomain:p}),G=B.points,J=B.delaunay,K=B.voronoi,Q={links:null,cells:null,points:null,bounds:null};M&&d.includes("links")&&(Q.links=r.jsx("path",{stroke:x,strokeWidth:k,fill:"none",d:J.render()},"links")),T&&d.includes("cells")&&(Q.cells=r.jsx("path",{d:K.render(),fill:"none",stroke:E,strokeWidth:P},"cells")),W&&d.includes("points")&&(Q.points=r.jsx("path",{stroke:"none",fill:A,d:J.renderPoints(void 0,R/2)},"points")),d.includes("bounds")&&(Q.bounds=r.jsx("path",{fill:"none",stroke:E,strokeWidth:P,d:K.renderBounds()},"bounds"));var U=g({points:G,delaunay:J,voronoi:K});return r.jsx(o.SvgWrapper,{width:O,height:I,margin:z,role:V,children:d.map((function(o,n){return void 0!==Q[o]?Q[o]:"function"==typeof o?r.jsx(e.Fragment,{children:e.createElement(o,U)},n):null}))})},k=function(e){var n=e.theme,t=function(e,o){if(null==e)return{};var n,t,i={},r=Object.keys(e);for(t=0;t<r.length;t++)n=r[t],o.indexOf(n)>=0||(i[n]=e[n]);return i}(e,M);return r.jsx(o.Container,{isInteractive:!1,animate:!1,theme:n,children:r.jsx(b,l({},t))})},C=function(e,o){e.save(),e.globalAlpha=.75,e.beginPath(),o.render(e),e.strokeStyle="red",e.lineWidth=1,e.stroke(),e.restore()},x=function(e,o,n){e.save(),e.globalAlpha=.15,e.beginPath(),o.renderPoints(e,n),e.strokeStyle="red",e.lineWidth=1,e.stroke(),e.restore()},y=function(e,o,n){e.save(),e.globalAlpha=.35,e.beginPath(),o.renderCell(n,e),e.fillStyle="pink",e.fill(),e.restore()};exports.Mesh=function(o){var n=o.nodes,t=o.width,i=o.height,l=o.margin,u=void 0===l?s:l,a=o.getNodePosition,h=o.setCurrent,v=o.onMouseEnter,f=o.onMouseMove,g=o.onMouseLeave,M=o.onClick,b=o.onTouchStart,k=o.onTouchMove,C=o.onTouchEnd,x=o.enableTouchCrosshair,y=void 0!==x&&x,T=o.detectionRadius,L=void 0===T?1/0:T,P=o.tooltip,j=o.tooltipPosition,E=void 0===j?d:j,w=o.tooltipAnchor,W=void 0===w?c:w,D=o.debug,R=e.useRef(null),S=p({points:n,getNodePosition:a,width:t,height:i,margin:u,debug:D}),A=S.delaunay,N=S.voronoi,V=m({elementRef:R,nodes:n,delaunay:A,margin:u,detectionRadius:L,setCurrent:h,onMouseEnter:v,onMouseMove:f,onMouseLeave:g,onClick:M,onTouchStart:b,onTouchMove:k,onTouchEnd:C,enableTouchCrosshair:y,tooltip:P,tooltipPosition:E,tooltipAnchor:W}),q=V.current,O=V.handleMouseEnter,I=V.handleMouseMove,z=V.handleMouseLeave,F=V.handleClick,H=V.handleTouchStart,B=V.handleTouchMove,G=V.handleTouchEnd,J=e.useMemo((function(){if(D&&N)return N.render()}),[D,N]);return r.jsxs("g",{ref:R,transform:"translate("+-u.left+","+-u.top+")",children:[D&&N&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:J,stroke:"red",strokeWidth:1,opacity:.75}),L<1/0&&r.jsx("path",{stroke:"red",strokeWidth:.35,fill:"none",d:A.renderPoints(void 0,L)}),q&&r.jsx("path",{fill:"pink",opacity:.35,d:N.renderCell(q[0])})]}),r.jsx("rect",{"data-ref":"mesh-interceptor",width:u.left+t+u.right,height:u.top+i+u.bottom,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:O,onMouseMove:I,onMouseLeave:z,onTouchStart:H,onTouchMove:B,onTouchEnd:G,onClick:F})]})},exports.ResponsiveVoronoi=function(e){return r.jsx(o.ResponsiveWrapper,{children:function(o){var n=o.width,t=o.height;return r.jsx(k,l({width:n,height:t},e))}})},exports.Voronoi=k,exports.computeMesh=v,exports.computeMeshPoints=h,exports.defaultVoronoiProps=u,exports.renderDebugToCanvas=function(e,o){var n=o.delaunay,t=o.voronoi,i=o.detectionRadius,r=o.index;C(e,t),i<1/0&&x(e,n,i),null!==r&&y(e,t,r)},exports.renderDelaunayPointsToCanvas=x,exports.renderVoronoiCellToCanvas=y,exports.renderVoronoiToCanvas=C,exports.useMesh=function(e){var o=e.elementRef,n=e.nodes,t=e.getNodePosition,i=e.width,r=e.height,l=e.margin,u=void 0===l?s:l,a=e.isInteractive,h=void 0===a||a,v=e.detectionRadius,f=void 0===v?1/0:v,g=e.setCurrent,M=e.onMouseEnter,b=e.onMouseMove,k=e.onMouseLeave,C=e.onClick,x=e.tooltip,y=e.tooltipPosition,T=void 0===y?d:y,L=e.tooltipAnchor,P=void 0===L?c:L,j=e.debug,E=p({points:n,getNodePosition:t,width:i,height:r,margin:u,debug:void 0!==j&&j}),w=E.delaunay,W=E.voronoi,D=m({elementRef:o,nodes:n,margin:u,setCurrent:g,delaunay:w,detectionRadius:f,isInteractive:h,onMouseEnter:M,onMouseMove:b,onMouseLeave:k,onClick:C,tooltip:x,tooltipPosition:T,tooltipAnchor:P}),R=D.handleMouseEnter,S=D.handleMouseMove,A=D.handleMouseLeave,N=D.handleClick;return{delaunay:w,voronoi:W,current:D.current,handleMouseEnter:R,handleMouseMove:S,handleMouseLeave:A,handleClick:N}},exports.useMeshEvents=m,exports.useVoronoi=f,exports.useVoronoiLayerContext=g,exports.useVoronoiMesh=p; | ||
//# sourceMappingURL=nivo-voronoi.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
import{useMemo as n,Fragment as o,createElement as e,useRef as i,useState as t,useCallback as r}from"react";import{Container as l,useDimensions as u,SvgWrapper as a,ResponsiveWrapper as d,getRelativeCursor as c}from"@nivo/core";import{scaleLinear as s}from"d3-scale";import{Delaunay as h}from"d3-delaunay";import{jsx as f,jsxs as v,Fragment as p}from"react/jsx-runtime";function m(){return m=Object.assign?Object.assign.bind():function(n){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},m.apply(this,arguments)}var y={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},b=function(n){return"function"==typeof n?n:function(o){return o[n]}},g=function(n){var o=n.points,e=n.x,i=void 0===e?"x":e,t=n.y,r=void 0===t?"y":t,l=b(i),u=b(r);return o.map((function(n){return[l(n),u(n)]}))},k=function(n){var o=n.points,e=n.width,i=n.height,t=n.debug,r=h.from(o),l=t?r.voronoi([0,0,e,i]):void 0;return{delaunay:r,voronoi:l}},C=function(o){var e=o.points,i=o.x,t=o.y,r=o.width,l=o.height,u=o.debug,a=n((function(){return g({points:e,x:i,y:t})}),[e,i,t]);return n((function(){return k({points:a,width:r,height:l,debug:u})}),[a,r,l,u])},x=function(o){var e=o.data,i=o.width,t=o.height,r=o.xDomain,l=o.yDomain,u=n((function(){return s().domain(r).range([0,i])}),[r,i]),a=n((function(){return s().domain(l).range([0,t])}),[l,t]),d=n((function(){return e.map((function(n){return{x:u(n.x),y:a(n.y),data:n}}))}),[e,u,a]);return n((function(){var n=h.from(d.map((function(n){return[n.x,n.y]}))),o=n.voronoi([0,0,i,t]);return{points:d,delaunay:n,voronoi:o}}),[d,i,t])},L=function(o){var e=o.points,i=o.delaunay,t=o.voronoi;return n((function(){return{points:e,delaunay:i,voronoi:t}}),[e,i,t])},w=["theme"],W=function(n){var i=n.data,t=n.width,r=n.height,l=n.margin,d=n.layers,c=void 0===d?y.layers:d,s=n.xDomain,h=void 0===s?y.xDomain:s,v=n.yDomain,p=void 0===v?y.yDomain:v,m=n.enableLinks,b=void 0===m?y.enableLinks:m,g=n.linkLineWidth,k=void 0===g?y.linkLineWidth:g,C=n.linkLineColor,w=void 0===C?y.linkLineColor:C,W=n.enableCells,D=void 0===W?y.enableCells:W,M=n.cellLineWidth,S=void 0===M?y.cellLineWidth:M,T=n.cellLineColor,O=void 0===T?y.cellLineColor:T,P=n.enablePoints,j=void 0===P?y.enableCells:P,E=n.pointSize,z=void 0===E?y.pointSize:E,A=n.pointColor,H=void 0===A?y.pointColor:A,B=n.role,F=void 0===B?y.role:B,I=u(t,r,l),q=I.outerWidth,G=I.outerHeight,J=I.margin,K=I.innerWidth,N=I.innerHeight,Q=x({data:i,width:K,height:N,xDomain:h,yDomain:p}),R=Q.points,U=Q.delaunay,V=Q.voronoi,X={links:null,cells:null,points:null,bounds:null};b&&c.includes("links")&&(X.links=f("path",{stroke:w,strokeWidth:k,fill:"none",d:U.render()},"links")),D&&c.includes("cells")&&(X.cells=f("path",{d:V.render(),fill:"none",stroke:O,strokeWidth:S},"cells")),j&&c.includes("points")&&(X.points=f("path",{stroke:"none",fill:H,d:U.renderPoints(void 0,z/2)},"points")),c.includes("bounds")&&(X.bounds=f("path",{fill:"none",stroke:O,strokeWidth:S,d:V.renderBounds()},"bounds"));var Y=L({points:R,delaunay:U,voronoi:V});return f(a,{width:q,height:G,margin:J,role:F,children:c.map((function(n,i){return void 0!==X[n]?X[n]:"function"==typeof n?f(o,{children:e(n,Y)},i):null}))})},D=function(n){var o=n.theme,e=function(n,o){if(null==n)return{};var e,i,t={},r=Object.keys(n);for(i=0;i<r.length;i++)e=r[i],o.indexOf(e)>=0||(t[e]=n[e]);return t}(n,w);return f(l,{isInteractive:!1,animate:!1,theme:o,children:f(W,m({},e))})},M=function(n){return f(d,{children:function(o){var e=o.width,i=o.height;return f(D,m({width:e,height:i},n))}})},S=function(o){var e=o.nodes,l=o.width,u=o.height,a=o.x,d=o.y,s=o.onMouseEnter,h=o.onMouseMove,m=o.onMouseLeave,y=o.onClick,b=o.onTouchStart,g=o.onTouchMove,k=o.onTouchEnd,x=o.enableTouchCrosshair,L=void 0!==x&&x,w=o.debug,W=i(null),D=t(null),M=D[0],S=D[1],T=C({points:e,x:a,y:d,width:l,height:u,debug:w}),O=T.delaunay,P=T.voronoi,j=n((function(){if(w&&P)return P.render()}),[w,P]),E=r((function(n){if(!W.current)return[null,null];var o=c(W.current,n),i=o[0],t=o[1],r=O.find(i,t);return[r,void 0!==r?e[r]:null]}),[O,e]),z=r((function(n){if(!W.current)return[null,null];var o=c(W.current,n),i=o[0],t=o[1],r=O.find(i,t);return[r,void 0!==r?e[r]:null]}),[O,e]),A=r((function(n){var o=E(n),e=o[0],i=o[1];S(e),i&&(null==s||s(i,n))}),[E,S,s]),H=r((function(n){var o=E(n),e=o[0],i=o[1];S(e),i&&(null==h||h(i,n))}),[E,S,h]),B=r((function(n){if(S(null),m){var o=void 0;null!==M&&(o=e[M]),o&&m(o,n)}}),[S,M,m,e]),F=r((function(n){var o=E(n),e=o[0],i=o[1];S(e),i&&(null==y||y(i,n))}),[E,S,y]),I=r((function(n){var o=z(n),e=o[0],i=o[1];L&&S(e),i&&(null==b||b(i,n))}),[z,L,b]),q=r((function(n){var o=z(n),e=o[0],i=o[1];L&&S(e),i&&(null==g||g(i,n))}),[z,L,g]),G=r((function(n){if(L&&S(null),k){var o=void 0;null!==M&&(o=e[M]),o&&k(o,n)}}),[L,k,M,e]);return v("g",{ref:W,children:[w&&P&&v(p,{children:[f("path",{d:j,stroke:"red",strokeWidth:1,opacity:.75}),null!==M&&f("path",{fill:"pink",opacity:.35,d:P.renderCell(M)})]}),f("rect",{"data-ref":"mesh-interceptor",width:l,height:u,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:A,onMouseMove:H,onMouseLeave:B,onTouchStart:I,onTouchMove:q,onTouchEnd:G,onClick:F})]})},T=function(n,o){n.save(),n.globalAlpha=.75,n.beginPath(),o.render(n),n.strokeStyle="red",n.lineWidth=1,n.stroke(),n.restore()},O=function(n,o,e){n.save(),n.globalAlpha=.35,n.beginPath(),o.renderCell(e,n),n.fillStyle="red",n.fill(),n.restore()};export{S as Mesh,M as ResponsiveVoronoi,D as Voronoi,k as computeMesh,g as computeMeshPoints,y as defaultVoronoiProps,O as renderVoronoiCellToCanvas,T as renderVoronoiToCanvas,x as useVoronoi,L as useVoronoiLayerContext,C as useVoronoiMesh}; | ||
import{useMemo as n,useState as o,useRef as e,useEffect as i,useCallback as t,Fragment as r,createElement as l}from"react";import{defaultMargin as u,getRelativeCursor as a,getDistance as d,Container as s,useDimensions as c,SvgWrapper as h,ResponsiveWrapper as v}from"@nivo/core";import{scaleLinear as f}from"d3-scale";import{Delaunay as p}from"d3-delaunay";import{useTooltip as g}from"@nivo/tooltip";import{jsx as m,jsxs as M,Fragment as b}from"react/jsx-runtime";function k(){return k=Object.assign?Object.assign.bind():function(n){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},k.apply(this,arguments)}var y={xDomain:[0,1],yDomain:[0,1],layers:["links","cells","points","bounds"],enableLinks:!1,linkLineWidth:1,linkLineColor:"#bbbbbb",enableCells:!0,cellLineWidth:2,cellLineColor:"#000000",enablePoints:!0,pointSize:4,pointColor:"#666666",role:"img"},C=function(n){return[n.x,n.y]},L=u,T="cursor",P="top",w=function(n){var o=n.points,e=n.getNodePosition,i=void 0===e?C:e,t=n.margin,r=void 0===t?L:t;return o.map((function(n){var o=i(n),e=o[0],t=o[1];return[e+r.left,t+r.top]}))},E=function(n){var o=n.points,e=n.width,i=n.height,t=n.margin,r=void 0===t?L:t,l=n.debug,u=p.from(o),a=l?u.voronoi([0,0,r.left+e+r.right,r.top+i+r.bottom]):void 0;return{points:o,delaunay:u,voronoi:a}},W=function(o){var e=o.points,i=o.getNodePosition,t=void 0===i?C:i,r=o.width,l=o.height,u=o.margin,a=void 0===u?L:u,d=o.debug;return n((function(){return E({points:w({points:e,margin:a,getNodePosition:t}),width:r,height:l,margin:a,debug:d})}),[e,r,l,a,d])},x=function(o){var e=o.data,i=o.width,t=o.height,r=o.xDomain,l=o.yDomain,u=n((function(){return f().domain(r).range([0,i])}),[r,i]),a=n((function(){return f().domain(l).range([0,t])}),[l,t]),d=n((function(){return e.map((function(n){return{x:u(n.x),y:a(n.y),data:n}}))}),[e,u,a]);return n((function(){var n=p.from(d.map((function(n){return[n.x,n.y]}))),o=n.voronoi([0,0,i,t]);return{points:d,delaunay:n,voronoi:o}}),[d,i,t])},S=function(o){var e=o.points,i=o.delaunay,t=o.voronoi;return n((function(){return{points:e,delaunay:i,voronoi:t}}),[e,i,t])},D=function(r){var l=r.elementRef,u=r.nodes,s=r.getNodePosition,c=void 0===s?C:s,h=r.delaunay,v=r.setCurrent,f=r.margin,p=void 0===f?L:f,m=r.detectionRadius,M=void 0===m?1/0:m,b=r.isInteractive,k=void 0===b||b,y=r.onMouseEnter,w=r.onMouseMove,E=r.onMouseLeave,W=r.onClick,x=r.onTouchStart,S=r.onTouchMove,D=r.onTouchEnd,R=r.enableTouchCrosshair,A=void 0!==R&&R,N=r.tooltip,O=r.tooltipPosition,j=void 0===O?T:O,I=r.tooltipAnchor,z=void 0===I?P:I,F=o(null),H=F[0],B=F[1],q=e(null);i((function(){q.current=H}),[q,H]);var G=t((function(n){if(!l.current)return null;var o=a(l.current,n),e=o[0],i=o[1],t=h.find(e,i),r=void 0!==t?u[t]:null;if(r&&M!==1/0){var s=c(r),v=s[0],f=s[1];d(e,i,v+p.left,f+p.top)>M&&(t=null,r=null)}return null===t||null===r?null:[t,r]}),[l,h,u,c,p,M]),J=g(),K=J.showTooltipAt,Q=J.showTooltipFromEvent,U=J.hideTooltip,V=n((function(){if(N)return"cursor"===j?function(n,o){Q(N(n),o,z)}:function(n){var o=c(n),e=o[0],i=o[1];K(N(n),[e+p.left,i+p.top],z)}}),[K,Q,N,j,z,c,p]),X=t((function(n){var o=G(n);if(B(o),null==v||v(o?o[1]:null),o){var e=o[1];null==V||V(e,n),null==y||y(o[1],n)}}),[G,B,v,V,y]),Y=t((function(n){var o=G(n);if(B(o),o){var e=o[0],i=o[1];if(null==v||v(i),null==V||V(i,n),q.current){var t=q.current,r=t[0],l=t[1];e!==r?null==E||E(l,n):null==w||w(i,n)}else null==y||y(i,n)}else null==v||v(null),null==U||U(),q.current&&(null==E||E(q.current[1],n))}),[G,B,q,y,w,E,V,U]),Z=t((function(n){B(null),null==v||v(null),U(),E&&q.current&&E(q.current[1],n)}),[B,v,q,U,E]),$=t((function(n){var o=G(n);B(o),o&&(null==W||W(o[1],n))}),[G,B,W]),_=t((function(n){var o=G(n);A&&(B(o),null==v||v(o?o[1]:null)),o&&(null==x||x(o[1],n))}),[G,B,v,A,x]),nn=t((function(n){var o=G(n);A&&(B(o),null==v||v(o?o[1]:null)),o&&(null==S||S(o[1],n))}),[G,B,v,A,S]),on=t((function(n){A&&(B(null),null==v||v(null)),D&&q.current&&D(q.current[1],n)}),[A,B,v,D,q]);return{current:H,handleMouseEnter:k?X:void 0,handleMouseMove:k?Y:void 0,handleMouseLeave:k?Z:void 0,handleClick:k?$:void 0,handleTouchStart:k?_:void 0,handleTouchMove:k?nn:void 0,handleTouchEnd:k?on:void 0}},R=function(n){var o=n.elementRef,e=n.nodes,i=n.getNodePosition,t=n.width,r=n.height,l=n.margin,u=void 0===l?L:l,a=n.isInteractive,d=void 0===a||a,s=n.detectionRadius,c=void 0===s?1/0:s,h=n.setCurrent,v=n.onMouseEnter,f=n.onMouseMove,p=n.onMouseLeave,g=n.onClick,m=n.tooltip,M=n.tooltipPosition,b=void 0===M?T:M,k=n.tooltipAnchor,y=void 0===k?P:k,C=n.debug,w=W({points:e,getNodePosition:i,width:t,height:r,margin:u,debug:void 0!==C&&C}),E=w.delaunay,x=w.voronoi,S=D({elementRef:o,nodes:e,margin:u,setCurrent:h,delaunay:E,detectionRadius:c,isInteractive:d,onMouseEnter:v,onMouseMove:f,onMouseLeave:p,onClick:g,tooltip:m,tooltipPosition:b,tooltipAnchor:y}),R=S.handleMouseEnter,A=S.handleMouseMove,N=S.handleMouseLeave,O=S.handleClick;return{delaunay:E,voronoi:x,current:S.current,handleMouseEnter:R,handleMouseMove:A,handleMouseLeave:N,handleClick:O}},A=["theme"],N=function(n){var o=n.data,e=n.width,i=n.height,t=n.margin,u=n.layers,a=void 0===u?y.layers:u,d=n.xDomain,s=void 0===d?y.xDomain:d,v=n.yDomain,f=void 0===v?y.yDomain:v,p=n.enableLinks,g=void 0===p?y.enableLinks:p,M=n.linkLineWidth,b=void 0===M?y.linkLineWidth:M,k=n.linkLineColor,C=void 0===k?y.linkLineColor:k,L=n.enableCells,T=void 0===L?y.enableCells:L,P=n.cellLineWidth,w=void 0===P?y.cellLineWidth:P,E=n.cellLineColor,W=void 0===E?y.cellLineColor:E,D=n.enablePoints,R=void 0===D?y.enableCells:D,A=n.pointSize,N=void 0===A?y.pointSize:A,O=n.pointColor,j=void 0===O?y.pointColor:O,I=n.role,z=void 0===I?y.role:I,F=c(e,i,t),H=F.outerWidth,B=F.outerHeight,q=F.margin,G=F.innerWidth,J=F.innerHeight,K=x({data:o,width:G,height:J,xDomain:s,yDomain:f}),Q=K.points,U=K.delaunay,V=K.voronoi,X={links:null,cells:null,points:null,bounds:null};g&&a.includes("links")&&(X.links=m("path",{stroke:C,strokeWidth:b,fill:"none",d:U.render()},"links")),T&&a.includes("cells")&&(X.cells=m("path",{d:V.render(),fill:"none",stroke:W,strokeWidth:w},"cells")),R&&a.includes("points")&&(X.points=m("path",{stroke:"none",fill:j,d:U.renderPoints(void 0,N/2)},"points")),a.includes("bounds")&&(X.bounds=m("path",{fill:"none",stroke:W,strokeWidth:w,d:V.renderBounds()},"bounds"));var Y=S({points:Q,delaunay:U,voronoi:V});return m(h,{width:H,height:B,margin:q,role:z,children:a.map((function(n,o){return void 0!==X[n]?X[n]:"function"==typeof n?m(r,{children:l(n,Y)},o):null}))})},O=function(n){var o=n.theme,e=function(n,o){if(null==n)return{};var e,i,t={},r=Object.keys(n);for(i=0;i<r.length;i++)e=r[i],o.indexOf(e)>=0||(t[e]=n[e]);return t}(n,A);return m(s,{isInteractive:!1,animate:!1,theme:o,children:m(N,k({},e))})},j=function(n){return m(v,{children:function(o){var e=o.width,i=o.height;return m(O,k({width:e,height:i},n))}})},I=function(o){var i=o.nodes,t=o.width,r=o.height,l=o.margin,u=void 0===l?L:l,a=o.getNodePosition,d=o.setCurrent,s=o.onMouseEnter,c=o.onMouseMove,h=o.onMouseLeave,v=o.onClick,f=o.onTouchStart,p=o.onTouchMove,g=o.onTouchEnd,k=o.enableTouchCrosshair,y=void 0!==k&&k,C=o.detectionRadius,w=void 0===C?1/0:C,E=o.tooltip,x=o.tooltipPosition,S=void 0===x?T:x,R=o.tooltipAnchor,A=void 0===R?P:R,N=o.debug,O=e(null),j=W({points:i,getNodePosition:a,width:t,height:r,margin:u,debug:N}),I=j.delaunay,z=j.voronoi,F=D({elementRef:O,nodes:i,delaunay:I,margin:u,detectionRadius:w,setCurrent:d,onMouseEnter:s,onMouseMove:c,onMouseLeave:h,onClick:v,onTouchStart:f,onTouchMove:p,onTouchEnd:g,enableTouchCrosshair:y,tooltip:E,tooltipPosition:S,tooltipAnchor:A}),H=F.current,B=F.handleMouseEnter,q=F.handleMouseMove,G=F.handleMouseLeave,J=F.handleClick,K=F.handleTouchStart,Q=F.handleTouchMove,U=F.handleTouchEnd,V=n((function(){if(N&&z)return z.render()}),[N,z]);return M("g",{ref:O,transform:"translate("+-u.left+","+-u.top+")",children:[N&&z&&M(b,{children:[m("path",{d:V,stroke:"red",strokeWidth:1,opacity:.75}),w<1/0&&m("path",{stroke:"red",strokeWidth:.35,fill:"none",d:I.renderPoints(void 0,w)}),H&&m("path",{fill:"pink",opacity:.35,d:z.renderCell(H[0])})]}),m("rect",{"data-ref":"mesh-interceptor",width:u.left+t+u.right,height:u.top+r+u.bottom,fill:"red",opacity:0,style:{cursor:"auto"},onMouseEnter:B,onMouseMove:q,onMouseLeave:G,onTouchStart:K,onTouchMove:Q,onTouchEnd:U,onClick:J})]})},z=function(n,o){n.save(),n.globalAlpha=.75,n.beginPath(),o.render(n),n.strokeStyle="red",n.lineWidth=1,n.stroke(),n.restore()},F=function(n,o,e){n.save(),n.globalAlpha=.15,n.beginPath(),o.renderPoints(n,e),n.strokeStyle="red",n.lineWidth=1,n.stroke(),n.restore()},H=function(n,o,e){n.save(),n.globalAlpha=.35,n.beginPath(),o.renderCell(e,n),n.fillStyle="pink",n.fill(),n.restore()},B=function(n,o){var e=o.delaunay,i=o.voronoi,t=o.detectionRadius,r=o.index;z(n,i),t<1/0&&F(n,e,t),null!==r&&H(n,i,r)};export{I as Mesh,j as ResponsiveVoronoi,O as Voronoi,E as computeMesh,w as computeMeshPoints,y as defaultVoronoiProps,B as renderDebugToCanvas,F as renderDelaunayPointsToCanvas,H as renderVoronoiCellToCanvas,z as renderVoronoiToCanvas,R as useMesh,D as useMeshEvents,x as useVoronoi,S as useVoronoiLayerContext,W as useVoronoiMesh}; | ||
//# sourceMappingURL=nivo-voronoi.es.js.map |
import { Delaunay } from 'd3-delaunay'; | ||
type NumberPropertyNames<T> = { | ||
[K in keyof T]: T[K] extends number ? K : never; | ||
}[keyof T]; | ||
export type XYAccessor<Datum> = NumberPropertyNames<Datum> | ((datum: Datum) => number); | ||
import { Margin } from '@nivo/core'; | ||
import { NodePositionAccessor } from './types'; | ||
/** | ||
@@ -14,23 +12,18 @@ * The delaunay generator requires an array | ||
*/ | ||
export declare const computeMeshPoints: <Datum>({ points, x, y, }: { | ||
points: Datum[]; | ||
x?: XYAccessor<Datum> | undefined; | ||
y?: XYAccessor<Datum> | undefined; | ||
}) => [ | ||
number, | ||
number | ||
][]; | ||
export declare const computeMesh: ({ points, width, height, debug, }: { | ||
points: [ | ||
number, | ||
number | ||
][]; | ||
export declare const computeMeshPoints: <Node_1>({ points, getNodePosition, margin, }: { | ||
points: readonly Node_1[]; | ||
getNodePosition?: NodePositionAccessor<Node_1> | undefined; | ||
margin?: Margin | undefined; | ||
}) => [number, number][]; | ||
export declare const computeMesh: ({ points, width, height, margin, debug, }: { | ||
points: readonly [number, number][]; | ||
width: number; | ||
height: number; | ||
margin?: Margin | undefined; | ||
debug?: boolean | undefined; | ||
}) => { | ||
points: readonly [number, number][]; | ||
delaunay: Delaunay<Delaunay.Point>; | ||
voronoi: import("d3-delaunay").Voronoi<Delaunay.Point> | undefined; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=computeMesh.d.ts.map |
@@ -0,8 +1,10 @@ | ||
import { MouseEvent, MutableRefObject, TouchEvent } from 'react'; | ||
import { Delaunay } from 'd3-delaunay'; | ||
import { XYAccessor } from './computeMesh'; | ||
import { VoronoiCommonProps, VoronoiDatum, VoronoiCustomLayerProps } from './types'; | ||
export declare const useVoronoiMesh: <Datum>({ points, x, y, width, height, debug, }: { | ||
points: Datum[]; | ||
x?: XYAccessor<Datum> | undefined; | ||
y?: XYAccessor<Datum> | undefined; | ||
import { Margin } from '@nivo/core'; | ||
import { TooltipAnchor, TooltipPosition } from '@nivo/tooltip'; | ||
import { VoronoiCommonProps, VoronoiDatum, VoronoiCustomLayerProps, NodeMouseHandler, NodePositionAccessor, NodeTouchHandler } from './types'; | ||
export declare const useVoronoiMesh: <Node_1>({ points, getNodePosition, width, height, margin, debug, }: { | ||
points: readonly Node_1[]; | ||
getNodePosition?: NodePositionAccessor<Node_1> | undefined; | ||
margin?: Margin | undefined; | ||
width: number; | ||
@@ -12,2 +14,3 @@ height: number; | ||
}) => { | ||
points: readonly [number, number][]; | ||
delaunay: Delaunay<Delaunay.Point>; | ||
@@ -35,2 +38,62 @@ voronoi: import("d3-delaunay").Voronoi<Delaunay.Point> | undefined; | ||
export declare const useVoronoiLayerContext: ({ points, delaunay, voronoi, }: VoronoiCustomLayerProps) => VoronoiCustomLayerProps; | ||
export declare const useMeshEvents: <Node_1, ElementType extends Element>({ elementRef, nodes, getNodePosition, delaunay, setCurrent: setCurrentNode, margin, detectionRadius, isInteractive, onMouseEnter, onMouseMove, onMouseLeave, onClick, onTouchStart, onTouchMove, onTouchEnd, enableTouchCrosshair, tooltip, tooltipPosition, tooltipAnchor, }: { | ||
elementRef: MutableRefObject<ElementType | null>; | ||
nodes: readonly Node_1[]; | ||
getNodePosition?: NodePositionAccessor<Node_1> | undefined; | ||
delaunay: Delaunay<Node_1>; | ||
setCurrent?: ((node: Node_1 | null) => void) | undefined; | ||
margin?: Margin | undefined; | ||
detectionRadius?: number | undefined; | ||
isInteractive?: boolean | undefined; | ||
onMouseEnter?: NodeMouseHandler<Node_1> | undefined; | ||
onMouseMove?: NodeMouseHandler<Node_1> | undefined; | ||
onMouseLeave?: NodeMouseHandler<Node_1> | undefined; | ||
onClick?: NodeMouseHandler<Node_1> | undefined; | ||
onTouchStart?: NodeTouchHandler<Node_1> | undefined; | ||
onTouchMove?: NodeTouchHandler<Node_1> | undefined; | ||
onTouchEnd?: NodeTouchHandler<Node_1> | undefined; | ||
enableTouchCrosshair?: boolean | undefined; | ||
tooltip?: ((node: Node_1) => JSX.Element) | undefined; | ||
tooltipPosition?: TooltipPosition | undefined; | ||
tooltipAnchor?: TooltipAnchor | undefined; | ||
}) => { | ||
current: [number, Node_1] | null; | ||
handleMouseEnter: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleMouseMove: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleMouseLeave: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleClick: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleTouchStart: ((event: TouchEvent<ElementType>) => void) | undefined; | ||
handleTouchMove: ((event: TouchEvent<ElementType>) => void) | undefined; | ||
handleTouchEnd: ((event: TouchEvent<SVGRectElement>) => void) | undefined; | ||
}; | ||
/** | ||
* Compute a voronoi mesh and corresponding events. | ||
*/ | ||
export declare const useMesh: <Node_1, ElementType extends Element>({ elementRef, nodes, getNodePosition, width, height, margin, isInteractive, detectionRadius, setCurrent, onMouseEnter, onMouseMove, onMouseLeave, onClick, tooltip, tooltipPosition, tooltipAnchor, debug, }: { | ||
elementRef: MutableRefObject<ElementType | null>; | ||
nodes: readonly Node_1[]; | ||
getNodePosition?: NodePositionAccessor<Node_1> | undefined; | ||
width: number; | ||
height: number; | ||
margin?: Margin | undefined; | ||
isInteractive?: boolean | undefined; | ||
detectionRadius?: number | undefined; | ||
setCurrent?: ((node: Node_1 | null) => void) | undefined; | ||
onMouseEnter?: NodeMouseHandler<Node_1> | undefined; | ||
onMouseMove?: NodeMouseHandler<Node_1> | undefined; | ||
onMouseLeave?: NodeMouseHandler<Node_1> | undefined; | ||
onClick?: NodeMouseHandler<Node_1> | undefined; | ||
tooltip?: ((node: Node_1) => JSX.Element) | undefined; | ||
tooltipPosition?: TooltipPosition | undefined; | ||
tooltipAnchor?: TooltipAnchor | undefined; | ||
debug?: boolean | undefined; | ||
}) => { | ||
delaunay: Delaunay<Delaunay.Point>; | ||
voronoi: import("d3-delaunay").Voronoi<Delaunay.Point> | undefined; | ||
current: [number, Node_1] | null; | ||
handleMouseEnter: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleMouseMove: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleMouseLeave: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
handleClick: ((event: MouseEvent<ElementType, globalThis.MouseEvent>) => void) | undefined; | ||
}; | ||
//# sourceMappingURL=hooks.d.ts.map |
@@ -1,23 +0,28 @@ | ||
import { MouseEvent, TouchEvent } from 'react'; | ||
import { XYAccessor } from './computeMesh'; | ||
type MouseHandler<Datum> = (datum: Datum, event: MouseEvent) => void; | ||
type TouchHandler<Datum> = (datum: Datum, event: TouchEvent) => void; | ||
interface MeshProps<Datum> { | ||
nodes: Datum[]; | ||
/// <reference types="react" /> | ||
import { Margin } from '@nivo/core'; | ||
import { TooltipAnchor, TooltipPosition } from '@nivo/tooltip'; | ||
import { NodeMouseHandler, NodePositionAccessor, NodeTouchHandler } from './types'; | ||
interface MeshProps<Node> { | ||
nodes: Node[]; | ||
width: number; | ||
height: number; | ||
x?: XYAccessor<Datum>; | ||
y?: XYAccessor<Datum>; | ||
onMouseEnter?: MouseHandler<Datum>; | ||
onMouseMove?: MouseHandler<Datum>; | ||
onMouseLeave?: MouseHandler<Datum>; | ||
onClick?: MouseHandler<Datum>; | ||
onTouchStart?: TouchHandler<Datum>; | ||
onTouchMove?: TouchHandler<Datum>; | ||
onTouchEnd?: TouchHandler<Datum>; | ||
margin?: Margin; | ||
getNodePosition?: NodePositionAccessor<Node>; | ||
setCurrent?: (node: Node | null) => void; | ||
onMouseEnter?: NodeMouseHandler<Node>; | ||
onMouseMove?: NodeMouseHandler<Node>; | ||
onMouseLeave?: NodeMouseHandler<Node>; | ||
onClick?: NodeMouseHandler<Node>; | ||
onTouchStart?: NodeTouchHandler<Node>; | ||
onTouchMove?: NodeTouchHandler<Node>; | ||
onTouchEnd?: NodeTouchHandler<Node>; | ||
enableTouchCrosshair?: boolean; | ||
detectionRadius?: number; | ||
tooltip?: (node: Node) => JSX.Element; | ||
tooltipPosition?: TooltipPosition; | ||
tooltipAnchor?: TooltipAnchor; | ||
debug?: boolean; | ||
} | ||
export declare const Mesh: <Datum>({ nodes, width, height, x, y, onMouseEnter, onMouseMove, onMouseLeave, onClick, onTouchStart, onTouchMove, onTouchEnd, enableTouchCrosshair, debug, }: MeshProps<Datum>) => JSX.Element; | ||
export declare const Mesh: <Node_1>({ nodes, width, height, margin, getNodePosition, setCurrent, onMouseEnter, onMouseMove, onMouseLeave, onClick, onTouchStart, onTouchMove, onTouchEnd, enableTouchCrosshair, detectionRadius, tooltip, tooltipPosition, tooltipAnchor, debug, }: MeshProps<Node_1>) => JSX.Element; | ||
export {}; | ||
//# sourceMappingURL=Mesh.d.ts.map |
import { Delaunay, Voronoi } from 'd3-delaunay'; | ||
export declare const renderVoronoiToCanvas: (ctx: CanvasRenderingContext2D, voronoi: Voronoi<Delaunay.Point>) => void; | ||
export declare const renderDelaunayPointsToCanvas: (ctx: CanvasRenderingContext2D, delaunay: Delaunay<Delaunay.Point>, radius: number) => void; | ||
export declare const renderVoronoiCellToCanvas: (ctx: CanvasRenderingContext2D, voronoi: Voronoi<Delaunay.Point>, index: number) => void; | ||
export declare const renderDebugToCanvas: (ctx: CanvasRenderingContext2D, { delaunay, voronoi, detectionRadius, index, }: { | ||
delaunay: Delaunay<Delaunay.Point>; | ||
voronoi: Voronoi<Delaunay.Point>; | ||
detectionRadius: number; | ||
index: number | null; | ||
}) => void; | ||
//# sourceMappingURL=meshCanvas.d.ts.map |
@@ -1,4 +0,7 @@ | ||
import * as React from 'react'; | ||
import { MouseEvent, TouchEvent, FunctionComponent } from 'react'; | ||
import { Theme, Box } from '@nivo/core'; | ||
import { Delaunay, Voronoi } from 'd3-delaunay'; | ||
export type NodeMouseHandler<Node> = (node: Node, Node: MouseEvent) => void; | ||
export type NodeTouchHandler<Node> = (node: Node, event: TouchEvent) => void; | ||
export type NodePositionAccessor<Node> = (node: Node) => [number, number]; | ||
export type VoronoiDatum = { | ||
@@ -20,3 +23,3 @@ id: string | number; | ||
} | ||
export type VoronoiCustomLayer = React.FC<VoronoiCustomLayerProps>; | ||
export type VoronoiCustomLayer = FunctionComponent<VoronoiCustomLayerProps>; | ||
export type VoronoiLayer = VoronoiLayerId | VoronoiCustomLayer; | ||
@@ -23,0 +26,0 @@ export type VoronoiCommonProps = { |
{ | ||
"name": "@nivo/voronoi", | ||
"version": "0.86.0", | ||
"version": "0.87.0", | ||
"license": "MIT", | ||
@@ -32,6 +32,7 @@ "author": { | ||
"dependencies": { | ||
"@nivo/core": "0.86.0", | ||
"@types/d3-delaunay": "^5.3.0", | ||
"@nivo/core": "0.87.0", | ||
"@nivo/tooltip": "0.87.0", | ||
"@types/d3-delaunay": "^6.0.4", | ||
"@types/d3-scale": "^4.0.8", | ||
"d3-delaunay": "^5.3.0", | ||
"d3-delaunay": "^6.0.4", | ||
"d3-scale": "^4.0.2" | ||
@@ -45,3 +46,3 @@ }, | ||
}, | ||
"gitHead": "6996fc1a0f0d3ee20ec002316e4d0d3aeddbd4ed" | ||
"gitHead": "da6d6b751cff5570fb7378d57b52e3e4bdbcf872" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131496
28
361
7
1
+ Added@nivo/tooltip@0.87.0
+ Added@nivo/core@0.87.0(transitive)
+ Added@nivo/tooltip@0.87.0(transitive)
+ Added@types/d3-delaunay@6.0.4(transitive)
+ Added@types/d3-path@3.1.0(transitive)
+ Added@types/d3-shape@3.1.7(transitive)
+ Addedd3-delaunay@6.0.4(transitive)
+ Addedd3-path@3.1.0(transitive)
+ Addedd3-shape@3.2.0(transitive)
+ Addeddelaunator@5.0.1(transitive)
+ Addedrobust-predicates@3.0.2(transitive)
- Removed@nivo/core@0.86.0(transitive)
- Removed@nivo/recompose@0.86.0(transitive)
- Removed@nivo/tooltip@0.86.0(transitive)
- Removed@types/d3-delaunay@5.3.4(transitive)
- Removed@types/d3-path@2.0.4(transitive)
- Removed@types/d3-shape@2.1.7(transitive)
- Removed@types/prop-types@15.7.14(transitive)
- Removed@types/react@19.0.3(transitive)
- Removed@types/react-lifecycles-compat@3.0.4(transitive)
- Removedcsstype@3.1.3(transitive)
- Removedd3-delaunay@5.3.0(transitive)
- Removedd3-path@1.0.9(transitive)
- Removedd3-shape@1.3.7(transitive)
- Removeddelaunator@4.0.1(transitive)
- Removedreact-lifecycles-compat@3.0.4(transitive)
Updated@nivo/core@0.87.0
Updated@types/d3-delaunay@^6.0.4
Updatedd3-delaunay@^6.0.4