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

victory-voronoi-container

Package Overview
Dependencies
Maintainers
16
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-voronoi-container - npm Package Compare versions

Comparing version 36.8.2 to 36.8.3

es/victory-voronoi-container.d.ts

8

CHANGELOG.md
# victory-voronoi-container
## 36.8.3
### Patch Changes
- Migrate victory-voronoi-container to TypeScript ([#2727](https://github.com/FormidableLabs/victory/pull/2727))
* Refactor param reassignments ([#2724](https://github.com/FormidableLabs/victory/pull/2724))
## 36.8.2

@@ -4,0 +12,0 @@

47

es/index.d.ts

@@ -1,44 +0,3 @@

import * as React from "react";
import { PaddingProps, VictoryContainerProps } from "victory-core";
export interface VictoryVoronoiContainerProps extends VictoryContainerProps {
activateData?: boolean;
activateLabels?: boolean;
disable?: boolean;
labels?: (point: any, index: number, points: any[]) => string;
labelComponent?: React.ReactElement;
mouseFollowTooltips?: boolean;
onActivated?: (points: any[], props: VictoryVoronoiContainerProps) => void;
onDeactivated?: (points: any[], props: VictoryVoronoiContainerProps) => void;
radius?: number;
voronoiBlacklist?: (string | RegExp)[];
voronoiDimension?: "x" | "y";
voronoiPadding?: PaddingProps;
}
export class VictoryVoronoiContainer extends React.Component<
VictoryVoronoiContainerProps,
any
> {}
export const VoronoiHelpers: {
withinBounds(props: any, point: any): any;
getDatasets(props: any): any;
findPoints(datasets: any, point: any): any;
withinRadius(point: any, mousePosition: any, radius: any): any;
getVoronoiPoints(props: any, mousePosition: any): any;
getActiveMutations(props: any, point: any): any;
getInactiveMutations(props: any, point: any): any;
getParentMutation(
activePoints: any,
mousePosition: any,
parentSVG: any,
vIndex: any,
): any;
onActivated(props: any, points: any): any;
onDeactivated(props: any, points: any): any;
onMouseLeave(evt: any, targetProps: any): any;
onMouseMove(evt: any, targetProps: any): any;
};
export const voronoiContainerMixin: (base: Function) => Function;
export * from "./victory-voronoi-container";
export * from "./voronoi-helpers";
//# sourceMappingURL=index.d.ts.map

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

export { voronoiContainerMixin, default as VictoryVoronoiContainer } from "./victory-voronoi-container";
export { default as VoronoiHelpers } from "./voronoi-helpers";
export * from "./victory-voronoi-container";
export * from "./voronoi-helpers";

@@ -49,12 +49,12 @@ import _pick from "lodash/pick";

/* eslint-disable react/no-multi-comp */
import PropTypes from "prop-types";
import React from "react";
import { VictoryTooltip } from "victory-tooltip";
import { VictoryContainer, Helpers, PropTypes as CustomPropTypes } from "victory-core";
import VoronoiHelpers from "./voronoi-helpers";
export var voronoiContainerMixin = function (base) {
import { VictoryContainer, Helpers } from "victory-core";
import { VoronoiHelpers } from "./voronoi-helpers";
export function voronoiContainerMixin(Base) {
var _class;
return _class = /*#__PURE__*/function (_base) {
_inherits(VictoryVoronoiContainer, _base);
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
return _class = /*#__PURE__*/function (_Base) {
_inherits(VictoryVoronoiContainer, _Base);

@@ -138,4 +138,3 @@ var _super = _createSuper(VictoryVoronoiContainer);

}) : [style];
memo = memo.concat(styleArray);
return memo;
return memo.concat(styleArray);
}, []);

@@ -184,4 +183,3 @@ }

memo = memo.concat("".concat(t).split("\n"));
return memo;
return memo.concat("".concat(t).split("\n"));
}, []); // remove properties from first point to make datum

@@ -248,21 +246,3 @@ // eslint-disable-next-line no-unused-vars

return VictoryVoronoiContainer;
}(base), _class.displayName = "VictoryVoronoiContainer", _class.propTypes = _objectSpread(_objectSpread({}, VictoryContainer.propTypes), {}, {
activateData: PropTypes.bool,
activateLabels: PropTypes.bool,
disable: PropTypes.bool,
labelComponent: PropTypes.element,
labels: PropTypes.func,
mouseFollowTooltips: PropTypes.bool,
onActivated: PropTypes.func,
onDeactivated: PropTypes.func,
radius: PropTypes.number,
voronoiBlacklist: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, CustomPropTypes.regExp])),
voronoiDimension: PropTypes.oneOf(["x", "y"]),
voronoiPadding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
top: PropTypes.number,
bottom: PropTypes.number,
left: PropTypes.number,
right: PropTypes.number
})])
}), _class.defaultProps = _objectSpread(_objectSpread({}, VictoryContainer.defaultProps), {}, {
}(Base), _class.displayName = "VictoryVoronoiContainer", _class.defaultProps = _objectSpread(_objectSpread({}, VictoryContainer.defaultProps), {}, {
activateData: true,

@@ -304,5 +284,3 @@ activateLabels: true,

}, _class;
};
export default voronoiContainerMixin(VictoryContainer); // @ts-expect-error IMPORTANT: when converting this file to TypeScript, you must export the type as well:
// export const VictoryVoronoiContainer = voronoiContainerMixin(VictoryContainer);
// export type VictoryVoronoiContainer = typeof VictoryVoronoiContainer;
}
export var VictoryVoronoiContainer = voronoiContainerMixin(VictoryContainer);

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

import _throttle from "lodash/throttle";
import _isRegExp from "lodash/isRegExp";

@@ -6,3 +7,2 @@ import _isString from "lodash/isString";

import _isFunction from "lodash/isFunction";
import _throttle from "lodash/throttle";
import _assign from "lodash/assign";

@@ -22,2 +22,8 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
import { Collection, Selection, Data, Helpers } from "victory-core";

@@ -27,265 +33,298 @@ import isEqual from "react-fast-compare";

import React from "react";
var VoronoiHelpers = {
withinBounds: function (props, point) {
var width = props.width,
height = props.height,
polar = props.polar,
origin = props.origin,
scale = props.scale;
var padding = Helpers.getPadding(props, "voronoiPadding");
var x = point.x,
y = point.y;
var ON_MOUSE_MOVE_THROTTLE_MS = 32;
if (polar) {
var distanceSquared = Math.pow(x - origin.x, 2) + Math.pow(y - origin.y, 2);
var radius = Math.max.apply(Math, _toConsumableArray(scale.y.range()));
return distanceSquared < Math.pow(radius, 2);
}
var VoronoiHelpersClass = /*#__PURE__*/function () {
function VoronoiHelpersClass() {
var _this = this;
return x >= padding.left && x <= width - padding.right && y >= padding.top && y <= height - padding.bottom;
},
getDatasets: function (props) {
var minDomain = {
x: Collection.getMinValue(props.domain.x),
y: Collection.getMinValue(props.domain.y)
};
var children = React.Children.toArray(props.children);
_classCallCheck(this, VoronoiHelpersClass);
var addMeta = function (data, name, child) {
var continuous = child && child.type && child.type.continuous;
var style = child ? child.props && child.props.style : props.style;
return data.map(function (datum, index) {
var _Helpers$getPoint = Helpers.getPoint(datum),
x = _Helpers$getPoint.x,
y = _Helpers$getPoint.y,
y0 = _Helpers$getPoint.y0,
x0 = _Helpers$getPoint.x0;
this.onMouseLeave = function (evt, targetProps) {
var _this$getParentMutati;
var voronoiX = (Number(x) + Number(x0)) / 2;
var voronoiY = (Number(y) + Number(y0)) / 2;
return _assign({
_voronoiX: props.voronoiDimension === "y" ? minDomain.x : voronoiX,
_voronoiY: props.voronoiDimension === "x" ? minDomain.y : voronoiY,
eventKey: index,
childName: name,
continuous: continuous,
style: style
}, datum);
});
};
var activePoints = targetProps.activePoints || [];
if (props.data) {
return addMeta(props.data);
}
_this.onDeactivated(targetProps, activePoints);
var getData = function (childProps) {
var data = Data.getData(childProps);
return Array.isArray(data) && data.length > 0 ? data : undefined;
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati = _this.getParentMutation([])).concat.apply(_this$getParentMutati, _toConsumableArray(inactiveMutations));
};
var iteratee = function (child, childName) {
var childProps = child.props || {};
var name = childProps.name || childName;
var blacklist = props.voronoiBlacklist || [];
var blacklistStr = blacklist.filter(_isString);
var blacklistRegExp = blacklist.filter(_isRegExp);
var isRegExpMatch = blacklistRegExp.some(function (regExp) {
return regExp.test(name);
});
this.handleMouseMove = function (evt, targetProps) {
// eslint-disable-line max-statements
var activePoints = targetProps.activePoints || [];
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt);
var mousePosition = Selection.getSVGEventCoordinates(evt, parentSVG);
if (!Data.isDataComponent(child) || _includes(blacklistStr, name) || isRegExpMatch) {
return null;
if (!_this.withinBounds(targetProps, mousePosition)) {
var _this$getParentMutati2;
_this.onDeactivated(targetProps, activePoints);
var _inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati2 = _this.getParentMutation([], mousePosition, parentSVG)).concat.apply(_this$getParentMutati2, _toConsumableArray(_inactiveMutations));
}
var getChildData = child.type && _isFunction(child.type.getData) ? child.type.getData : getData;
var childData = getChildData(child.props);
return childData ? addMeta(childData, name, child) : null;
var _this$getVoronoiPoint = _this.getVoronoiPoints(targetProps, mousePosition),
_this$getVoronoiPoint2 = _this$getVoronoiPoint.points,
points = _this$getVoronoiPoint2 === void 0 ? [] : _this$getVoronoiPoint2,
index = _this$getVoronoiPoint.index;
var parentMutations = _this.getParentMutation(points, mousePosition, parentSVG, index);
if (activePoints.length && isEqual(points, activePoints)) {
return parentMutations;
}
_this.onActivated(targetProps, points);
_this.onDeactivated(targetProps, activePoints);
var activeMutations = points.length ? points.map(function (point) {
return _this.getActiveMutations(targetProps, point);
}) : [];
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return parentMutations.concat.apply(parentMutations, _toConsumableArray(inactiveMutations).concat(_toConsumableArray(activeMutations)));
};
return Helpers.reduceChildren(children, iteratee, props);
},
findPoints: function (datasets, point) {
return datasets.filter(function (d) {
return point._voronoiX === d._voronoiX && point._voronoiY === d._voronoiY;
this.onMouseMove = _throttle(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, {
leading: true,
trailing: false
});
},
withinRadius: function (point, mousePosition, radius) {
if (!point) {
return false;
}
}
if (!radius) {
return true;
_createClass(VoronoiHelpersClass, [{
key: "withinBounds",
value: function withinBounds(props, point) {
var width = props.width,
height = props.height,
polar = props.polar,
origin = props.origin,
scale = props.scale;
var padding = Helpers.getPadding(props, "voronoiPadding");
var x = point.x,
y = point.y;
if (polar) {
var distanceSquared = Math.pow(x - origin.x, 2) + Math.pow(y - origin.y, 2);
var radius = Math.max.apply(Math, _toConsumableArray(scale.y.range()));
return distanceSquared < Math.pow(radius, 2);
}
return x >= padding.left && x <= width - padding.right && y >= padding.top && y <= height - padding.bottom;
}
}, {
key: "getDatasets",
value: function getDatasets(props) {
var minDomain = {
x: Collection.getMinValue(props.domain.x),
y: Collection.getMinValue(props.domain.y)
};
var children = React.Children.toArray(props.children);
var x = mousePosition.x,
y = mousePosition.y;
var distanceSquared = Math.pow(x - point[0], 2) + Math.pow(y - point[1], 2);
return distanceSquared < Math.pow(radius, 2);
},
getVoronoiPoints: function (props, mousePosition) {
var datasets = this.getDatasets(props);
var scaledData = datasets.map(function (d) {
var _Helpers$scalePoint = Helpers.scalePoint(props, d),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
var addMeta = function (data, name, child) {
var continuous = child && child.type && child.type.continuous;
var style = child ? child.props && child.props.style : props.style;
return data.map(function (datum, index) {
var _Helpers$getPoint = Helpers.getPoint(datum),
x = _Helpers$getPoint.x,
y = _Helpers$getPoint.y,
y0 = _Helpers$getPoint.y0,
x0 = _Helpers$getPoint.x0;
return [x, y];
});
var delaunay = Delaunay.from(scaledData);
var index = delaunay.find(mousePosition.x, mousePosition.y);
var withinRadius = this.withinRadius(scaledData[index], mousePosition, props.radius);
var points = withinRadius ? this.findPoints(datasets, datasets[index]) : [];
return {
points: points,
index: index
};
},
getActiveMutations: function (props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
var voronoiX = (Number(x) + Number(x0)) / 2;
var voronoiY = (Number(y) + Number(y0)) / 2;
return _assign({
_voronoiX: props.voronoiDimension === "y" ? minDomain.x : voronoiX,
_voronoiY: props.voronoiDimension === "x" ? minDomain.y : voronoiY,
eventKey: index,
childName: name,
continuous: continuous,
style: style
}, datum);
});
};
if (!activateData && !activateLabels) {
return [];
}
if (props.data) {
return addMeta(props.data);
}
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
var getData = function (childProps) {
var data = Data.getData(childProps);
return Array.isArray(data) && data.length > 0 ? data : undefined;
};
if (_isEmpty(targets)) {
return [];
}
var iteratee = function (child, childName) {
var childProps = child.props || {};
var name = childProps.name || childName;
var blacklist = props.voronoiBlacklist || [];
var blacklistStr = blacklist.filter(_isString);
var blacklistRegExp = blacklist.filter(_isRegExp);
var isRegExpMatch = blacklistRegExp.some(function (regExp) {
return regExp.test(name);
});
return targets.map(function (target) {
var eventKey = continuous === true && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return {
active: true
};
if (!Data.isDataComponent(child) || _includes(blacklistStr, name) || isRegExpMatch) {
return null;
}
var getChildData = child.type && _isFunction(child.type.getData) ? child.type.getData : getData;
var childData = getChildData(child.props);
return childData ? addMeta(childData, name, child) : null;
};
});
},
getInactiveMutations: function (props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
if (!activateData && !activateLabels) {
return [];
return Helpers.reduceChildren(children, iteratee, props);
}
}, {
key: "findPoints",
value: function findPoints(datasets, point) {
return datasets.filter(function (d) {
return point._voronoiX === d._voronoiX && point._voronoiY === d._voronoiY;
});
}
}, {
key: "withinRadius",
value: function withinRadius(point, mousePosition, radius) {
if (!point) {
return false;
}
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
if (!radius) {
return true;
}
if (_isEmpty(targets)) {
return [];
var x = mousePosition.x,
y = mousePosition.y;
var distanceSquared = Math.pow(x - point[0], 2) + Math.pow(y - point[1], 2);
return distanceSquared < Math.pow(radius, 2);
}
}, {
key: "getVoronoiPoints",
value: function getVoronoiPoints(props, mousePosition) {
var datasets = this.getDatasets(props);
var scaledData = datasets.map(function (d) {
var _Helpers$scalePoint = Helpers.scalePoint(props, d),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
return targets.map(function (target) {
var eventKey = continuous && target === "data" ? "all" : point.eventKey;
return [x, y];
});
var delaunay = Delaunay.from(scaledData);
var index = delaunay.find(mousePosition.x, mousePosition.y);
var withinRadius = this.withinRadius(scaledData[index], mousePosition, props.radius);
var points = withinRadius ? this.findPoints(datasets, datasets[index]) : [];
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return null;
}
points: points,
index: index
};
});
},
// eslint-disable-next-line max-params
getParentMutation: function (activePoints, mousePosition, parentSVG, vIndex) {
return [{
target: "parent",
eventKey: "parent",
mutation: function () {
return {
activePoints: activePoints,
mousePosition: mousePosition,
parentSVG: parentSVG,
vIndex: vIndex
};
}
}];
},
onActivated: function (props, points) {
if (_isFunction(props.onActivated)) {
props.onActivated(points, props);
}
},
onDeactivated: function (props, points) {
if (_isFunction(props.onDeactivated)) {
props.onDeactivated(points, props);
}
},
onMouseLeave: function (evt, targetProps) {
var _this = this,
_this$getParentMutati;
}, {
key: "getActiveMutations",
value: function getActiveMutations(props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
var activePoints = targetProps.activePoints || [];
this.onDeactivated(targetProps, activePoints);
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati = this.getParentMutation([])).concat.apply(_this$getParentMutati, _toConsumableArray(inactiveMutations));
},
onMouseMove: function (evt, targetProps) {
var _this2 = this;
if (!activateData && !activateLabels) {
return [];
}
// eslint-disable-line max-statements
var activePoints = targetProps.activePoints || [];
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt);
var mousePosition = Selection.getSVGEventCoordinates(evt, parentSVG);
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
if (!this.withinBounds(targetProps, mousePosition)) {
var _this$getParentMutati2;
if (_isEmpty(targets)) {
return [];
}
this.onDeactivated(targetProps, activePoints);
return targets.map(function (target) {
var eventKey = continuous === true && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return {
active: true
};
}
};
});
}
}, {
key: "getInactiveMutations",
value: function getInactiveMutations(props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
var _inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this2.getInactiveMutations(targetProps, point);
}) : [];
if (!activateData && !activateLabels) {
return [];
}
return (_this$getParentMutati2 = this.getParentMutation([], mousePosition, parentSVG)).concat.apply(_this$getParentMutati2, _toConsumableArray(_inactiveMutations));
}
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
var _this$getVoronoiPoint = this.getVoronoiPoints(targetProps, mousePosition),
_this$getVoronoiPoint2 = _this$getVoronoiPoint.points,
points = _this$getVoronoiPoint2 === void 0 ? [] : _this$getVoronoiPoint2,
index = _this$getVoronoiPoint.index;
if (_isEmpty(targets)) {
return [];
}
var parentMutations = this.getParentMutation(points, mousePosition, parentSVG, index);
return targets.map(function (target) {
var eventKey = continuous && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return null;
}
};
});
} // eslint-disable-next-line max-params
if (activePoints.length && isEqual(points, activePoints)) {
return parentMutations;
}, {
key: "getParentMutation",
value: function getParentMutation(activePoints, mousePosition, parentSVG, vIndex) {
return [{
target: "parent",
eventKey: "parent",
mutation: function () {
return {
activePoints: activePoints,
mousePosition: mousePosition,
parentSVG: parentSVG,
vIndex: vIndex
};
}
}];
}
}, {
key: "onActivated",
value: function onActivated(props, points) {
if (_isFunction(props.onActivated)) {
props.onActivated(points, props);
}
}
}, {
key: "onDeactivated",
value: function onDeactivated(props, points) {
if (_isFunction(props.onDeactivated)) {
props.onDeactivated(points, props);
}
}
}]);
this.onActivated(targetProps, points);
this.onDeactivated(targetProps, activePoints);
var activeMutations = points.length ? points.map(function (point) {
return _this2.getActiveMutations(targetProps, point);
}) : [];
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this2.getInactiveMutations(targetProps, point);
}) : [];
return parentMutations.concat.apply(parentMutations, _toConsumableArray(inactiveMutations).concat(_toConsumableArray(activeMutations)));
}
};
export default {
onMouseLeave: VoronoiHelpers.onMouseLeave.bind(VoronoiHelpers),
onMouseMove: _throttle(VoronoiHelpers.onMouseMove.bind(VoronoiHelpers), 32, // eslint-disable-line no-magic-numbers
{
leading: true,
trailing: false
})
};
return VoronoiHelpersClass;
}();
export var VoronoiHelpers = new VoronoiHelpersClass();

@@ -1,44 +0,3 @@

import * as React from "react";
import { PaddingProps, VictoryContainerProps } from "victory-core";
export interface VictoryVoronoiContainerProps extends VictoryContainerProps {
activateData?: boolean;
activateLabels?: boolean;
disable?: boolean;
labels?: (point: any, index: number, points: any[]) => string;
labelComponent?: React.ReactElement;
mouseFollowTooltips?: boolean;
onActivated?: (points: any[], props: VictoryVoronoiContainerProps) => void;
onDeactivated?: (points: any[], props: VictoryVoronoiContainerProps) => void;
radius?: number;
voronoiBlacklist?: (string | RegExp)[];
voronoiDimension?: "x" | "y";
voronoiPadding?: PaddingProps;
}
export class VictoryVoronoiContainer extends React.Component<
VictoryVoronoiContainerProps,
any
> {}
export const VoronoiHelpers: {
withinBounds(props: any, point: any): any;
getDatasets(props: any): any;
findPoints(datasets: any, point: any): any;
withinRadius(point: any, mousePosition: any, radius: any): any;
getVoronoiPoints(props: any, mousePosition: any): any;
getActiveMutations(props: any, point: any): any;
getInactiveMutations(props: any, point: any): any;
getParentMutation(
activePoints: any,
mousePosition: any,
parentSVG: any,
vIndex: any,
): any;
onActivated(props: any, points: any): any;
onDeactivated(props: any, points: any): any;
onMouseLeave(evt: any, targetProps: any): any;
onMouseMove(evt: any, targetProps: any): any;
};
export const voronoiContainerMixin: (base: Function) => Function;
export * from "./victory-voronoi-container";
export * from "./voronoi-helpers";
//# sourceMappingURL=index.d.ts.map

@@ -6,29 +6,27 @@ "use strict";

});
Object.defineProperty(exports, "VictoryVoronoiContainer", {
enumerable: true,
get: function () {
return _victoryVoronoiContainer.default;
}
});
Object.defineProperty(exports, "VoronoiHelpers", {
enumerable: true,
get: function () {
return _voronoiHelpers.default;
}
});
Object.defineProperty(exports, "voronoiContainerMixin", {
enumerable: true,
get: function () {
return _victoryVoronoiContainer.voronoiContainerMixin;
}
});
var _victoryVoronoiContainer = _interopRequireWildcard(require("./victory-voronoi-container"));
var _victoryVoronoiContainer = require("./victory-voronoi-container");
var _voronoiHelpers = _interopRequireDefault(require("./voronoi-helpers"));
Object.keys(_victoryVoronoiContainer).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _victoryVoronoiContainer[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _victoryVoronoiContainer[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _voronoiHelpers = require("./voronoi-helpers");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
Object.keys(_voronoiHelpers).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _voronoiHelpers[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _voronoiHelpers[key];
}
});
});

@@ -6,3 +6,4 @@ "use strict";

});
exports.voronoiContainerMixin = exports.default = void 0;
exports.VictoryVoronoiContainer = void 0;
exports.voronoiContainerMixin = voronoiContainerMixin;

@@ -15,4 +16,2 @@ var _pick2 = _interopRequireDefault(require("lodash/pick"));

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));

@@ -24,3 +23,3 @@

var _voronoiHelpers = _interopRequireDefault(require("./voronoi-helpers"));
var _voronoiHelpers = require("./voronoi-helpers");

@@ -73,7 +72,8 @@ var _excluded = ["childName", "eventKey", "style", "continuous"];

var voronoiContainerMixin = function (base) {
function voronoiContainerMixin(Base) {
var _class;
return _class = /*#__PURE__*/function (_base) {
_inherits(VictoryVoronoiContainer, _base);
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
return _class = /*#__PURE__*/function (_Base) {
_inherits(VictoryVoronoiContainer, _Base);

@@ -160,4 +160,3 @@ var _super = _createSuper(VictoryVoronoiContainer);

}) : [style];
memo = memo.concat(styleArray);
return memo;
return memo.concat(styleArray);
}, []);

@@ -205,4 +204,3 @@ }

memo = memo.concat("".concat(t).split("\n"));
return memo;
return memo.concat("".concat(t).split("\n"));
}, []); // remove properties from first point to make datum

@@ -267,21 +265,3 @@ // eslint-disable-next-line no-unused-vars

return VictoryVoronoiContainer;
}(base), _class.displayName = "VictoryVoronoiContainer", _class.propTypes = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.propTypes), {}, {
activateData: _propTypes.default.bool,
activateLabels: _propTypes.default.bool,
disable: _propTypes.default.bool,
labelComponent: _propTypes.default.element,
labels: _propTypes.default.func,
mouseFollowTooltips: _propTypes.default.bool,
onActivated: _propTypes.default.func,
onDeactivated: _propTypes.default.func,
radius: _propTypes.default.number,
voronoiBlacklist: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _victoryCore.PropTypes.regExp])),
voronoiDimension: _propTypes.default.oneOf(["x", "y"]),
voronoiPadding: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
top: _propTypes.default.number,
bottom: _propTypes.default.number,
left: _propTypes.default.number,
right: _propTypes.default.number
})])
}), _class.defaultProps = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.defaultProps), {}, {
}(Base), _class.displayName = "VictoryVoronoiContainer", _class.defaultProps = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.defaultProps), {}, {
activateData: true,

@@ -296,12 +276,12 @@ activateLabels: true,

onMouseLeave: function (evt, targetProps) {
return props.disable ? {} : _voronoiHelpers.default.onMouseLeave(evt, targetProps);
return props.disable ? {} : _voronoiHelpers.VoronoiHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: function (evt, targetProps) {
return props.disable ? {} : _voronoiHelpers.default.onMouseLeave(evt, targetProps);
return props.disable ? {} : _voronoiHelpers.VoronoiHelpers.onMouseLeave(evt, targetProps);
},
onMouseMove: function (evt, targetProps) {
return props.disable ? {} : _voronoiHelpers.default.onMouseMove(evt, targetProps);
return props.disable ? {} : _voronoiHelpers.VoronoiHelpers.onMouseMove(evt, targetProps);
},
onTouchMove: function (evt, targetProps) {
return props.disable ? {} : _voronoiHelpers.default.onMouseMove(evt, targetProps);
return props.disable ? {} : _voronoiHelpers.VoronoiHelpers.onMouseMove(evt, targetProps);
}

@@ -324,11 +304,5 @@ }

}, _class;
};
}
exports.voronoiContainerMixin = voronoiContainerMixin;
var _default = voronoiContainerMixin(_victoryCore.VictoryContainer); // @ts-expect-error IMPORTANT: when converting this file to TypeScript, you must export the type as well:
// export const VictoryVoronoiContainer = voronoiContainerMixin(VictoryContainer);
// export type VictoryVoronoiContainer = typeof VictoryVoronoiContainer;
exports.default = _default;
var VictoryVoronoiContainer = voronoiContainerMixin(_victoryCore.VictoryContainer);
exports.VictoryVoronoiContainer = VictoryVoronoiContainer;

@@ -6,4 +6,6 @@ "use strict";

});
exports.default = void 0;
exports.VoronoiHelpers = void 0;
var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
var _isRegExp2 = _interopRequireDefault(require("lodash/isRegExp"));

@@ -19,4 +21,2 @@

var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
var _assign2 = _interopRequireDefault(require("lodash/assign"));

@@ -46,274 +46,313 @@

var VoronoiHelpers = {
withinBounds: function (props, point) {
var width = props.width,
height = props.height,
polar = props.polar,
origin = props.origin,
scale = props.scale;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var padding = _victoryCore.Helpers.getPadding(props, "voronoiPadding");
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
var x = point.x,
y = point.y;
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
if (polar) {
var distanceSquared = Math.pow(x - origin.x, 2) + Math.pow(y - origin.y, 2);
var radius = Math.max.apply(Math, _toConsumableArray(scale.y.range()));
return distanceSquared < Math.pow(radius, 2);
}
var ON_MOUSE_MOVE_THROTTLE_MS = 32;
return x >= padding.left && x <= width - padding.right && y >= padding.top && y <= height - padding.bottom;
},
getDatasets: function (props) {
var minDomain = {
x: _victoryCore.Collection.getMinValue(props.domain.x),
y: _victoryCore.Collection.getMinValue(props.domain.y)
};
var VoronoiHelpersClass = /*#__PURE__*/function () {
function VoronoiHelpersClass() {
var _this = this;
var children = _react.default.Children.toArray(props.children);
_classCallCheck(this, VoronoiHelpersClass);
var addMeta = function (data, name, child) {
var continuous = child && child.type && child.type.continuous;
var style = child ? child.props && child.props.style : props.style;
return data.map(function (datum, index) {
var _Helpers$getPoint = _victoryCore.Helpers.getPoint(datum),
x = _Helpers$getPoint.x,
y = _Helpers$getPoint.y,
y0 = _Helpers$getPoint.y0,
x0 = _Helpers$getPoint.x0;
this.onMouseLeave = function (evt, targetProps) {
var _this$getParentMutati;
var voronoiX = (Number(x) + Number(x0)) / 2;
var voronoiY = (Number(y) + Number(y0)) / 2;
return (0, _assign2.default)({
_voronoiX: props.voronoiDimension === "y" ? minDomain.x : voronoiX,
_voronoiY: props.voronoiDimension === "x" ? minDomain.y : voronoiY,
eventKey: index,
childName: name,
continuous: continuous,
style: style
}, datum);
});
var activePoints = targetProps.activePoints || [];
_this.onDeactivated(targetProps, activePoints);
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati = _this.getParentMutation([])).concat.apply(_this$getParentMutati, _toConsumableArray(inactiveMutations));
};
if (props.data) {
return addMeta(props.data);
}
this.handleMouseMove = function (evt, targetProps) {
// eslint-disable-line max-statements
var activePoints = targetProps.activePoints || [];
var getData = function (childProps) {
var data = _victoryCore.Data.getData(childProps);
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt);
return Array.isArray(data) && data.length > 0 ? data : undefined;
};
var mousePosition = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG);
var iteratee = function (child, childName) {
var childProps = child.props || {};
var name = childProps.name || childName;
var blacklist = props.voronoiBlacklist || [];
var blacklistStr = blacklist.filter(_isString2.default);
var blacklistRegExp = blacklist.filter(_isRegExp2.default);
var isRegExpMatch = blacklistRegExp.some(function (regExp) {
return regExp.test(name);
});
if (!_this.withinBounds(targetProps, mousePosition)) {
var _this$getParentMutati2;
if (!_victoryCore.Data.isDataComponent(child) || (0, _includes2.default)(blacklistStr, name) || isRegExpMatch) {
return null;
_this.onDeactivated(targetProps, activePoints);
var _inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati2 = _this.getParentMutation([], mousePosition, parentSVG)).concat.apply(_this$getParentMutati2, _toConsumableArray(_inactiveMutations));
}
var getChildData = child.type && (0, _isFunction2.default)(child.type.getData) ? child.type.getData : getData;
var childData = getChildData(child.props);
return childData ? addMeta(childData, name, child) : null;
};
var _this$getVoronoiPoint = _this.getVoronoiPoints(targetProps, mousePosition),
_this$getVoronoiPoint2 = _this$getVoronoiPoint.points,
points = _this$getVoronoiPoint2 === void 0 ? [] : _this$getVoronoiPoint2,
index = _this$getVoronoiPoint.index;
return _victoryCore.Helpers.reduceChildren(children, iteratee, props);
},
findPoints: function (datasets, point) {
return datasets.filter(function (d) {
return point._voronoiX === d._voronoiX && point._voronoiY === d._voronoiY;
});
},
withinRadius: function (point, mousePosition, radius) {
if (!point) {
return false;
}
var parentMutations = _this.getParentMutation(points, mousePosition, parentSVG, index);
if (!radius) {
return true;
}
if (activePoints.length && (0, _reactFastCompare.default)(points, activePoints)) {
return parentMutations;
}
var x = mousePosition.x,
y = mousePosition.y;
var distanceSquared = Math.pow(x - point[0], 2) + Math.pow(y - point[1], 2);
return distanceSquared < Math.pow(radius, 2);
},
getVoronoiPoints: function (props, mousePosition) {
var datasets = this.getDatasets(props);
var scaledData = datasets.map(function (d) {
var _Helpers$scalePoint = _victoryCore.Helpers.scalePoint(props, d),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
_this.onActivated(targetProps, points);
return [x, y];
_this.onDeactivated(targetProps, activePoints);
var activeMutations = points.length ? points.map(function (point) {
return _this.getActiveMutations(targetProps, point);
}) : [];
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return parentMutations.concat.apply(parentMutations, _toConsumableArray(inactiveMutations).concat(_toConsumableArray(activeMutations)));
};
this.onMouseMove = (0, _throttle2.default)(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, {
leading: true,
trailing: false
});
}
var delaunay = _index.default.from(scaledData);
_createClass(VoronoiHelpersClass, [{
key: "withinBounds",
value: function withinBounds(props, point) {
var width = props.width,
height = props.height,
polar = props.polar,
origin = props.origin,
scale = props.scale;
var index = delaunay.find(mousePosition.x, mousePosition.y);
var withinRadius = this.withinRadius(scaledData[index], mousePosition, props.radius);
var points = withinRadius ? this.findPoints(datasets, datasets[index]) : [];
return {
points: points,
index: index
};
},
getActiveMutations: function (props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
var padding = _victoryCore.Helpers.getPadding(props, "voronoiPadding");
if (!activateData && !activateLabels) {
return [];
}
var x = point.x,
y = point.y;
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
if (polar) {
var distanceSquared = Math.pow(x - origin.x, 2) + Math.pow(y - origin.y, 2);
var radius = Math.max.apply(Math, _toConsumableArray(scale.y.range()));
return distanceSquared < Math.pow(radius, 2);
}
if ((0, _isEmpty2.default)(targets)) {
return [];
return x >= padding.left && x <= width - padding.right && y >= padding.top && y <= height - padding.bottom;
}
}, {
key: "getDatasets",
value: function getDatasets(props) {
var minDomain = {
x: _victoryCore.Collection.getMinValue(props.domain.x),
y: _victoryCore.Collection.getMinValue(props.domain.y)
};
return targets.map(function (target) {
var eventKey = continuous === true && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return {
active: true
};
}
var children = _react.default.Children.toArray(props.children);
var addMeta = function (data, name, child) {
var continuous = child && child.type && child.type.continuous;
var style = child ? child.props && child.props.style : props.style;
return data.map(function (datum, index) {
var _Helpers$getPoint = _victoryCore.Helpers.getPoint(datum),
x = _Helpers$getPoint.x,
y = _Helpers$getPoint.y,
y0 = _Helpers$getPoint.y0,
x0 = _Helpers$getPoint.x0;
var voronoiX = (Number(x) + Number(x0)) / 2;
var voronoiY = (Number(y) + Number(y0)) / 2;
return (0, _assign2.default)({
_voronoiX: props.voronoiDimension === "y" ? minDomain.x : voronoiX,
_voronoiY: props.voronoiDimension === "x" ? minDomain.y : voronoiY,
eventKey: index,
childName: name,
continuous: continuous,
style: style
}, datum);
});
};
});
},
getInactiveMutations: function (props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
if (!activateData && !activateLabels) {
return [];
}
if (props.data) {
return addMeta(props.data);
}
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
var getData = function (childProps) {
var data = _victoryCore.Data.getData(childProps);
if ((0, _isEmpty2.default)(targets)) {
return [];
}
return Array.isArray(data) && data.length > 0 ? data : undefined;
};
return targets.map(function (target) {
var eventKey = continuous && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
var iteratee = function (child, childName) {
var childProps = child.props || {};
var name = childProps.name || childName;
var blacklist = props.voronoiBlacklist || [];
var blacklistStr = blacklist.filter(_isString2.default);
var blacklistRegExp = blacklist.filter(_isRegExp2.default);
var isRegExpMatch = blacklistRegExp.some(function (regExp) {
return regExp.test(name);
});
if (!_victoryCore.Data.isDataComponent(child) || (0, _includes2.default)(blacklistStr, name) || isRegExpMatch) {
return null;
}
var getChildData = child.type && (0, _isFunction2.default)(child.type.getData) ? child.type.getData : getData;
var childData = getChildData(child.props);
return childData ? addMeta(childData, name, child) : null;
};
});
},
// eslint-disable-next-line max-params
getParentMutation: function (activePoints, mousePosition, parentSVG, vIndex) {
return [{
target: "parent",
eventKey: "parent",
mutation: function () {
return {
activePoints: activePoints,
mousePosition: mousePosition,
parentSVG: parentSVG,
vIndex: vIndex
};
}
}];
},
onActivated: function (props, points) {
if ((0, _isFunction2.default)(props.onActivated)) {
props.onActivated(points, props);
return _victoryCore.Helpers.reduceChildren(children, iteratee, props);
}
},
onDeactivated: function (props, points) {
if ((0, _isFunction2.default)(props.onDeactivated)) {
props.onDeactivated(points, props);
}, {
key: "findPoints",
value: function findPoints(datasets, point) {
return datasets.filter(function (d) {
return point._voronoiX === d._voronoiX && point._voronoiY === d._voronoiY;
});
}
},
onMouseLeave: function (evt, targetProps) {
var _this = this,
_this$getParentMutati;
}, {
key: "withinRadius",
value: function withinRadius(point, mousePosition, radius) {
if (!point) {
return false;
}
var activePoints = targetProps.activePoints || [];
this.onDeactivated(targetProps, activePoints);
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this.getInactiveMutations(targetProps, point);
}) : [];
return (_this$getParentMutati = this.getParentMutation([])).concat.apply(_this$getParentMutati, _toConsumableArray(inactiveMutations));
},
onMouseMove: function (evt, targetProps) {
var _this2 = this;
if (!radius) {
return true;
}
// eslint-disable-line max-statements
var activePoints = targetProps.activePoints || [];
var x = mousePosition.x,
y = mousePosition.y;
var distanceSquared = Math.pow(x - point[0], 2) + Math.pow(y - point[1], 2);
return distanceSquared < Math.pow(radius, 2);
}
}, {
key: "getVoronoiPoints",
value: function getVoronoiPoints(props, mousePosition) {
var datasets = this.getDatasets(props);
var scaledData = datasets.map(function (d) {
var _Helpers$scalePoint = _victoryCore.Helpers.scalePoint(props, d),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt);
return [x, y];
});
var mousePosition = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG);
var delaunay = _index.default.from(scaledData);
if (!this.withinBounds(targetProps, mousePosition)) {
var _this$getParentMutati2;
var index = delaunay.find(mousePosition.x, mousePosition.y);
var withinRadius = this.withinRadius(scaledData[index], mousePosition, props.radius);
var points = withinRadius ? this.findPoints(datasets, datasets[index]) : [];
return {
points: points,
index: index
};
}
}, {
key: "getActiveMutations",
value: function getActiveMutations(props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
this.onDeactivated(targetProps, activePoints);
if (!activateData && !activateLabels) {
return [];
}
var _inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this2.getInactiveMutations(targetProps, point);
}) : [];
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
return (_this$getParentMutati2 = this.getParentMutation([], mousePosition, parentSVG)).concat.apply(_this$getParentMutati2, _toConsumableArray(_inactiveMutations));
if ((0, _isEmpty2.default)(targets)) {
return [];
}
return targets.map(function (target) {
var eventKey = continuous === true && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return {
active: true
};
}
};
});
}
}, {
key: "getInactiveMutations",
value: function getInactiveMutations(props, point) {
var childName = point.childName,
continuous = point.continuous;
var activateData = props.activateData,
activateLabels = props.activateLabels,
labels = props.labels;
var _this$getVoronoiPoint = this.getVoronoiPoints(targetProps, mousePosition),
_this$getVoronoiPoint2 = _this$getVoronoiPoint.points,
points = _this$getVoronoiPoint2 === void 0 ? [] : _this$getVoronoiPoint2,
index = _this$getVoronoiPoint.index;
if (!activateData && !activateLabels) {
return [];
}
var parentMutations = this.getParentMutation(points, mousePosition, parentSVG, index);
var defaultTarget = activateData ? ["data"] : [];
var targets = labels && !activateLabels ? defaultTarget : defaultTarget.concat("labels");
if (activePoints.length && (0, _reactFastCompare.default)(points, activePoints)) {
return parentMutations;
if ((0, _isEmpty2.default)(targets)) {
return [];
}
return targets.map(function (target) {
var eventKey = continuous && target === "data" ? "all" : point.eventKey;
return {
childName: childName,
eventKey: eventKey,
target: target,
mutation: function () {
return null;
}
};
});
} // eslint-disable-next-line max-params
}, {
key: "getParentMutation",
value: function getParentMutation(activePoints, mousePosition, parentSVG, vIndex) {
return [{
target: "parent",
eventKey: "parent",
mutation: function () {
return {
activePoints: activePoints,
mousePosition: mousePosition,
parentSVG: parentSVG,
vIndex: vIndex
};
}
}];
}
}, {
key: "onActivated",
value: function onActivated(props, points) {
if ((0, _isFunction2.default)(props.onActivated)) {
props.onActivated(points, props);
}
}
}, {
key: "onDeactivated",
value: function onDeactivated(props, points) {
if ((0, _isFunction2.default)(props.onDeactivated)) {
props.onDeactivated(points, props);
}
}
}]);
this.onActivated(targetProps, points);
this.onDeactivated(targetProps, activePoints);
var activeMutations = points.length ? points.map(function (point) {
return _this2.getActiveMutations(targetProps, point);
}) : [];
var inactiveMutations = activePoints.length ? activePoints.map(function (point) {
return _this2.getInactiveMutations(targetProps, point);
}) : [];
return parentMutations.concat.apply(parentMutations, _toConsumableArray(inactiveMutations).concat(_toConsumableArray(activeMutations)));
}
};
var _default = {
onMouseLeave: VoronoiHelpers.onMouseLeave.bind(VoronoiHelpers),
onMouseMove: (0, _throttle2.default)(VoronoiHelpers.onMouseMove.bind(VoronoiHelpers), 32, // eslint-disable-line no-magic-numbers
{
leading: true,
trailing: false
})
};
exports.default = _default;
return VoronoiHelpersClass;
}();
var VoronoiHelpers = new VoronoiHelpersClass();
exports.VoronoiHelpers = VoronoiHelpers;
{
"name": "victory-voronoi-container",
"version": "36.8.2",
"version": "36.8.3",
"description": "Interactive Voronoi Mouseover Component for Victory",

@@ -27,4 +27,4 @@ "keywords": [

"react-fast-compare": "^3.2.0",
"victory-core": "^36.8.2",
"victory-tooltip": "^36.8.2"
"victory-core": "^36.8.3",
"victory-tooltip": "^36.8.3"
},

@@ -31,0 +31,0 @@ "peerDependencies": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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