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

@nivo/voronoi

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/voronoi - npm Package Compare versions

Comparing version 0.71.0 to 0.72.0

202

dist/nivo-voronoi.cjs.js

@@ -5,10 +5,51 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
var react = require('react');
var core = require('@nivo/core');
var d3Scale = require('d3-scale');
var d3Delaunay = require('d3-delaunay');
var jsxRuntime = require('react/jsx-runtime');
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -97,3 +138,3 @@ if (source == null) return {};

debug = _ref.debug;
var points2d = React.useMemo(function () {
var points2d = react.useMemo(function () {
return computeMeshPoints({

@@ -105,3 +146,3 @@ points: points,

}, [points, x, y]);
return React.useMemo(function () {
return react.useMemo(function () {
return computeMesh({

@@ -121,9 +162,9 @@ points: points2d,

yDomain = _ref2.yDomain;
var xScale = React.useMemo(function () {
var xScale = react.useMemo(function () {
return d3Scale.scaleLinear().domain(xDomain).range([0, width]);
}, [xDomain, width]);
var yScale = React.useMemo(function () {
var yScale = react.useMemo(function () {
return d3Scale.scaleLinear().domain(yDomain).range([0, height]);
}, [yDomain, height]);
var points = React.useMemo(function () {
var points = react.useMemo(function () {
return data.map(function (d) {

@@ -137,3 +178,3 @@ return {

}, [data, xScale, yScale]);
return React.useMemo(function () {
return react.useMemo(function () {
var delaunay = d3Delaunay.Delaunay.from(points.map(function (p) {

@@ -154,3 +195,3 @@ return [p.x, p.y];

voronoi = _ref3.voronoi;
return React.useMemo(function () {
return react.useMemo(function () {
return {

@@ -222,4 +263,3 @@ points: points,

if (enableLinks && layers.includes('links')) {
layerById.links = React__default.createElement("path", {
key: "links",
layerById.links = jsxRuntime.jsx("path", {
stroke: linkLineColor,

@@ -229,8 +269,7 @@ strokeWidth: linkLineWidth,

d: delaunay.render()
});
}, "links");
}
if (enableCells && layers.includes('cells')) {
layerById.cells = React__default.createElement("path", {
key: "cells",
layerById.cells = jsxRuntime.jsx("path", {
d: voronoi.render(),

@@ -240,17 +279,15 @@ fill: "none",

strokeWidth: cellLineWidth
});
}, "cells");
}
if (enablePoints && layers.includes('points')) {
layerById.points = React__default.createElement("path", {
key: "points",
layerById.points = jsxRuntime.jsx("path", {
stroke: "none",
fill: pointColor,
d: delaunay.renderPoints(undefined, pointSize / 2)
});
}, "points");
}
if (layers.includes('bounds')) {
layerById.bounds = React__default.createElement("path", {
key: "bounds",
layerById.bounds = jsxRuntime.jsx("path", {
fill: "none",

@@ -260,3 +297,3 @@ stroke: cellLineColor,

d: voronoi.renderBounds()
});
}, "bounds");
}

@@ -269,20 +306,21 @@

});
return React__default.createElement(core.SvgWrapper, {
return jsxRuntime.jsx(core.SvgWrapper, {
width: outerWidth,
height: outerHeight,
margin: margin,
role: role
}, layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
role: role,
children: layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
if (typeof layer === 'function') {
return React__default.createElement(React.Fragment, {
key: i
}, React.createElement(layer, layerContext));
}
if (typeof layer === 'function') {
return jsxRuntime.jsx(react.Fragment, {
children: react.createElement(layer, layerContext)
}, i);
}
return null;
}));
return null;
})
});
};

@@ -294,17 +332,20 @@

return React__default.createElement(core.Container, {
return jsxRuntime.jsx(core.Container, {
isInteractive: false,
animate: false,
theme: theme
}, React__default.createElement(InnerVoronoi, otherProps));
theme: theme,
children: jsxRuntime.jsx(InnerVoronoi, _objectSpread2({}, otherProps))
});
};
var ResponsiveVoronoi = function ResponsiveVoronoi(props) {
return React__default.createElement(core.ResponsiveWrapper, null, function (_ref) {
var width = _ref.width,
height = _ref.height;
return React__default.createElement(Voronoi, Object.assign({
width: width,
height: height
}, props));
return jsxRuntime.jsx(core.ResponsiveWrapper, {
children: function children(_ref) {
var width = _ref.width,
height = _ref.height;
return jsxRuntime.jsx(Voronoi, _objectSpread2({
width: width,
height: height
}, props));
}
});

@@ -354,3 +395,3 @@ };

if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);

@@ -378,5 +419,5 @@ }

debug = _ref.debug;
var elementRef = React.useRef(null);
var elementRef = react.useRef(null);
var _useState = React.useState(null),
var _useState = react.useState(null),
_useState2 = _slicedToArray(_useState, 2),

@@ -397,3 +438,3 @@ currentIndex = _useState2[0],

var voronoiPath = React.useMemo(function () {
var voronoiPath = react.useMemo(function () {
if (debug && voronoi) {

@@ -405,3 +446,3 @@ return voronoi.render();

}, [debug, voronoi]);
var getIndexAndNodeFromEvent = React.useCallback(function (event) {
var getIndexAndNodeFromEvent = react.useCallback(function (event) {
if (!elementRef.current) {

@@ -419,3 +460,3 @@ return [null, null];

}, [elementRef, delaunay]);
var handleMouseEnter = React.useCallback(function (event) {
var handleMouseEnter = react.useCallback(function (event) {
var _getIndexAndNodeFromE = getIndexAndNodeFromEvent(event),

@@ -432,3 +473,3 @@ _getIndexAndNodeFromE2 = _slicedToArray(_getIndexAndNodeFromE, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onMouseEnter]);
var handleMouseMove = React.useCallback(function (event) {
var handleMouseMove = react.useCallback(function (event) {
var _getIndexAndNodeFromE3 = getIndexAndNodeFromEvent(event),

@@ -445,3 +486,3 @@ _getIndexAndNodeFromE4 = _slicedToArray(_getIndexAndNodeFromE3, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onMouseMove]);
var handleMouseLeave = React.useCallback(function (event) {
var handleMouseLeave = react.useCallback(function (event) {
setCurrentIndex(null);

@@ -459,3 +500,3 @@

}, [setCurrentIndex, currentIndex, onMouseLeave, nodes]);
var handleClick = React.useCallback(function (event) {
var handleClick = react.useCallback(function (event) {
var _getIndexAndNodeFromE5 = getIndexAndNodeFromEvent(event),

@@ -472,26 +513,29 @@ _getIndexAndNodeFromE6 = _slicedToArray(_getIndexAndNodeFromE5, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onClick]);
return React__default.createElement("g", {
ref: elementRef
}, debug && voronoi && React__default.createElement(React__default.Fragment, null, React__default.createElement("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && React__default.createElement("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})), React__default.createElement("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
}));
return jsxRuntime.jsxs("g", {
ref: elementRef,
children: [debug && voronoi && jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [jsxRuntime.jsx("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && jsxRuntime.jsx("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})]
}), jsxRuntime.jsx("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
})]
});
};

@@ -498,0 +542,0 @@

@@ -1,6 +0,50 @@

import React, { useMemo, Fragment, createElement, useRef, useState, useCallback } from 'react';
import { useMemo, Fragment, createElement, useRef, useState, useCallback } from 'react';
import { Container, useDimensions, SvgWrapper, ResponsiveWrapper, getRelativeCursor } from '@nivo/core';
import { scaleLinear } from 'd3-scale';
import { Delaunay } from 'd3-delaunay';
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -209,4 +253,3 @@ if (source == null) return {};

if (enableLinks && layers.includes('links')) {
layerById.links = React.createElement("path", {
key: "links",
layerById.links = jsx("path", {
stroke: linkLineColor,

@@ -216,8 +259,7 @@ strokeWidth: linkLineWidth,

d: delaunay.render()
});
}, "links");
}
if (enableCells && layers.includes('cells')) {
layerById.cells = React.createElement("path", {
key: "cells",
layerById.cells = jsx("path", {
d: voronoi.render(),

@@ -227,17 +269,15 @@ fill: "none",

strokeWidth: cellLineWidth
});
}, "cells");
}
if (enablePoints && layers.includes('points')) {
layerById.points = React.createElement("path", {
key: "points",
layerById.points = jsx("path", {
stroke: "none",
fill: pointColor,
d: delaunay.renderPoints(undefined, pointSize / 2)
});
}, "points");
}
if (layers.includes('bounds')) {
layerById.bounds = React.createElement("path", {
key: "bounds",
layerById.bounds = jsx("path", {
fill: "none",

@@ -247,3 +287,3 @@ stroke: cellLineColor,

d: voronoi.renderBounds()
});
}, "bounds");
}

@@ -256,20 +296,21 @@

});
return React.createElement(SvgWrapper, {
return jsx(SvgWrapper, {
width: outerWidth,
height: outerHeight,
margin: margin,
role: role
}, layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
role: role,
children: layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
if (typeof layer === 'function') {
return React.createElement(Fragment, {
key: i
}, createElement(layer, layerContext));
}
if (typeof layer === 'function') {
return jsx(Fragment, {
children: createElement(layer, layerContext)
}, i);
}
return null;
}));
return null;
})
});
};

@@ -281,17 +322,20 @@

return React.createElement(Container, {
return jsx(Container, {
isInteractive: false,
animate: false,
theme: theme
}, React.createElement(InnerVoronoi, otherProps));
theme: theme,
children: jsx(InnerVoronoi, _objectSpread2({}, otherProps))
});
};
var ResponsiveVoronoi = function ResponsiveVoronoi(props) {
return React.createElement(ResponsiveWrapper, null, function (_ref) {
var width = _ref.width,
height = _ref.height;
return React.createElement(Voronoi, Object.assign({
width: width,
height: height
}, props));
return jsx(ResponsiveWrapper, {
children: function children(_ref) {
var width = _ref.width,
height = _ref.height;
return jsx(Voronoi, _objectSpread2({
width: width,
height: height
}, props));
}
});

@@ -341,3 +385,3 @@ };

if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);

@@ -452,26 +496,29 @@ }

}, [getIndexAndNodeFromEvent, setCurrentIndex, onClick]);
return React.createElement("g", {
ref: elementRef
}, debug && voronoi && React.createElement(React.Fragment, null, React.createElement("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && React.createElement("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})), React.createElement("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
}));
return jsxs("g", {
ref: elementRef,
children: [debug && voronoi && jsxs(Fragment$1, {
children: [jsx("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && jsx("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})]
}), jsx("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
})]
});
};

@@ -478,0 +525,0 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@nivo/core'), require('d3-scale'), require('d3-delaunay')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', '@nivo/core', 'd3-scale', 'd3-delaunay'], factory) :
(global = global || self, factory(global.nivo = global.nivo || {}, global.React, global.nivo, global.d3, global.d3));
}(this, (function (exports, React, core, d3Scale, d3Delaunay) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@nivo/core'), require('d3-scale'), require('d3-delaunay'), require('react/jsx-runtime')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', '@nivo/core', 'd3-scale', 'd3-delaunay', 'react/jsx-runtime'], factory) :
(global = global || self, factory(global.nivo = global.nivo || {}, global.React, global.nivo, global.d3, global.d3, global['react/jsx-runtime']));
}(this, (function (exports, react, core, d3Scale, d3Delaunay, jsxRuntime) { 'use strict';
var React__default = 'default' in React ? React['default'] : React;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {

@@ -92,3 +133,3 @@ if (source == null) return {};

debug = _ref.debug;
var points2d = React.useMemo(function () {
var points2d = react.useMemo(function () {
return computeMeshPoints({

@@ -100,3 +141,3 @@ points: points,

}, [points, x, y]);
return React.useMemo(function () {
return react.useMemo(function () {
return computeMesh({

@@ -116,9 +157,9 @@ points: points2d,

yDomain = _ref2.yDomain;
var xScale = React.useMemo(function () {
var xScale = react.useMemo(function () {
return d3Scale.scaleLinear().domain(xDomain).range([0, width]);
}, [xDomain, width]);
var yScale = React.useMemo(function () {
var yScale = react.useMemo(function () {
return d3Scale.scaleLinear().domain(yDomain).range([0, height]);
}, [yDomain, height]);
var points = React.useMemo(function () {
var points = react.useMemo(function () {
return data.map(function (d) {

@@ -132,3 +173,3 @@ return {

}, [data, xScale, yScale]);
return React.useMemo(function () {
return react.useMemo(function () {
var delaunay = d3Delaunay.Delaunay.from(points.map(function (p) {

@@ -149,3 +190,3 @@ return [p.x, p.y];

voronoi = _ref3.voronoi;
return React.useMemo(function () {
return react.useMemo(function () {
return {

@@ -217,4 +258,3 @@ points: points,

if (enableLinks && layers.includes('links')) {
layerById.links = React__default.createElement("path", {
key: "links",
layerById.links = jsxRuntime.jsx("path", {
stroke: linkLineColor,

@@ -224,8 +264,7 @@ strokeWidth: linkLineWidth,

d: delaunay.render()
});
}, "links");
}
if (enableCells && layers.includes('cells')) {
layerById.cells = React__default.createElement("path", {
key: "cells",
layerById.cells = jsxRuntime.jsx("path", {
d: voronoi.render(),

@@ -235,17 +274,15 @@ fill: "none",

strokeWidth: cellLineWidth
});
}, "cells");
}
if (enablePoints && layers.includes('points')) {
layerById.points = React__default.createElement("path", {
key: "points",
layerById.points = jsxRuntime.jsx("path", {
stroke: "none",
fill: pointColor,
d: delaunay.renderPoints(undefined, pointSize / 2)
});
}, "points");
}
if (layers.includes('bounds')) {
layerById.bounds = React__default.createElement("path", {
key: "bounds",
layerById.bounds = jsxRuntime.jsx("path", {
fill: "none",

@@ -255,3 +292,3 @@ stroke: cellLineColor,

d: voronoi.renderBounds()
});
}, "bounds");
}

@@ -264,20 +301,21 @@

});
return React__default.createElement(core.SvgWrapper, {
return jsxRuntime.jsx(core.SvgWrapper, {
width: outerWidth,
height: outerHeight,
margin: margin,
role: role
}, layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
role: role,
children: layers.map(function (layer, i) {
if (layerById[layer] !== undefined) {
return layerById[layer];
}
if (typeof layer === 'function') {
return React__default.createElement(React.Fragment, {
key: i
}, React.createElement(layer, layerContext));
}
if (typeof layer === 'function') {
return jsxRuntime.jsx(react.Fragment, {
children: react.createElement(layer, layerContext)
}, i);
}
return null;
}));
return null;
})
});
};

@@ -289,17 +327,20 @@

return React__default.createElement(core.Container, {
return jsxRuntime.jsx(core.Container, {
isInteractive: false,
animate: false,
theme: theme
}, React__default.createElement(InnerVoronoi, otherProps));
theme: theme,
children: jsxRuntime.jsx(InnerVoronoi, _objectSpread2({}, otherProps))
});
};
var ResponsiveVoronoi = function ResponsiveVoronoi(props) {
return React__default.createElement(core.ResponsiveWrapper, null, function (_ref) {
var width = _ref.width,
height = _ref.height;
return React__default.createElement(Voronoi, Object.assign({
width: width,
height: height
}, props));
return jsxRuntime.jsx(core.ResponsiveWrapper, {
children: function children(_ref) {
var width = _ref.width,
height = _ref.height;
return jsxRuntime.jsx(Voronoi, _objectSpread2({
width: width,
height: height
}, props));
}
});

@@ -349,3 +390,3 @@ };

if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);

@@ -373,5 +414,5 @@ }

debug = _ref.debug;
var elementRef = React.useRef(null);
var elementRef = react.useRef(null);
var _useState = React.useState(null),
var _useState = react.useState(null),
_useState2 = _slicedToArray(_useState, 2),

@@ -392,3 +433,3 @@ currentIndex = _useState2[0],

var voronoiPath = React.useMemo(function () {
var voronoiPath = react.useMemo(function () {
if (debug && voronoi) {

@@ -400,3 +441,3 @@ return voronoi.render();

}, [debug, voronoi]);
var getIndexAndNodeFromEvent = React.useCallback(function (event) {
var getIndexAndNodeFromEvent = react.useCallback(function (event) {
if (!elementRef.current) {

@@ -414,3 +455,3 @@ return [null, null];

}, [elementRef, delaunay]);
var handleMouseEnter = React.useCallback(function (event) {
var handleMouseEnter = react.useCallback(function (event) {
var _getIndexAndNodeFromE = getIndexAndNodeFromEvent(event),

@@ -427,3 +468,3 @@ _getIndexAndNodeFromE2 = _slicedToArray(_getIndexAndNodeFromE, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onMouseEnter]);
var handleMouseMove = React.useCallback(function (event) {
var handleMouseMove = react.useCallback(function (event) {
var _getIndexAndNodeFromE3 = getIndexAndNodeFromEvent(event),

@@ -440,3 +481,3 @@ _getIndexAndNodeFromE4 = _slicedToArray(_getIndexAndNodeFromE3, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onMouseMove]);
var handleMouseLeave = React.useCallback(function (event) {
var handleMouseLeave = react.useCallback(function (event) {
setCurrentIndex(null);

@@ -454,3 +495,3 @@

}, [setCurrentIndex, currentIndex, onMouseLeave, nodes]);
var handleClick = React.useCallback(function (event) {
var handleClick = react.useCallback(function (event) {
var _getIndexAndNodeFromE5 = getIndexAndNodeFromEvent(event),

@@ -467,26 +508,29 @@ _getIndexAndNodeFromE6 = _slicedToArray(_getIndexAndNodeFromE5, 2),

}, [getIndexAndNodeFromEvent, setCurrentIndex, onClick]);
return React__default.createElement("g", {
ref: elementRef
}, debug && voronoi && React__default.createElement(React__default.Fragment, null, React__default.createElement("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && React__default.createElement("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})), React__default.createElement("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
}));
return jsxRuntime.jsxs("g", {
ref: elementRef,
children: [debug && voronoi && jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [jsxRuntime.jsx("path", {
d: voronoiPath,
stroke: "red",
strokeWidth: 1,
opacity: 0.75
}), currentIndex !== null && jsxRuntime.jsx("path", {
fill: "pink",
opacity: 0.35,
d: voronoi.renderCell(currentIndex)
})]
}), jsxRuntime.jsx("rect", {
width: width,
height: height,
fill: "red",
opacity: 0,
style: {
cursor: 'auto'
},
onMouseEnter: handleMouseEnter,
onMouseMove: handleMouseMove,
onMouseLeave: handleMouseLeave,
onClick: handleClick
})]
});
};

@@ -493,0 +537,0 @@

@@ -16,4 +16,4 @@ import { Delaunay } from 'd3-delaunay';

points: Datum[];
x?: NumberPropertyNames<Datum> | ((datum: Datum) => number) | undefined;
y?: NumberPropertyNames<Datum> | ((datum: Datum) => number) | undefined;
x?: XYAccessor<Datum> | undefined;
y?: XYAccessor<Datum> | undefined;
}) => [number, number][];

@@ -20,0 +20,0 @@ export declare const computeMesh: ({ points, width, height, debug, }: {

@@ -6,4 +6,4 @@ import { Delaunay } from 'd3-delaunay';

points: Datum[];
x?: { [K in keyof Datum]: Datum[K] extends number ? K : never; }[keyof Datum] | ((datum: Datum) => number) | undefined;
y?: { [K in keyof Datum]: Datum[K] extends number ? K : never; }[keyof Datum] | ((datum: Datum) => number) | undefined;
x?: XYAccessor<Datum> | undefined;
y?: XYAccessor<Datum> | undefined;
width: number;

@@ -10,0 +10,0 @@ height: number;

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

import React from 'react';
import * as React from 'react';
import { XYAccessor } from './computeMesh';

@@ -3,0 +3,0 @@ declare type MouseHandler<Datum> = (datum: Datum, event: React.MouseEvent) => void;

{
"name": "@nivo/voronoi",
"version": "0.71.0",
"version": "0.72.0",
"license": "MIT",

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

"devDependencies": {
"@nivo/core": "0.71.0",
"@nivo/core": "0.72.0",
"@types/d3-delaunay": "^5.3.0",

@@ -42,3 +42,3 @@ "@types/d3-scale": "^3.2.2"

"peerDependencies": {
"@nivo/core": "0.71.0",
"@nivo/core": "0.72.0",
"react": ">= 16.8.4 < 18.0.0"

@@ -49,3 +49,3 @@ },

},
"gitHead": "232b613bd61d2b8e5c783f4181b2d14580e2fd27"
"gitHead": "26098f6437cd8ab2be166bbc52973dcbb5ee7569"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc