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

victory-core

Package Overview
Dependencies
Maintainers
8
Versions
308
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-core - npm Package Compare versions

Comparing version 35.9.3 to 35.10.0

2

es/index.d.ts

@@ -919,2 +919,4 @@ import * as React from "react";

desc?: string;
rx?: number;
ry?: number;
}

@@ -921,0 +923,0 @@

54

es/index.js

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

// This rule doesn't play well with namespaced exports
/* eslint-disable import/export */
export { default as VictoryAccessibleGroup } from "./victory-accessible-group/victory-accessible-group";

@@ -24,22 +27,39 @@ export { default as VictoryAnimation } from "./victory-animation/victory-animation";

export { default as addEvents } from "./victory-util/add-events";
export { default as Collection } from "./victory-util/collection";
export { default as Data } from "./victory-util/data";
export { default as DefaultTransitions } from "./victory-util/default-transitions";
export { default as Domain } from "./victory-util/domain";
export { default as Events } from "./victory-util/events";
export { default as Helpers } from "./victory-util/helpers";
export { default as Immutable } from "./victory-util/immutable";
export { default as LabelHelpers } from "./victory-util/label-helpers";
export { default as Log } from "./victory-util/log";
export { default as PropTypes } from "./victory-util/prop-types";
export { default as Scale } from "./victory-util/scale";
export { default as Selection } from "./victory-util/selection";
export { default as Style } from "./victory-util/style";
export { default as TextSize } from "./victory-util/textsize";
import * as _Collection from "./victory-util/collection";
export { _Collection as Collection };
import * as _Data from "./victory-util/data";
export { _Data as Data };
import * as _DefaultTransitions from "./victory-util/default-transitions";
export { _DefaultTransitions as DefaultTransitions };
import * as _Domain from "./victory-util/domain";
export { _Domain as Domain };
import * as _Events from "./victory-util/events";
export { _Events as Events };
import * as _Helpers from "./victory-util/helpers";
export { _Helpers as Helpers };
import * as _Immutable from "./victory-util/immutable";
export { _Immutable as Immutable };
import * as _LabelHelpers from "./victory-util/label-helpers";
export { _LabelHelpers as LabelHelpers };
import * as _Log from "./victory-util/log";
export { _Log as Log };
import * as _PropTypes from "./victory-util/prop-types";
export { _PropTypes as PropTypes };
import * as _Scale from "./victory-util/scale";
export { _Scale as Scale };
import * as _Selection from "./victory-util/selection";
export { _Selection as Selection };
import * as _Style from "./victory-util/style";
export { _Style as Style };
import * as _TextSize from "./victory-util/textsize";
export { _TextSize as TextSize };
export { default as Timer } from "./victory-util/timer";
export { default as Transitions } from "./victory-util/transitions";
export { default as CommonProps } from "./victory-util/common-props";
import * as _Transitions from "./victory-util/transitions";
export { _Transitions as Transitions };
import * as _CommonProps from "./victory-util/common-props";
export { _CommonProps as CommonProps };
export { default as Wrapper } from "./victory-util/wrapper";
export { default as Axis } from "./victory-util/axis";
import * as _Axis from "./victory-util/axis";
export { _Axis as Axis };
export { default as TimerContext } from "./victory-util/timer-context";
export { default as PortalContext } from "./victory-portal/portal-context";

@@ -32,4 +32,4 @@ import _uniqueId from "lodash/uniqueId";

import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import Helpers from "../victory-util/helpers";
import * as CustomPropTypes from "../victory-util/prop-types";
import * as Helpers from "../victory-util/helpers";
import ClipPath from "../victory-primitives/clip-path";

@@ -36,0 +36,0 @@ import Circle from "../victory-primitives/circle";

@@ -27,7 +27,7 @@ import _isFunction from "lodash/isFunction";

import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import * as CustomPropTypes from "../victory-util/prop-types";
import Portal from "../victory-portal/portal";
import PortalContext from "../victory-portal/portal-context";
import TimerContext from "../victory-util/timer-context";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";

@@ -34,0 +34,0 @@ var VictoryContainer =

@@ -22,8 +22,8 @@ import _isEmpty from "lodash/isEmpty";

import Rect from "../victory-primitives/rect";
import CustomPropTypes from "../victory-util/prop-types";
import Helpers from "../victory-util/helpers";
import LabelHelpers from "../victory-util/label-helpers";
import Style from "../victory-util/style";
import Log from "../victory-util/log";
import TextSize from "../victory-util/textsize";
import * as CustomPropTypes from "../victory-util/prop-types";
import * as Helpers from "../victory-util/helpers";
import * as LabelHelpers from "../victory-util/label-helpers";
import * as Style from "../victory-util/style";
import * as Log from "../victory-util/log";
import * as TextSize from "../victory-util/textsize";
import TSpan from "../victory-primitives/tspan";

@@ -30,0 +30,0 @@ import Text from "../victory-primitives/text";

@@ -17,3 +17,3 @@ import _keys from "lodash/keys";

import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import * as CustomPropTypes from "../victory-util/prop-types";

@@ -20,0 +20,0 @@ var Portal =

@@ -17,4 +17,4 @@ import _defaults from "lodash/defaults";

import PropTypes from "prop-types";
import Log from "../victory-util/log";
import Helpers from "../victory-util/helpers";
import * as Log from "../victory-util/log";
import * as Helpers from "../victory-util/helpers";
import PortalContext from "./portal-context";

@@ -21,0 +21,0 @@

@@ -10,4 +10,4 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Path from "./path";

@@ -14,0 +14,0 @@

@@ -9,4 +9,4 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Rect from "./rect";

@@ -13,0 +13,0 @@ import Circle from "./circle";

@@ -9,4 +9,4 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Rect from "./rect";

@@ -13,0 +13,0 @@

@@ -9,4 +9,4 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Line from "./line";

@@ -13,0 +13,0 @@

@@ -9,5 +9,5 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";
import pathHelpers from "./path-helpers";
import CommonProps from "../victory-util/common-props";
import * as CommonProps from "../victory-util/common-props";
import Path from "./path";

@@ -14,0 +14,0 @@

@@ -9,4 +9,4 @@ import _assign from "lodash/assign";

import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Line from "./line";

@@ -13,0 +13,0 @@

@@ -23,6 +23,6 @@ import _isObject from "lodash/isObject";

import VictoryAnimation from "../victory-animation/victory-animation";
import Collection from "../victory-util/collection";
import Helpers from "../victory-util/helpers";
import * as Collection from "../victory-util/collection";
import * as Helpers from "../victory-util/helpers";
import TimerContext from "../victory-util/timer-context";
import Transitions from "../victory-util/transitions";
import * as Transitions from "../victory-util/transitions";
import isEqual from "react-fast-compare";

@@ -29,0 +29,0 @@

@@ -33,3 +33,3 @@ import _difference from "lodash/difference";

import React from "react";
import Events from "./events";
import * as Events from "./events";
import isEqual from "react-fast-compare";

@@ -36,0 +36,0 @@ import VictoryTransition from "../victory-transition/victory-transition";

@@ -24,5 +24,5 @@ import _without from "lodash/without";

import React from "react";
import Collection from "./collection";
import Domain from "./domain";
import Helpers from "./helpers";
import * as Collection from "./collection";
import * as Domain from "./domain";
import * as Helpers from "./helpers";
/**

@@ -35,3 +35,3 @@ * Returns the axis (x or y) of a particular axis component

function getAxis(props) {
export function getAxis(props) {
var dependentAxis = props.dependentAxis;

@@ -47,4 +47,3 @@ return dependentAxis ? "y" : "x";

function findAxisComponents(childComponents, predicate) {
export function findAxisComponents(childComponents, predicate) {
predicate = predicate || _identity;

@@ -73,4 +72,3 @@

function getAxisComponent(childComponents, axis) {
export function getAxisComponent(childComponents, axis) {
var matchesAxis = function (component) {

@@ -91,4 +89,3 @@ var type = component.type.getAxis(component.props);

function getAxisComponentsWithParent(childComponents, type) {
export function getAxisComponentsWithParent(childComponents, type) {
var matchesType = function (child) {

@@ -113,4 +110,3 @@ return type === "dependent" ? child.props.dependentAxis : !child.props.dependentAxis;

}
function getOrigin(domain) {
export function getOrigin(domain) {
var getSingleOrigin = function (d) {

@@ -127,4 +123,3 @@ var domainMin = Math.min.apply(Math, _toConsumableArray(d));

}
function getOriginSign(origin, domain) {
export function getOriginSign(origin, domain) {
var getSign = function () {

@@ -141,4 +136,3 @@ return origin <= 0 && Math.max.apply(Math, _toConsumableArray(domain)) <= 0 ? "negative" : "positive";

function isVertical(props) {
export function isVertical(props) {
var orientation = props.orientation || (props.dependentAxis ? "left" : "bottom");

@@ -158,4 +152,3 @@ var vertical = {

function stringTicks(props) {
export function stringTicks(props) {
return props.tickValues !== undefined && Collection.containsStrings(props.tickValues);

@@ -264,3 +257,3 @@ }

function getTickFormat(props, scale) {
export function getTickFormat(props, scale) {
var tickFormat = props.tickFormat;

@@ -316,3 +309,3 @@ var axis = getAxis(props);

function getTicks(props, scale, filterZero) {
export function getTicks(props, scale, filterZero) {
var tickCount = props.tickCount;

@@ -351,3 +344,2 @@ var tickArray = getTickArray(props);

function getDomainFromData(props, axis) {

@@ -389,3 +381,3 @@ var polar = props.polar,

function getDomain(props, axis) {
export function getDomain(props, axis) {
var inherentAxis = getAxis(props);

@@ -399,4 +391,3 @@

}
function getAxisValue(props, axis) {
export function getAxisValue(props, axis) {
if (!props.axisValue) {

@@ -418,4 +409,3 @@ return undefined;

}
function modifyProps(props, fallbackProps) {
export function modifyProps(props, fallbackProps) {
if (!_isObject(props.theme)) {

@@ -446,18 +436,2 @@ return Helpers.modifyProps(props, fallbackProps, "axis");

}), fallbackProps, "axis");
}
export default {
getTicks: getTicks,
getTickFormat: getTickFormat,
getAxis: getAxis,
getAxisComponent: getAxisComponent,
getAxisComponentsWithParent: getAxisComponentsWithParent,
getAxisValue: getAxisValue,
findAxisComponents: findAxisComponents,
getOrigin: getOrigin,
getOriginSign: getOriginSign,
getDomain: getDomain,
isVertical: isVertical,
modifyProps: modifyProps,
stringTicks: stringTicks
};
}

@@ -16,3 +16,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function containsStrings(collection) {
export function containsStrings(collection) {
return Array.isArray(collection) && collection.some(function (value) {

@@ -22,4 +22,3 @@ return typeof value === "string";

}
function containsDates(collection) {
export function containsDates(collection) {
return Array.isArray(collection) && collection.some(function (value) {

@@ -29,4 +28,3 @@ return value instanceof Date;

}
function containsNumbers(collection) {
export function containsNumbers(collection) {
return Array.isArray(collection) && collection.some(function (value) {

@@ -36,4 +34,3 @@ return typeof value === "number";

}
function containsOnlyStrings(collection) {
export function containsOnlyStrings(collection) {
return isNonEmptyArray(collection) && collection.every(function (value) {

@@ -43,8 +40,6 @@ return typeof value === "string";

}
function isArrayOfArrays(collection) {
export function isArrayOfArrays(collection) {
return isNonEmptyArray(collection) && collection.every(Array.isArray);
}
function removeUndefined(arr) {
export function removeUndefined(arr) {
return arr.filter(function (el) {

@@ -54,4 +49,3 @@ return el !== undefined;

}
function getMaxValue(arr) {
export function getMaxValue(arr) {
for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

@@ -64,4 +58,3 @@ values[_key - 1] = arguments[_key];

}
function getMinValue(arr) {
export function getMinValue(arr) {
for (var _len2 = arguments.length, values = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

@@ -73,13 +66,2 @@ values[_key2 - 1] = arguments[_key2];

return containsDates(array) ? new Date(Math.min.apply(Math, _toConsumableArray(array))) : Math.min.apply(Math, _toConsumableArray(array));
}
export default {
containsDates: containsDates,
containsNumbers: containsNumbers,
containsOnlyStrings: containsOnlyStrings,
containsStrings: containsStrings,
getMaxValue: getMaxValue,
getMinValue: getMinValue,
isArrayOfArrays: isArrayOfArrays,
removeUndefined: removeUndefined
};
}
import PropTypes from "prop-types";
import CustomPropTypes from "./prop-types";
var dataProps = {
import * as CustomPropTypes from "./prop-types";
export var dataProps = {
categories: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.shape({

@@ -25,3 +25,3 @@ x: PropTypes.arrayOf(PropTypes.string),

};
var baseProps = {
export var baseProps = {
animate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

@@ -92,3 +92,3 @@ containerComponent: PropTypes.element,

};
var primitiveProps = {
export var primitiveProps = {
active: PropTypes.bool,

@@ -118,7 +118,2 @@ ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),

transform: PropTypes.string
};
export default {
baseProps: baseProps,
dataProps: dataProps,
primitiveProps: primitiveProps
};

@@ -27,6 +27,6 @@ import _omitBy from "lodash/omitBy";

import React from "react";
import Helpers from "./helpers";
import Collection from "./collection";
import Scale from "./scale";
import Immutable from "./immutable"; // Private Functions
import * as Helpers from "./helpers";
import * as Collection from "./collection";
import * as Scale from "./scale";
import * as Immutable from "./immutable"; // Private Functions

@@ -113,6 +113,41 @@ function parseDatum(datum) {

});
} // This method will remove data points that fall outside of the desired domain (non-continuous charts only)
} // Returns a data accessor given an eventKey prop
function formatDataFromDomain(dataset, domain, defaultBaseline) {
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if (_isFunction(key)) {
return key;
} else if (key === null || key === undefined) {
return function () {
return undefined;
};
} // otherwise, assume it is an array index, property key or path (_.property handles all three)
return _property(key);
} // Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
var hasEventKeyAccessor = !!props.eventKey;
var eventKeyAccessor = getEventKey(props.eventKey);
return data.map(function (datum, index) {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
var eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? _assign({
eventKey: eventKey
}, datum) : datum;
} else {
return datum;
}
});
} // Exported Functions
// This method will remove data points that fall outside of the desired domain (non-continuous charts only)
export function formatDataFromDomain(dataset, domain, defaultBaseline) {
var exists = function (val) {

@@ -169,38 +204,3 @@ return val !== undefined;

});
} // Returns a data accessor given an eventKey prop
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if (_isFunction(key)) {
return key;
} else if (key === null || key === undefined) {
return function () {
return undefined;
};
} // otherwise, assume it is an array index, property key or path (_.property handles all three)
return _property(key);
} // Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
var hasEventKeyAccessor = !!props.eventKey;
var eventKeyAccessor = getEventKey(props.eventKey);
return data.map(function (datum, index) {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
var eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? _assign({
eventKey: eventKey
}, datum) : datum;
} else {
return datum;
}
});
} // Exported Functions
}
/**

@@ -213,4 +213,3 @@ * Returns an object mapping string data to numeric data

function createStringMap(props, axis) {
export function createStringMap(props, axis) {
var stringsFromAxes = getStringsFromAxes(props, axis);

@@ -236,4 +235,3 @@ var stringsFromCategories = getStringsFromCategories(props, axis);

function downsample(data, maxPoints) {
export function downsample(data, maxPoints) {
var startingIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;

@@ -263,4 +261,3 @@ // ensures that the downampling of data while zooming looks good.

function formatData(dataset, props, expectedKeys) {
export function formatData(dataset, props, expectedKeys) {
var isArrayOrIterable = Array.isArray(dataset) || Immutable.isIterable(dataset);

@@ -336,4 +333,3 @@

function generateData(props) {
export function generateData(props) {
var xValues = generateDataArray(props, "x");

@@ -356,4 +352,3 @@ var yValues = generateDataArray(props, "y");

function getCategories(props, axis) {
export function getCategories(props, axis) {
return props.categories && !Array.isArray(props.categories) ? props.categories[axis] : props.categories;

@@ -367,4 +362,3 @@ }

function getData(props) {
export function getData(props) {
return props.data ? formatData(props.data, props) : formatData(generateData(props), props);

@@ -379,4 +373,3 @@ }

function getStringsFromAxes(props, axis) {
export function getStringsFromAxes(props, axis) {
var tickValues = props.tickValues,

@@ -403,4 +396,3 @@ tickFormat = props.tickFormat;

function getStringsFromCategories(props, axis) {
export function getStringsFromCategories(props, axis) {
if (!props.categories) {

@@ -423,4 +415,3 @@ return [];

function getStringsFromData(props, axis) {
export function getStringsFromData(props, axis) {
var isArrayOrIterable = Array.isArray(props.data) || Immutable.isIterable(props.data);

@@ -462,4 +453,3 @@

function isDataComponent(component) {
export function isDataComponent(component) {
var getRole = function (child) {

@@ -478,16 +468,2 @@ return child && child.type ? child.type.role : "";

return _includes(whitelist, role);
}
export default {
createStringMap: createStringMap,
downsample: downsample,
formatData: formatData,
formatDataFromDomain: formatDataFromDomain,
generateData: generateData,
getCategories: getCategories,
getData: getData,
getStringsFromAxes: getStringsFromAxes,
getStringsFromCategories: getStringsFromCategories,
getStringsFromData: getStringsFromData,
isDataComponent: isDataComponent
};
}
/* eslint-disable func-style */
export default {
continuousTransitions: function () {
return {
onLoad: {
duration: 2000
export function continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
}
};
}
export function continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: function () {
return {
_y: 0,
_y1: 0,
_y0: 0
};
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
after: function (datum) {
return {
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
};
},
continuousPolarTransitions: function () {
return {
onLoad: {
duration: 2000,
before: function () {
return {
_y: 0,
_y1: 0,
_y0: 0
};
},
after: function (datum) {
return {
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
},
onExit: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
},
onExit: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
},
onEnter: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
onEnter: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
after: function (datum) {
return {
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
after: function (datum) {
return {
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
};
},
discreteTransitions: function () {
return {
onLoad: {
duration: 2000,
before: function () {
return {
opacity: 0
};
},
after: function (datum) {
return datum;
}
}
};
}
export function discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: function () {
return {
opacity: 0
};
},
onExit: {
duration: 600,
before: function () {
return {
opacity: 0
};
}
after: function (datum) {
return datum;
}
},
onExit: {
duration: 600,
before: function () {
return {
opacity: 0
};
}
},
onEnter: {
duration: 600,
before: function () {
return {
opacity: 0
};
},
onEnter: {
duration: 600,
before: function () {
return {
opacity: 0
};
},
after: function (datum) {
return datum;
}
after: function (datum) {
return datum;
}
};
}
};
}
};
}

@@ -20,6 +20,6 @@ import _isDate from "lodash/isDate";

import React from "react";
import Data from "./data";
import Scale from "./scale";
import Helpers from "./helpers";
import Collection from "./collection"; // Private Methods
import * as Data from "./data";
import * as Scale from "./scale";
import * as Helpers from "./helpers";
import * as Collection from "./collection"; // Private Methods

@@ -162,3 +162,3 @@ function cleanDomain(domain, props, axis) {

function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
export function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
getDomainFromDataFunction = _isFunction(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData;

@@ -186,4 +186,3 @@ formatDomainFunction = _isFunction(formatDomainFunction) ? formatDomainFunction : formatDomain;

function formatDomain(domain, props, axis) {
export function formatDomain(domain, props, axis) {
return cleanDomain(padDomain(domain, props, axis), props, axis);

@@ -198,4 +197,3 @@ }

function getDomain(props, axis) {
export function getDomain(props, axis) {
return createDomainFunction()(props, axis);

@@ -211,4 +209,3 @@ }

function getDomainFromCategories(props, axis, categories) {
export function getDomainFromCategories(props, axis, categories) {
categories = categories || Data.getCategories(props, axis);

@@ -248,4 +245,3 @@ var polar = props.polar,

function getDomainFromData(props, axis, dataset) {
export function getDomainFromData(props, axis, dataset) {
dataset = dataset || Data.getData(props);

@@ -276,4 +272,3 @@ var polar = props.polar,

function getDomainFromMinMax(min, max) {
export function getDomainFromMinMax(min, max) {
var getSinglePointDomain = function (val) {

@@ -298,4 +293,3 @@ // d3-scale does not properly resolve very small differences.

function getDomainFromProps(props, axis) {
export function getDomainFromProps(props, axis) {
var minDomain = getMinFromProps(props, axis);

@@ -322,4 +316,3 @@ var maxDomain = getMaxFromProps(props, axis);

function getDomainWithZero(props, axis) {
export function getDomainWithZero(props, axis) {
var propsDomain = getDomainFromProps(props, axis);

@@ -366,4 +359,3 @@

function getMaxFromProps(props, axis) {
export function getMaxFromProps(props, axis) {
if (_isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {

@@ -382,4 +374,3 @@ return props.maxDomain[axis];

function getMinFromProps(props, axis) {
export function getMinFromProps(props, axis) {
if (_isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {

@@ -399,4 +390,3 @@ return props.minDomain[axis];

function getSymmetricDomain(domain, values) {
export function getSymmetricDomain(domain, values) {
var processedData = _sortedUniq(values.sort(function (a, b) {

@@ -415,4 +405,3 @@ return a - b;

function isDomainComponent(component) {
export function isDomainComponent(component) {
var getRole = function (child) {

@@ -431,17 +420,2 @@ return child && child.type ? child.type.role : "";

return _includes(whitelist, role);
}
export default {
createDomainFunction: createDomainFunction,
formatDomain: formatDomain,
getDomain: getDomain,
getDomainFromCategories: getDomainFromCategories,
getDomainFromData: getDomainFromData,
getDomainFromMinMax: getDomainFromMinMax,
getDomainFromProps: getDomainFromProps,
getDomainWithZero: getDomainWithZero,
getMaxFromProps: getMaxFromProps,
getMinFromProps: getMinFromProps,
getSymmetricDomain: getSymmetricDomain,
isDomainComponent: isDomainComponent
};
}

@@ -22,433 +22,432 @@ import _keys from "lodash/keys";

var GLOBAL_EVENT_REGEX = /^onGlobal(.*)$/;
export default {
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params
getEvents: function (props, target, eventKey, getScopedEvents) {
var _this = this;
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params,no-shadow
// Returns all events that apply to a particular target element
var getEventsByTarget = function (events) {
var getSelectedEvents = function () {
var targetEvents = events.reduce(function (memo, event) {
if (event.target !== undefined) {
var matchesTarget = Array.isArray(event.target) ? _includes(event.target, target) : "".concat(event.target) === "".concat(target);
return matchesTarget ? memo.concat(event) : memo;
}
export function getEvents(props, target, eventKey, getScopedEvents) {
var _this = this;
return memo.concat(event);
}, []);
// Returns all events that apply to a particular target element
var getEventsByTarget = function (events) {
var getSelectedEvents = function () {
var targetEvents = events.reduce(function (memo, event) {
if (event.target !== undefined) {
var matchesTarget = Array.isArray(event.target) ? _includes(event.target, target) : "".concat(event.target) === "".concat(target);
return matchesTarget ? memo.concat(event) : memo;
}
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter(function (obj) {
var targetKeys = obj.eventKey;
return memo.concat(event);
}, []);
var useKey = function (key) {
return key ? "".concat(key) === "".concat(eventKey) : true;
};
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter(function (obj) {
var targetKeys = obj.eventKey;
return Array.isArray(targetKeys) ? targetKeys.some(function (k) {
return useKey(k);
}) : useKey(targetKeys);
});
}
var useKey = function (key) {
return key ? "".concat(key) === "".concat(eventKey) : true;
};
return targetEvents;
};
return Array.isArray(targetKeys) ? targetKeys.some(function (k) {
return useKey(k);
}) : useKey(targetKeys);
});
}
var selectedEvents = getSelectedEvents();
return Array.isArray(selectedEvents) && selectedEvents.reduce(function (memo, event) {
return event ? _assign(memo, event.eventHandlers) : memo;
}, {});
return targetEvents;
};
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
var selectedEvents = getSelectedEvents();
return Array.isArray(selectedEvents) && selectedEvents.reduce(function (memo, event) {
return event ? _assign(memo, event.eventHandlers) : memo;
}, {});
};
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
var getAllEvents = function () {
if (Array.isArray(_this.componentEvents)) {
var _this$componentEvents;
return Array.isArray(props.events) ? (_this$componentEvents = _this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : _this.componentEvents;
}
var getAllEvents = function () {
if (Array.isArray(_this.componentEvents)) {
var _this$componentEvents;
return props.events;
};
return Array.isArray(props.events) ? (_this$componentEvents = _this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : _this.componentEvents;
}
var allEvents = getAllEvents();
var ownEvents = allEvents && _isFunction(getScopedEvents) ? getScopedEvents(getEventsByTarget(allEvents), target) : undefined;
return props.events;
};
if (!props.sharedEvents) {
return ownEvents;
}
var allEvents = getAllEvents();
var ownEvents = allEvents && _isFunction(getScopedEvents) ? getScopedEvents(getEventsByTarget(allEvents), target) : undefined;
var getSharedEvents = props.sharedEvents.getEvents;
var sharedEvents = props.sharedEvents.events && getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return _assign({}, sharedEvents, ownEvents);
},
if (!props.sharedEvents) {
return ownEvents;
}
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
*/
// eslint-disable-next-line max-params
getScopedEvents: function (events, namespace, childType, baseProps) {
var _this2 = this;
var getSharedEvents = props.sharedEvents.getEvents;
var sharedEvents = props.sharedEvents.events && getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return _assign({}, sharedEvents, ownEvents);
}
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
*/
// eslint-disable-next-line max-params
if (_isEmpty(events)) {
return {};
}
export function getScopedEvents(events, namespace, childType, baseProps) {
var _this2 = this;
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element
if (_isEmpty(events)) {
return {};
}
var getTargetProps = function (identifier, type) {
var childName = identifier.childName,
target = identifier.target,
key = identifier.key;
var baseType = type === "props" ? baseProps : _this2.state || {};
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
}; // Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element
var getTargetProps = function (identifier, type) {
var childName = identifier.childName,
target = identifier.target,
key = identifier.key;
var baseType = type === "props" ? baseProps : _this2.state || {};
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
}; // Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
var parseEvent = function (eventReturn, eventKey) {
var childNames = namespace === "parent" ? eventReturn.childName : eventReturn.childName || childType;
var target = eventReturn.target || namespace; // returns all eventKeys to modify for a targeted childName
var getKeys = function (childName) {
if (target === "parent") {
return "parent";
}
var parseEvent = function (eventReturn, eventKey) {
var childNames = namespace === "parent" ? eventReturn.childName : eventReturn.childName || childType;
var target = eventReturn.target || namespace; // returns all eventKeys to modify for a targeted childName
if (eventReturn.eventKey === "all") {
return baseProps[childName] ? _without(_keys(baseProps[childName]), "parent") : _without(_keys(baseProps), "parent");
} else if (eventReturn.eventKey === undefined && eventKey === "parent") {
return baseProps[childName] ? _keys(baseProps[childName]) : _keys(baseProps);
}
var getKeys = function (childName) {
if (target === "parent") {
return "parent";
}
return eventReturn.eventKey !== undefined ? eventReturn.eventKey : eventKey;
}; // returns the state object with mutated props applied for a single key
if (eventReturn.eventKey === "all") {
return baseProps[childName] ? _without(_keys(baseProps[childName]), "parent") : _without(_keys(baseProps), "parent");
} else if (eventReturn.eventKey === undefined && eventKey === "parent") {
return baseProps[childName] ? _keys(baseProps[childName]) : _keys(baseProps);
}
return eventReturn.eventKey !== undefined ? eventReturn.eventKey : eventKey;
}; // returns the state object with mutated props applied for a single key
var getMutationObject = function (key, childName) {
var baseState = _this2.state || {};
if (!_isFunction(eventReturn.mutation)) {
return baseState;
var getMutationObject = function (key, childName) {
var baseState = _this2.state || {};
if (!_isFunction(eventReturn.mutation)) {
return baseState;
}
var mutationTargetProps = getTargetProps({
childName: childName,
key: key,
target: target
}, "props");
var mutationTargetState = getTargetProps({
childName: childName,
key: key,
target: target
}, "state");
var mutatedProps = eventReturn.mutation(_assign({}, mutationTargetProps, mutationTargetState), baseProps);
var childState = baseState[childName] || {};
var filterState = function (state) {
if (state[key] && state[key][target]) {
delete state[key][target];
}
var mutationTargetProps = getTargetProps({
childName: childName,
key: key,
target: target
}, "props");
var mutationTargetState = getTargetProps({
childName: childName,
key: key,
target: target
}, "state");
var mutatedProps = eventReturn.mutation(_assign({}, mutationTargetProps, mutationTargetState), baseProps);
var childState = baseState[childName] || {};
if (state[key] && !_keys(state[key]).length) {
delete state[key];
}
var filterState = function (state) {
if (state[key] && state[key][target]) {
delete state[key][target];
}
return state;
};
if (state[key] && !_keys(state[key]).length) {
delete state[key];
}
var extendState = function (state) {
return target === "parent" ? _assign(state, _defineProperty({}, key, _assign(state[key], mutatedProps))) : _assign(state, _defineProperty({}, key, _assign(state[key], _defineProperty({}, target, mutatedProps))));
};
return state;
};
var updateState = function (state) {
return mutatedProps ? extendState(state) : filterState(state);
};
var extendState = function (state) {
return target === "parent" ? _assign(state, _defineProperty({}, key, _assign(state[key], mutatedProps))) : _assign(state, _defineProperty({}, key, _assign(state[key], _defineProperty({}, target, mutatedProps))));
};
return childName !== undefined && childName !== null ? _assign(baseState, _defineProperty({}, childName, updateState(childState))) : updateState(baseState);
}; // returns entire mutated state for a given childName
var updateState = function (state) {
return mutatedProps ? extendState(state) : filterState(state);
};
return childName !== undefined && childName !== null ? _assign(baseState, _defineProperty({}, childName, updateState(childState))) : updateState(baseState);
}; // returns entire mutated state for a given childName
var getReturnByChild = function (childName) {
var mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys) ? mutationKeys.reduce(function (memo, key) {
return _assign(memo, getMutationObject(key, childName));
}, {}) : getMutationObject(mutationKeys, childName);
}; // returns an entire mutated state for all children
var getReturnByChild = function (childName) {
var mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys) ? mutationKeys.reduce(function (memo, key) {
return _assign(memo, getMutationObject(key, childName));
}, {}) : getMutationObject(mutationKeys, childName);
}; // returns an entire mutated state for all children
var allChildNames = childNames === "all" ? _without(_keys(baseProps), "parent") : childNames;
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) {
return _assign(memo, getReturnByChild(childName));
}, {}) : getReturnByChild(allChildNames);
}; // Parses an array of event returns into a single state mutation
var allChildNames = childNames === "all" ? _without(_keys(baseProps), "parent") : childNames;
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) {
return _assign(memo, getReturnByChild(childName));
}, {}) : getReturnByChild(allChildNames);
}; // Parses an array of event returns into a single state mutation
var parseEventReturn = function (eventReturn, eventKey) {
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) {
memo = _assign({}, memo, parseEvent(props, eventKey));
return memo;
}, {}) : parseEvent(eventReturn, eventKey);
};
var parseEventReturn = function (eventReturn, eventKey) {
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) {
memo = _assign({}, memo, parseEvent(props, eventKey));
return memo;
}, {}) : parseEvent(eventReturn, eventKey);
var compileCallbacks = function (eventReturn) {
var getCallback = function (obj) {
return _isFunction(obj.callback) && obj.callback;
};
var compileCallbacks = function (eventReturn) {
var getCallback = function (obj) {
return _isFunction(obj.callback) && obj.callback;
};
var callbacks = Array.isArray(eventReturn) ? eventReturn.map(function (evtObj) {
return getCallback(evtObj);
}) : [getCallback(eventReturn)];
var callbackArray = callbacks.filter(function (callback) {
return callback !== false;
var callbacks = Array.isArray(eventReturn) ? eventReturn.map(function (evtObj) {
return getCallback(evtObj);
}) : [getCallback(eventReturn)];
var callbackArray = callbacks.filter(function (callback) {
return callback !== false;
});
return callbackArray.length ? function () {
return callbackArray.forEach(function (callback) {
return callback();
});
return callbackArray.length ? function () {
return callbackArray.forEach(function (callback) {
return callback();
});
} : undefined;
}; // A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
} : undefined;
}; // A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
var onEvent = function (evt, childProps, eventKey, eventName) {
var eventReturn = events[eventName](evt, childProps, eventKey, _this2);
var onEvent = function (evt, childProps, eventKey, eventName) {
var eventReturn = events[eventName](evt, childProps, eventKey, _this2);
if (!_isEmpty(eventReturn)) {
var callbacks = compileCallbacks(eventReturn);
if (!_isEmpty(eventReturn)) {
var callbacks = compileCallbacks(eventReturn);
_this2.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
}; // returns a new events object with enhanced event handlers
_this2.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
}; // returns a new events object with enhanced event handlers
return _keys(events).reduce(function (memo, event) {
memo[event] = onEvent;
return memo;
}, {});
},
return _keys(events).reduce(function (memo, event) {
memo[event] = onEvent;
return memo;
}, {});
}
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
getPartialEvents: function (events, eventKey, childProps) {
return events ? _keys(events).reduce(function (memo, eventName) {
var appliedEvent = function (evt) {
return events[eventName](evt, childProps, eventKey, eventName);
};
export function getPartialEvents(events, eventKey, childProps) {
return events ? _keys(events).reduce(function (memo, eventName) {
var appliedEvent = function (evt) {
return events[eventName](evt, childProps, eventKey, eventName);
};
memo[eventName] = appliedEvent;
return memo;
}, {}) : {};
},
memo[eventName] = appliedEvent;
return memo;
}, {}) : {};
}
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
getEventState: function (eventKey, namespace, childType) {
var state = this.state || {};
export function getEventState(eventKey, namespace, childType) {
var state = this.state || {};
if (!childType) {
return eventKey === "parent" ? state[eventKey] && state[eventKey][namespace] || state[eventKey] : state[eventKey] && state[eventKey][namespace];
}
if (!childType) {
return eventKey === "parent" ? state[eventKey] && state[eventKey][namespace] || state[eventKey] : state[eventKey] && state[eventKey][namespace];
}
return state[childType] && state[childType][eventKey] && state[childType][eventKey][namespace];
},
return state[childType] && state[childType][eventKey] && state[childType][eventKey][namespace];
}
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
getExternalMutationsWithChildren: function (mutations, baseProps, baseState, childNames) {
var _this3 = this;
export function getExternalMutationsWithChildren(mutations, baseProps, baseState, childNames) {
var _this3 = this;
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce(function (memo, childName) {
var childState = baseState[childName];
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce(function (memo, childName) {
var childState = baseState[childName];
var mutation = _this3.getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
var mutation = _this3.getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
memo[childName] = mutation ? mutation : childState;
return _pickBy(memo, function (v) {
return !_isEmpty(v);
});
}, {});
},
memo[childName] = mutation ? mutation : childState;
return _pickBy(memo, function (v) {
return !_isEmpty(v);
});
}, {});
}
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
getExternalMutations: function (mutations, baseProps, baseState, childName) {
var _this4 = this;
export function getExternalMutations(mutations, baseProps, baseState, childName) {
var _this4 = this;
baseProps = baseProps || {};
baseState = baseState || {};
baseProps = baseProps || {};
baseState = baseState || {};
var eventKeys = _keys(baseProps);
var eventKeys = _keys(baseProps);
return eventKeys.reduce(function (memo, eventKey) {
var keyState = baseState[eventKey] || {};
var keyProps = baseProps[eventKey] || {};
return eventKeys.reduce(function (memo, eventKey) {
var keyState = baseState[eventKey] || {};
var keyProps = baseProps[eventKey] || {};
if (eventKey === "parent") {
if (eventKey === "parent") {
var identifier = {
eventKey: eventKey,
target: "parent"
};
var mutation = _this4.getExternalMutation(mutations, keyProps, keyState, identifier);
memo[eventKey] = mutation !== undefined ? _assign({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
var targets = _uniq(_keys(keyProps).concat(_keys(keyState)));
memo[eventKey] = targets.reduce(function (m, target) {
var identifier = {
eventKey: eventKey,
target: "parent"
target: target,
childName: childName
};
var mutation = _this4.getExternalMutation(mutations, keyProps, keyState, identifier);
var mutation = _this4.getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
memo[eventKey] = mutation !== undefined ? _assign({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
var targets = _uniq(_keys(keyProps).concat(_keys(keyState)));
m[target] = mutation !== undefined ? _assign({}, keyState[target], mutation) : keyState[target];
return _pickBy(m, function (v) {
return !_isEmpty(v);
});
}, {});
}
memo[eventKey] = targets.reduce(function (m, target) {
var identifier = {
eventKey: eventKey,
target: target,
childName: childName
};
return _pickBy(memo, function (v) {
return !_isEmpty(v);
});
}, {});
}
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
var mutation = _this4.getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
m[target] = mutation !== undefined ? _assign({}, keyState[target], mutation) : keyState[target];
return _pickBy(m, function (v) {
return !_isEmpty(v);
});
}, {});
}
return _pickBy(memo, function (v) {
return !_isEmpty(v);
export function getExternalMutation(mutations, baseProps, baseState, identifier) {
var filterMutations = function (mutation, type) {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
var stringArray = mutation[type].map(function (m) {
return "".concat(m);
});
}, {});
},
return _includes(stringArray, identifier[type]);
} else {
return false;
}
};
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
getExternalMutation: function (mutations, baseProps, baseState, identifier) {
var filterMutations = function (mutation, type) {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
var stringArray = mutation[type].map(function (m) {
return "".concat(m);
});
return _includes(stringArray, identifier[type]);
} else {
return false;
}
};
mutations = Array.isArray(mutations) ? mutations : [mutations];
var scopedMutations = mutations;
mutations = Array.isArray(mutations) ? mutations : [mutations];
var scopedMutations = mutations;
if (identifier.childName) {
scopedMutations = mutations.filter(function (m) {
return filterMutations(m, "childName");
});
} // find any mutation objects that match the target
if (identifier.childName) {
scopedMutations = mutations.filter(function (m) {
return filterMutations(m, "childName");
});
} // find any mutation objects that match the target
var targetMutations = scopedMutations.filter(function (m) {
return filterMutations(m, "target");
});
var targetMutations = scopedMutations.filter(function (m) {
return filterMutations(m, "target");
});
if (_isEmpty(targetMutations)) {
return undefined;
}
if (_isEmpty(targetMutations)) {
return undefined;
}
var keyMutations = targetMutations.filter(function (m) {
return filterMutations(m, "eventKey");
});
var keyMutations = targetMutations.filter(function (m) {
return filterMutations(m, "eventKey");
});
if (_isEmpty(keyMutations)) {
return undefined;
}
if (_isEmpty(keyMutations)) {
return keyMutations.reduce(function (memo, curr) {
var mutationFunction = curr && _isFunction(curr.mutation) ? curr.mutation : function () {
return undefined;
}
};
var currentMutation = mutationFunction(_assign({}, baseProps, baseState));
return _assign({}, memo, currentMutation);
}, {});
}
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
return keyMutations.reduce(function (memo, curr) {
var mutationFunction = curr && _isFunction(curr.mutation) ? curr.mutation : function () {
return undefined;
};
var currentMutation = mutationFunction(_assign({}, baseProps, baseState));
return _assign({}, memo, currentMutation);
}, {});
},
export function getComponentEvents(props, components) {
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
var _memo;
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
getComponentEvents: function (props, components) {
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
var _memo;
var component = props[componentName];
var defaultEvents = component && component.type && component.type.defaultEvents;
var componentEvents = _isFunction(defaultEvents) ? defaultEvents(component.props) : defaultEvents;
memo = Array.isArray(componentEvents) ? (_memo = memo).concat.apply(_memo, _toConsumableArray(componentEvents)) : memo;
return memo;
}, []);
return events && events.length ? events : undefined;
},
getGlobalEventNameFromKey: function (key) {
var match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
},
getGlobalEvents: function (events) {
return _pickBy(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
},
omitGlobalEvents: function (events) {
return _omitBy(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
},
emulateReactEvent: function (event) {
return _assign(event, {
nativeEvent: event
});
}
var component = props[componentName];
var defaultEvents = component && component.type && component.type.defaultEvents;
var componentEvents = _isFunction(defaultEvents) ? defaultEvents(component.props) : defaultEvents;
memo = Array.isArray(componentEvents) ? (_memo = memo).concat.apply(_memo, _toConsumableArray(componentEvents)) : memo;
return memo;
}, []);
return events && events.length ? events : undefined;
}
export function getGlobalEventNameFromKey(key) {
var match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
}
export var getGlobalEvents = function (events) {
return _pickBy(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
};
export var omitGlobalEvents = function (events) {
return _omitBy(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
};
export var emulateReactEvent = function (event) {
return _assign(event, {
nativeEvent: event
});
};

@@ -45,3 +45,3 @@ import _keys from "lodash/keys";

function omit(originalObject) {
export function omit(originalObject) {
var ks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

@@ -65,4 +65,3 @@ // code based on babel's _objectWithoutProperties

}
function getPoint(datum) {
export function getPoint(datum) {
var exists = function (val) {

@@ -90,4 +89,3 @@ return val !== undefined;

}
function scalePoint(props, datum) {
export function scalePoint(props, datum) {
var scale = props.scale,

@@ -112,4 +110,3 @@ polar = props.polar,

}
function getPadding(props) {
export function getPadding(props) {
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "padding";

@@ -126,9 +123,7 @@ var padding = props[name];

}
function isTooltip(component) {
export function isTooltip(component) {
var labelRole = component && component.type && component.type.role;
return labelRole === "tooltip";
}
function getDefaultStyles(props, role) {
export function getDefaultStyles(props, role) {
var _props$theme = props.theme,

@@ -151,4 +146,3 @@ theme = _props$theme === void 0 ? {} : _props$theme,

}
function getStyles(style, defaultStyles) {
export function getStyles(style, defaultStyles) {
var width = "100%";

@@ -181,8 +175,6 @@ var height = "100%";

}
function evaluateProp(prop, props) {
export function evaluateProp(prop, props) {
return _isFunction(prop) ? prop(props) : prop;
}
function evaluateStyle(style, props) {
export function evaluateStyle(style, props) {
if (props.disableInlineStyles) {

@@ -203,12 +195,9 @@ return {};

}
function degreesToRadians(degrees) {
export function degreesToRadians(degrees) {
return typeof degrees === "number" ? degrees * (Math.PI / 180) : degrees;
}
function radiansToDegrees(radians) {
export function radiansToDegrees(radians) {
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
}
function getRadius(props) {
export function getRadius(props) {
var _getPadding = getPadding(props),

@@ -224,4 +213,3 @@ left = _getPadding.left,

}
function getPolarOrigin(props) {
export function getPolarOrigin(props) {
var width = props.width,

@@ -244,4 +232,3 @@ height = props.height;

}
function getRange(props, axis) {
export function getRange(props, axis) {
if (props.range && props.range[axis]) {

@@ -255,4 +242,3 @@ return props.range[axis];

}
function createAccessor(key) {
export function createAccessor(key) {
// creates a data accessor function

@@ -272,4 +258,3 @@ // given a property key, path, array index, or null for identity.

}
function modifyProps(props, fallbackProps, role) {
export function modifyProps(props, fallbackProps, role) {
var theme = props.theme && props.theme[role] ? props.theme[role] : {};

@@ -290,4 +275,3 @@ var themeProps = omit(theme, ["style"]);

function getCurrentAxis(axis, horizontal) {
export function getCurrentAxis(axis, horizontal) {
var otherAxis = axis === "x" ? "y" : "x";

@@ -308,4 +292,3 @@ return horizontal ? otherAxis : axis;

function reduceChildren(children, iteratee) {
export function reduceChildren(children, iteratee) {
var parentProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -361,4 +344,3 @@ var initialMemo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

function isHorizontal(props) {
export function isHorizontal(props) {
if (props.horizontal !== undefined || !props.children) {

@@ -382,24 +364,2 @@ return props.horizontal;

return traverseChildren(React.Children.toArray(props.children));
}
export default {
omit: omit,
getPoint: getPoint,
scalePoint: scalePoint,
getPadding: getPadding,
getDefaultStyles: getDefaultStyles,
getStyles: getStyles,
evaluateProp: evaluateProp,
evaluateStyle: evaluateStyle,
degreesToRadians: degreesToRadians,
radiansToDegrees: radiansToDegrees,
getRadius: getRadius,
getPolarOrigin: getPolarOrigin,
getRange: getRange,
createAccessor: createAccessor,
modifyProps: modifyProps,
getCurrentAxis: getCurrentAxis,
reduceChildren: reduceChildren,
isHorizontal: isHorizontal,
isTooltip: isTooltip
};
}

@@ -1,33 +0,30 @@

export default {
IMMUTABLE_ITERABLE: "@@__IMMUTABLE_ITERABLE__@@",
IMMUTABLE_RECORD: "@@__IMMUTABLE_RECORD__@@",
IMMUTABLE_LIST: "@@__IMMUTABLE_LIST__@@",
IMMUTABLE_MAP: "@@__IMMUTABLE_MAP__@@",
isImmutable: function (x) {
return this.isIterable(x) || this.isRecord(x);
},
isIterable: function (x) {
return !!(x && x[this.IMMUTABLE_ITERABLE]);
},
isRecord: function (x) {
return !!(x && x[this.IMMUTABLE_RECORD]);
},
isList: function (x) {
return !!(x && x[this.IMMUTABLE_LIST]);
},
isMap: function (x) {
return !!(x && x[this.IMMUTABLE_MAP]);
},
shallowToJS: function (x, whitelist) {
var _this = this;
/* eslint-disable func-style */
export var IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
export var IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
export var IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
export var IMMUTABLE_MAP = "@@__IMMUTABLE_MAP__@@";
export function isIterable(x) {
return !!(x && x[IMMUTABLE_ITERABLE]);
}
export function isRecord(x) {
return !!(x && x[IMMUTABLE_RECORD]);
}
export function isImmutable(x) {
return isIterable(x) || isRecord(x);
}
export function isList(x) {
return !!(x && x[IMMUTABLE_LIST]);
}
export function isMap(x) {
return !!(x && x[IMMUTABLE_MAP]);
}
export function shallowToJS(x, whitelist) {
return isIterable(x) ? x.reduce(function (prev, curr, key) {
if (whitelist && whitelist[key]) {
curr = shallowToJS(curr);
}
return this.isIterable(x) ? x.reduce(function (prev, curr, key) {
if (whitelist && whitelist[key]) {
curr = _this.shallowToJS(curr);
}
prev[key] = curr;
return prev;
}, this.isList(x) ? [] : {}) : x;
}
};
prev[key] = curr;
return prev;
}, isList(x) ? [] : {}) : x;
}

@@ -6,3 +6,3 @@ import _defaults from "lodash/defaults";

/* eslint-disable no-use-before-define */
import Helpers from "./helpers";
import * as Helpers from "./helpers";

@@ -126,3 +126,3 @@ // Private Functions

function getText(props, datum, index) {
export function getText(props, datum, index) {
datum = datum || {};

@@ -136,4 +136,3 @@

}
function getPolarTextAnchor(props, degrees) {
export function getPolarTextAnchor(props, degrees) {
var labelPlacement = getLabelPlacement(props);

@@ -147,4 +146,3 @@

}
function getPolarVerticalAnchor(props, degrees) {
export function getPolarVerticalAnchor(props, degrees) {
var labelPlacement = getLabelPlacement(props);

@@ -159,4 +157,3 @@ var orientation = getPolarOrientation(degrees);

}
function getPolarAngle(props, baseAngle) {
export function getPolarAngle(props, baseAngle) {
var labelPlacement = props.labelPlacement,

@@ -184,4 +181,3 @@ datum = props.datum;

}
function getDegrees(props, datum) {
export function getDegrees(props, datum) {
var _Helpers$getPoint = Helpers.getPoint(datum),

@@ -192,4 +188,3 @@ x = _Helpers$getPoint.x;

}
function getProps(props, index) {
export function getProps(props, index) {
var scale = props.scale,

@@ -249,11 +244,2 @@ data = props.data,

return _defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
}
export default {
getText: getText,
getPolarTextAnchor: getPolarTextAnchor,
getPolarVerticalAnchor: getPolarVerticalAnchor,
getPolarAngle: getPolarAngle,
getDegrees: getDegrees,
getProps: getProps
};
}

@@ -5,10 +5,9 @@ /* global console */

// TODO: Use "warning" npm module like React is switching to.
export default {
warn: function (message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
// eslint-disable-next-line func-style
export function warn(message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
}
};
}

@@ -7,3 +7,3 @@ import _isRegExp from "lodash/isRegExp";

import Log from "./log";
import * as Log from "./log";
import PropTypes from "prop-types";

@@ -86,169 +86,168 @@ /**

};
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
export default {
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
deprecated: function (propType, explanation) {
return function (props, propName, componentName) {
var value = props[propName];
if (value !== null && value !== undefined) {
Log.warn("\"".concat(propName, "\" property of \"").concat(componentName, "\" has been deprecated ").concat(explanation));
}
return PropTypes.checkPropTypes(_defineProperty({}, propName, propType), props, propName, componentName);
};
},
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
allOfType: function (validators) {
return makeChainable(function (props, propName, componentName) {
for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
rest[_key2 - 3] = arguments[_key2];
}
return validators.reduce(function (result, validator) {
return result || validator.apply(void 0, [props, propName, componentName].concat(rest));
}, undefined);
});
},
/**
* Check that the value is a non-negative number.
*/
nonNegative: makeChainable(function (props, propName, componentName) {
export function deprecated(propType, explanation) {
return function (props, propName, componentName) {
var value = props[propName];
if (typeof value !== "number" || value < 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a non-negative number."));
if (value !== null && value !== undefined) {
Log.warn("\"".concat(propName, "\" property of \"").concat(componentName, "\" has been deprecated ").concat(explanation));
}
return undefined;
}),
return PropTypes.checkPropTypes(_defineProperty({}, propName, propType), props, propName, componentName);
};
}
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
/**
* Check that the value is an integer.
*/
integer: makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (typeof value !== "number" || value % 1 !== 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an integer."));
export function allOfType(validators) {
return makeChainable(function (props, propName, componentName) {
for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
rest[_key2 - 3] = arguments[_key2];
}
return undefined;
}),
return validators.reduce(function (result, validator) {
return result || validator.apply(void 0, [props, propName, componentName].concat(rest));
}, undefined);
});
}
/**
* Check that the value is a non-negative number.
*/
/**
* Check that the value is greater than zero.
*/
greaterThanZero: makeChainable(function (props, propName, componentName) {
var value = props[propName];
export var nonNegative = makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (typeof value !== "number" || value <= 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a number greater than zero."));
}
if (typeof value !== "number" || value < 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a non-negative number."));
}
return undefined;
}),
return undefined;
});
/**
* Check that the value is an integer.
*/
/**
* Check that the value is an Array of two unique values.
*/
domain: makeChainable(function (props, propName, componentName) {
var value = props[propName];
export var integer = makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array of two unique numeric values."));
}
if (typeof value !== "number" || value % 1 !== 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an integer."));
}
return undefined;
}),
return undefined;
});
/**
* Check that the value is greater than zero.
*/
/**
* Check that the value looks like a d3 `scale` function.
*/
scale: makeChainable(function (props, propName, componentName) {
var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
export var greaterThanZero = makeChainable(function (props, propName, componentName) {
var value = props[propName];
var validScale = function (scl) {
if (_isFunction(scl)) {
return _isFunction(scl.copy) && _isFunction(scl.domain) && _isFunction(scl.range);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
if (typeof value !== "number" || value <= 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a number greater than zero."));
}
return false;
};
return undefined;
});
/**
* Check that the value is an Array of two unique values.
*/
var value = props[propName];
export var domain = makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (!validScale(value)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a d3 scale."));
}
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array of two unique numeric values."));
}
return undefined;
}),
return undefined;
});
/**
* Check that the value looks like a d3 `scale` function.
*/
/**
* Check that an array contains items of the same type.
*/
homogeneousArray: makeChainable(function (props, propName, componentName) {
var values = props[propName];
export var scale = makeChainable(function (props, propName, componentName) {
var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
if (!Array.isArray(values)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array."));
var validScale = function (scl) {
if (_isFunction(scl)) {
return _isFunction(scl.copy) && _isFunction(scl.domain) && _isFunction(scl.range);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
if (values.length < 2) {
return undefined;
}
return false;
};
var comparisonConstructor = getConstructor(values[0]);
var value = props[propName];
var typeMismatchedValue = _find(values, function (value) {
return comparisonConstructor !== getConstructor(value);
});
if (!validScale(value)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a d3 scale."));
}
if (typeMismatchedValue) {
var constructorName = getConstructorName(values[0]);
var otherConstructorName = getConstructorName(typeMismatchedValue);
return new Error("Expected `".concat(propName, "` in `").concat(componentName, "` to be a ") + "homogeneous array, but found types `".concat(constructorName, "` and ") + "`".concat(otherConstructorName, "`."));
}
return undefined;
});
/**
* Check that an array contains items of the same type.
*/
return undefined;
}),
export var homogeneousArray = makeChainable(function (props, propName, componentName) {
var values = props[propName];
/**
* Check that array prop length matches props.data.length
*/
matchDataLength: makeChainable(function (props, propName) {
if (props[propName] && Array.isArray(props[propName]) && props[propName].length !== props.data.length) {
return new Error("Length of data and ".concat(propName, " arrays must match."));
}
if (!Array.isArray(values)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array."));
}
if (values.length < 2) {
return undefined;
}),
}
/**
* Check that the value is a regular expression
*/
regExp: makeChainable(function (props, propName, componentName) {
if (props[propName] && !_isRegExp(props[propName])) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a regular expression."));
}
var comparisonConstructor = getConstructor(values[0]);
return undefined;
})
};
var typeMismatchedValue = _find(values, function (value) {
return comparisonConstructor !== getConstructor(value);
});
if (typeMismatchedValue) {
var constructorName = getConstructorName(values[0]);
var otherConstructorName = getConstructorName(typeMismatchedValue);
return new Error("Expected `".concat(propName, "` in `").concat(componentName, "` to be a ") + "homogeneous array, but found types `".concat(constructorName, "` and ") + "`".concat(otherConstructorName, "`."));
}
return undefined;
});
/**
* Check that array prop length matches props.data.length
*/
export var matchDataLength = makeChainable(function (props, propName) {
if (props[propName] && Array.isArray(props[propName]) && props[propName].length !== props.data.length) {
return new Error("Length of data and ".concat(propName, " arrays must match."));
}
return undefined;
});
/**
* Check that the value is a regular expression
*/
export var regExp = makeChainable(function (props, propName, componentName) {
if (props[propName] && !_isRegExp(props[propName])) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a regular expression."));
}
return undefined;
});
import _isPlainObject from "lodash/isPlainObject";
import _isFunction from "lodash/isFunction";
import _includes from "lodash/includes";
import Helpers from "./helpers";
import Collection from "./collection";
import * as Helpers from "./helpers";
import * as Collection from "./collection";
import * as d3Scale from "d3-scale";

@@ -77,7 +77,6 @@ var supportedScaleStrings = ["linear", "time", "log", "sqrt"]; // Private Functions

function getScaleFromName(name) {
export function getScaleFromName(name) {
return validScale(name) ? d3Scale[toNewName(name)]() : d3Scale.scaleLinear();
}
function getBaseScale(props, axis) {
export function getBaseScale(props, axis) {
var scale = getScaleFromProps(props, axis);

@@ -92,8 +91,6 @@

}
function getDefaultScale() {
export function getDefaultScale() {
return d3Scale.scaleLinear();
}
function getScaleFromProps(props, axis) {
export function getScaleFromProps(props, axis) {
if (!isScaleDefined(props, axis)) {

@@ -111,9 +108,7 @@ return undefined;

}
function getScaleType(props, axis) {
export function getScaleType(props, axis) {
// if the scale was not given in props, it will be set to linear or time depending on data
return getScaleTypeFromProps(props, axis) || getScaleTypeFromData(props, axis);
}
function getType(scale) {
export function getType(scale) {
if (typeof scale === "string") {

@@ -143,11 +138,2 @@ return scale;

return scaleType ? scaleType.name : undefined;
}
export default {
getBaseScale: getBaseScale,
getDefaultScale: getDefaultScale,
getScaleFromProps: getScaleFromProps,
getScaleType: getScaleType,
getType: getType,
getScaleFromName: getScaleFromName
};
}
/* eslint-disable func-style */
/* eslint-disable no-use-before-define */
import Collection from "./collection"; // Private Functions
import * as Collection from "./collection"; // Private Functions

@@ -19,3 +19,3 @@ function transformTarget(target, matrix, dimension) {

function getParentSVG(evt) {
export function getParentSVG(evt) {
if (evt.nativeEvent && evt.nativeEvent.identifier !== undefined) {

@@ -35,4 +35,3 @@ return undefined;

}
function getSVGEventCoordinates(evt, svg) {
export function getSVGEventCoordinates(evt, svg) {
if (evt.nativeEvent && evt.nativeEvent.identifier !== undefined) {

@@ -55,4 +54,3 @@ // react-native override. relies on the RN.View being the _exact_ same size as its child SVG.

}
function getDomainCoordinates(props, domain) {
export function getDomainCoordinates(props, domain) {
var scale = props.scale,

@@ -70,4 +68,3 @@ horizontal = props.horizontal;

function getDataCoordinates(props, scale, x, y) {
export function getDataCoordinates(props, scale, x, y) {
var polar = props.polar,

@@ -96,4 +93,3 @@ horizontal = props.horizontal;

}
function getBounds(props) {
export function getBounds(props) {
var x1 = props.x1,

@@ -115,10 +111,2 @@ x2 = props.x2,

};
}
export default {
getParentSVG: getParentSVG,
getSVGEventCoordinates: getSVGEventCoordinates,
getDomainCoordinates: getDomainCoordinates,
getDataCoordinates: getDataCoordinates,
getBounds: getBounds
};
}

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

/* eslint-disable func-style */
/**

@@ -10,3 +12,3 @@ * Given an object with CSS/SVG transform definitions, return the string value

*/
var toTransformString = function (obj) {
export var toTransformString = function (obj) {
for (var _len = arguments.length, more = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

@@ -37,26 +39,22 @@ more[_key - 1] = arguments[_key];

};
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
export default {
toTransformString: toTransformString,
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
getColorScale: function (name) {
var scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}
};
export function getColorScale(name) {
var scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}

@@ -180,3 +180,3 @@ import _defaults from "lodash/defaults";

var convertLengthToPixels = function (length, fontSize) {
export var convertLengthToPixels = function (length, fontSize) {
var attribute = length.match(/[a-zA-Z%]+/) && length.match(/[a-zA-Z%]+/)[0];

@@ -249,2 +249,20 @@ var value = length.match(/[0-9.,]+/);

}, 0);
}; // Stubbable implementation.
export var _approximateTextSizeInternal = {
impl: function (text, style) {
var angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
var height = _approximateTextHeightInternal(text, style);
var width = _approximateTextWidthInternal(text, style);
var widthWithRotate = angle ? _getSizeWithRotate(width, height, angle) : width;
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
}
};

@@ -263,21 +281,4 @@ /**

var approximateTextSize = function (text, style) {
var angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
var height = _approximateTextHeightInternal(text, style);
var width = _approximateTextWidthInternal(text, style);
var widthWithRotate = angle ? _getSizeWithRotate(width, height, angle) : width;
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
};
export default {
approximateTextSize: approximateTextSize,
convertLengthToPixels: convertLengthToPixels
export var approximateTextSize = function (text, style) {
return _approximateTextSizeInternal.impl(text, style);
};

@@ -82,3 +82,3 @@ import _keys from "lodash/keys";

function getInitialTransitionState(oldChildren, nextChildren) {
export function getInitialTransitionState(oldChildren, nextChildren) {
var nodesWillExit = false;

@@ -280,3 +280,3 @@ var nodesWillEnter = false;

function getTransitionPropsFactory(props, state, setState) {
export function getTransitionPropsFactory(props, state, setState) {
var nodesWillExit = state && state.nodesWillExit;

@@ -411,7 +411,2 @@ var nodesWillEnter = state && state.nodesWillEnter;

};
}
export default {
getInitialTransitionState: getInitialTransitionState,
getTransitionPropsFactory: getTransitionPropsFactory
};
}

@@ -25,12 +25,12 @@ import _isPlainObject from "lodash/isPlainObject";

import React from "react";
import Axis from "./axis";
import Style from "./style";
import Transitions from "./transitions";
import Data from "./data";
import Domain from "./domain";
import Events from "./events";
import Collection from "./collection";
import Helpers from "./helpers";
import Scale from "./scale";
import Log from "./log";
import * as Axis from "./axis";
import * as Style from "./style";
import * as Transitions from "./transitions";
import * as Data from "./data";
import * as Domain from "./domain";
import * as Events from "./events";
import * as Collection from "./collection";
import * as Helpers from "./helpers";
import * as Scale from "./scale";
import * as Log from "./log";
export default {

@@ -37,0 +37,0 @@ getData: function (props, childComponents) {

@@ -919,2 +919,4 @@ import * as React from "react";

desc?: string;
rx?: number;
ry?: number;
}

@@ -921,0 +923,0 @@

@@ -150,86 +150,2 @@ "use strict";

});
Object.defineProperty(exports, "Collection", {
enumerable: true,
get: function () {
return _collection.default;
}
});
Object.defineProperty(exports, "Data", {
enumerable: true,
get: function () {
return _data.default;
}
});
Object.defineProperty(exports, "DefaultTransitions", {
enumerable: true,
get: function () {
return _defaultTransitions.default;
}
});
Object.defineProperty(exports, "Domain", {
enumerable: true,
get: function () {
return _domain.default;
}
});
Object.defineProperty(exports, "Events", {
enumerable: true,
get: function () {
return _events.default;
}
});
Object.defineProperty(exports, "Helpers", {
enumerable: true,
get: function () {
return _helpers.default;
}
});
Object.defineProperty(exports, "Immutable", {
enumerable: true,
get: function () {
return _immutable.default;
}
});
Object.defineProperty(exports, "LabelHelpers", {
enumerable: true,
get: function () {
return _labelHelpers.default;
}
});
Object.defineProperty(exports, "Log", {
enumerable: true,
get: function () {
return _log.default;
}
});
Object.defineProperty(exports, "PropTypes", {
enumerable: true,
get: function () {
return _propTypes.default;
}
});
Object.defineProperty(exports, "Scale", {
enumerable: true,
get: function () {
return _scale.default;
}
});
Object.defineProperty(exports, "Selection", {
enumerable: true,
get: function () {
return _selection.default;
}
});
Object.defineProperty(exports, "Style", {
enumerable: true,
get: function () {
return _style.default;
}
});
Object.defineProperty(exports, "TextSize", {
enumerable: true,
get: function () {
return _textsize.default;
}
});
Object.defineProperty(exports, "Timer", {

@@ -241,14 +157,2 @@ enumerable: true,

});
Object.defineProperty(exports, "Transitions", {
enumerable: true,
get: function () {
return _transitions.default;
}
});
Object.defineProperty(exports, "CommonProps", {
enumerable: true,
get: function () {
return _commonProps.default;
}
});
Object.defineProperty(exports, "Wrapper", {

@@ -260,8 +164,2 @@ enumerable: true,

});
Object.defineProperty(exports, "Axis", {
enumerable: true,
get: function () {
return _axis.default;
}
});
Object.defineProperty(exports, "TimerContext", {

@@ -279,2 +177,3 @@ enumerable: true,

});
exports.Axis = exports.CommonProps = exports.Transitions = exports.TextSize = exports.Style = exports.Selection = exports.Scale = exports.PropTypes = exports.Log = exports.LabelHelpers = exports.Immutable = exports.Helpers = exports.Events = exports.Domain = exports.DefaultTransitions = exports.Data = exports.Collection = void 0;

@@ -327,40 +226,74 @@ var _victoryAccessibleGroup = _interopRequireDefault(require("./victory-accessible-group/victory-accessible-group"));

var _collection = _interopRequireDefault(require("./victory-util/collection"));
var _Collection = _interopRequireWildcard(require("./victory-util/collection"));
var _data = _interopRequireDefault(require("./victory-util/data"));
exports.Collection = _Collection;
var _defaultTransitions = _interopRequireDefault(require("./victory-util/default-transitions"));
var _Data = _interopRequireWildcard(require("./victory-util/data"));
var _domain = _interopRequireDefault(require("./victory-util/domain"));
exports.Data = _Data;
var _events = _interopRequireDefault(require("./victory-util/events"));
var _DefaultTransitions = _interopRequireWildcard(require("./victory-util/default-transitions"));
var _helpers = _interopRequireDefault(require("./victory-util/helpers"));
exports.DefaultTransitions = _DefaultTransitions;
var _immutable = _interopRequireDefault(require("./victory-util/immutable"));
var _Domain = _interopRequireWildcard(require("./victory-util/domain"));
var _labelHelpers = _interopRequireDefault(require("./victory-util/label-helpers"));
exports.Domain = _Domain;
var _log = _interopRequireDefault(require("./victory-util/log"));
var _Events = _interopRequireWildcard(require("./victory-util/events"));
var _propTypes = _interopRequireDefault(require("./victory-util/prop-types"));
exports.Events = _Events;
var _scale = _interopRequireDefault(require("./victory-util/scale"));
var _Helpers = _interopRequireWildcard(require("./victory-util/helpers"));
var _selection = _interopRequireDefault(require("./victory-util/selection"));
exports.Helpers = _Helpers;
var _style = _interopRequireDefault(require("./victory-util/style"));
var _Immutable = _interopRequireWildcard(require("./victory-util/immutable"));
var _textsize = _interopRequireDefault(require("./victory-util/textsize"));
exports.Immutable = _Immutable;
var _LabelHelpers = _interopRequireWildcard(require("./victory-util/label-helpers"));
exports.LabelHelpers = _LabelHelpers;
var _Log = _interopRequireWildcard(require("./victory-util/log"));
exports.Log = _Log;
var _PropTypes = _interopRequireWildcard(require("./victory-util/prop-types"));
exports.PropTypes = _PropTypes;
var _Scale = _interopRequireWildcard(require("./victory-util/scale"));
exports.Scale = _Scale;
var _Selection = _interopRequireWildcard(require("./victory-util/selection"));
exports.Selection = _Selection;
var _Style = _interopRequireWildcard(require("./victory-util/style"));
exports.Style = _Style;
var _TextSize = _interopRequireWildcard(require("./victory-util/textsize"));
exports.TextSize = _TextSize;
var _timer = _interopRequireDefault(require("./victory-util/timer"));
var _transitions = _interopRequireDefault(require("./victory-util/transitions"));
var _Transitions = _interopRequireWildcard(require("./victory-util/transitions"));
var _commonProps = _interopRequireDefault(require("./victory-util/common-props"));
exports.Transitions = _Transitions;
var _CommonProps = _interopRequireWildcard(require("./victory-util/common-props"));
exports.CommonProps = _CommonProps;
var _wrapper = _interopRequireDefault(require("./victory-util/wrapper"));
var _axis = _interopRequireDefault(require("./victory-util/axis"));
var _Axis = _interopRequireWildcard(require("./victory-util/axis"));
exports.Axis = _Axis;
var _timerContext = _interopRequireDefault(require("./victory-util/timer-context"));

@@ -370,2 +303,4 @@

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -20,5 +20,5 @@ "use strict";

var _propTypes2 = _interopRequireDefault(require("../victory-util/prop-types"));
var CustomPropTypes = _interopRequireWildcard(require("../victory-util/prop-types"));
var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));

@@ -31,2 +31,4 @@ var _clipPath = _interopRequireDefault(require("../victory-primitives/clip-path"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -86,9 +88,6 @@

translateY = _props$translateY === void 0 ? 0 : _props$translateY;
var clipPadding = _helpers.default.getPadding({
var clipPadding = Helpers.getPadding({
padding: props.clipPadding
});
var radius = props.radius || _helpers.default.getRadius(props);
var radius = props.radius || Helpers.getRadius(props);
return {

@@ -159,3 +158,3 @@ x: (polar ? origin.x : translateX) - clipPadding.left,

var _Helpers$getPadding = _helpers.default.getPadding({
var _Helpers$getPadding = Helpers.getPadding({
padding: props.clipPadding

@@ -171,4 +170,3 @@ }),

if (polar) {
var radius = props.radius || _helpers.default.getRadius(props);
var radius = props.radius || Helpers.getRadius(props);
var circleProps = {

@@ -208,4 +206,3 @@ r: Math.max(radius + left + right, radius + top + bottom, 0),

var range = _helpers.default.getRange(props, axis);
var range = Helpers.getRange(props, axis);
return range ? Math.abs(range[0] - range[1]) || undefined : undefined;

@@ -225,4 +222,3 @@ }

var range = _helpers.default.getRange(props, axis);
var range = Helpers.getRange(props, axis);
return range ? Math.min.apply(Math, _toConsumableArray(range)) : undefined;

@@ -277,3 +273,3 @@ }

className: _propTypes.default.string,
clipHeight: _propTypes2.default.nonNegative,
clipHeight: CustomPropTypes.nonNegative,
clipId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),

@@ -287,11 +283,11 @@ clipPadding: _propTypes.default.shape({

clipPathComponent: _propTypes.default.element,
clipWidth: _propTypes2.default.nonNegative,
clipWidth: CustomPropTypes.nonNegative,
events: _propTypes.default.object,
groupComponent: _propTypes.default.element,
origin: _propTypes.default.shape({
x: _propTypes2.default.nonNegative,
y: _propTypes2.default.nonNegative
x: CustomPropTypes.nonNegative,
y: CustomPropTypes.nonNegative
}),
polar: _propTypes.default.bool,
radius: _propTypes2.default.nonNegative,
radius: CustomPropTypes.nonNegative,
style: _propTypes.default.object,

@@ -298,0 +294,0 @@ tabIndex: _propTypes.default.number,

@@ -22,3 +22,3 @@ "use strict";

var _propTypes2 = _interopRequireDefault(require("../victory-util/prop-types"));
var CustomPropTypes = _interopRequireWildcard(require("../victory-util/prop-types"));

@@ -31,4 +31,6 @@ var _portal = _interopRequireDefault(require("../victory-portal/portal"));

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -218,3 +220,3 @@

role = _props.role;
var style = responsive ? this.props.style : _helpers.default.omit(this.props.style, ["height", "width"]);
var style = responsive ? this.props.style : Helpers.omit(this.props.style, ["height", "width"]);
var svgProps = (0, _assign2.default)({

@@ -263,7 +265,7 @@ width: width,

events: _propTypes.default.object,
height: _propTypes2.default.nonNegative,
height: CustomPropTypes.nonNegative,
name: _propTypes.default.string,
origin: _propTypes.default.shape({
x: _propTypes2.default.nonNegative,
y: _propTypes2.default.nonNegative
x: CustomPropTypes.nonNegative,
y: CustomPropTypes.nonNegative
}),

@@ -275,3 +277,3 @@ ouiaId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),

portalComponent: _propTypes.default.element,
portalZIndex: _propTypes2.default.integer,
portalZIndex: CustomPropTypes.integer,
preserveAspectRatio: _propTypes.default.string,

@@ -284,3 +286,3 @@ responsive: _propTypes.default.bool,

title: _propTypes.default.string,
width: _propTypes2.default.nonNegative
width: CustomPropTypes.nonNegative
}

@@ -287,0 +289,0 @@ });

@@ -22,13 +22,13 @@ "use strict";

var _propTypes2 = _interopRequireDefault(require("../victory-util/prop-types"));
var CustomPropTypes = _interopRequireWildcard(require("../victory-util/prop-types"));
var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _labelHelpers = _interopRequireDefault(require("../victory-util/label-helpers"));
var LabelHelpers = _interopRequireWildcard(require("../victory-util/label-helpers"));
var _style = _interopRequireDefault(require("../victory-util/style"));
var Style = _interopRequireWildcard(require("../victory-util/style"));
var _log = _interopRequireDefault(require("../victory-util/log"));
var Log = _interopRequireWildcard(require("../victory-util/log"));
var _textsize = _interopRequireDefault(require("../victory-util/textsize"));
var TextSize = _interopRequireWildcard(require("../victory-util/textsize"));

@@ -39,2 +39,4 @@ var _tspan = _interopRequireDefault(require("../victory-primitives/tspan"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -66,4 +68,3 @@

var scaledPoint = _helpers.default.scalePoint(props, props.datum);
var scaledPoint = Helpers.scalePoint(props, props.datum);
return scaledPoint[dimension];

@@ -85,4 +86,3 @@ };

} else {
_log.default.warn("fontSize should be expressed as a number of pixels");
Log.warn("fontSize should be expressed as a number of pixels");
return defaultStyles.fontSize;

@@ -108,4 +108,3 @@ }

if (props.disableInlineStyles) {
var baseStyles = _helpers.default.evaluateStyle(style, props);
var baseStyles = Helpers.evaluateStyle(style, props);
return {

@@ -119,5 +118,3 @@ // Font size is necessary to calculate the y position of the label

s = s ? (0, _defaults2.default)({}, s, defaultStyles) : defaultStyles;
var baseStyles = _helpers.default.evaluateStyle(s, props);
var baseStyles = Helpers.evaluateStyle(s, props);
return (0, _assign2.default)({}, baseStyles, {

@@ -139,4 +136,4 @@ fontSize: getFontSize(baseStyles)

return Array.isArray(style) && !(0, _isEmpty2.default)(style) ? style.map(function (s) {
return _helpers.default.evaluateStyle(s, props);
}) : _helpers.default.evaluateStyle(style, props);
return Helpers.evaluateStyle(s, props);
}) : Helpers.evaluateStyle(style, props);
};

@@ -147,5 +144,4 @@

return props.backgroundPadding.map(function (backgroundPadding) {
var padding = _helpers.default.evaluateProp(backgroundPadding, props);
return _helpers.default.getPadding({
var padding = Helpers.evaluateProp(backgroundPadding, props);
return Helpers.getPadding({
padding: padding

@@ -155,5 +151,4 @@ });

} else {
var padding = _helpers.default.evaluateProp(props.backgroundPadding, props);
return _helpers.default.getPadding({
var padding = Helpers.evaluateProp(props.backgroundPadding, props);
return Helpers.getPadding({
padding: padding

@@ -165,3 +160,3 @@ });

var getLineHeight = function (props) {
var lineHeight = _helpers.default.evaluateProp(props.lineHeight, props);
var lineHeight = Helpers.evaluateProp(props.lineHeight, props);

@@ -182,7 +177,7 @@ if (Array.isArray(lineHeight)) {

return text.map(function (line) {
return _helpers.default.evaluateProp(line, props);
return Helpers.evaluateProp(line, props);
});
}
var child = _helpers.default.evaluateProp(text, props);
var child = Helpers.evaluateProp(text, props);

@@ -197,9 +192,7 @@ if (child === undefined || child === null) {

var getDy = function (props, verticalAnchor, lineHeight) {
var dy = props.dy ? _helpers.default.evaluateProp(props.dy, props) : 0;
var dy = props.dy ? Helpers.evaluateProp(props.dy, props) : 0;
var length = props.inline ? 1 : props.text.length;
var capHeight = Helpers.evaluateProp(props.capHeight, props);
var anchor = verticalAnchor ? Helpers.evaluateProp(verticalAnchor, props) : "middle";
var capHeight = _helpers.default.evaluateProp(props.capHeight, props);
var anchor = verticalAnchor ? _helpers.default.evaluateProp(verticalAnchor, props) : "middle";
var fontSizes = _toConsumableArray(Array(length).keys()).map(function (i) {

@@ -231,13 +224,11 @@ return getSingleValue(props.style, i).fontSize;

var style = getSingleValue(props.style);
var defaultAngle = polar ? _labelHelpers.default.getPolarAngle(props) : 0;
var baseAngle = style.angle === undefined ? _helpers.default.evaluateProp(props.angle, props) : style.angle;
var defaultAngle = polar ? LabelHelpers.getPolarAngle(props) : 0;
var baseAngle = style.angle === undefined ? Helpers.evaluateProp(props.angle, props) : style.angle;
var angle = baseAngle === undefined ? defaultAngle : baseAngle;
var transform = props.transform || style.transform;
var transformPart = transform && _helpers.default.evaluateProp(transform, props);
var transformPart = transform && Helpers.evaluateProp(transform, props);
var rotatePart = angle && {
rotate: [angle, x, y]
};
return transformPart || angle ? _style.default.toTransformString(transformPart, rotatePart) : undefined;
return transformPart || angle ? Style.toTransformString(transformPart, rotatePart) : undefined;
};

@@ -456,5 +447,3 @@

}));
var id = _helpers.default.evaluateProp(props.id, props);
var id = Helpers.evaluateProp(props.id, props);
return (0, _assign2.default)({}, props, {

@@ -470,10 +459,9 @@ backgroundStyle: backgroundStyle,

var getCalculatedProps = function (props) {
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var style = getSingleValue(props.style);
var lineHeight = getLineHeight(props);
var direction = props.direction ? _helpers.default.evaluateProp(props.direction, props) : "inherit";
var textAnchor = props.textAnchor ? _helpers.default.evaluateProp(props.textAnchor, props) : style.textAnchor || "start";
var verticalAnchor = props.verticalAnchor ? _helpers.default.evaluateProp(props.verticalAnchor, props) : style.verticalAnchor || "middle";
var dx = props.dx ? _helpers.default.evaluateProp(props.dx, props) : 0;
var direction = props.direction ? Helpers.evaluateProp(props.direction, props) : "inherit";
var textAnchor = props.textAnchor ? Helpers.evaluateProp(props.textAnchor, props) : style.textAnchor || "start";
var verticalAnchor = props.verticalAnchor ? Helpers.evaluateProp(props.verticalAnchor, props) : style.verticalAnchor || "middle";
var dx = props.dx ? Helpers.evaluateProp(props.dx, props) : 0;
var dy = getDy(props, verticalAnchor, lineHeight);

@@ -529,4 +517,4 @@ var x = props.x !== undefined ? props.x : getPosition(props, "x");

title: title,
desc: _helpers.default.evaluateProp(desc, calculatedProps),
tabIndex: _helpers.default.evaluateProp(tabIndex, calculatedProps),
desc: Helpers.evaluateProp(desc, calculatedProps),
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps),
id: id

@@ -566,5 +554,3 @@ });

var currentStyle = getSingleValue(style, i);
var capHeightPx = _textsize.default.convertLengthToPixels("".concat(capHeight, "em"), currentStyle.fontSize);
var capHeightPx = TextSize.convertLengthToPixels("".concat(capHeight, "em"), currentStyle.fontSize);
var currentLineHeight = getSingleValue(lineHeight, i);

@@ -576,3 +562,3 @@ return {

text: line,
textSize: _textsize.default.approximateTextSize(line, currentStyle),
textSize: TextSize.approximateTextSize(line, currentStyle),
lineHeight: currentLineHeight,

@@ -606,3 +592,3 @@ backgroundPadding: getSingleValue(backgroundPadding, i)

backgroundStyle: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]),
capHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes2.default.nonNegative, _propTypes.default.func]),
capHeight: _propTypes.default.oneOfType([_propTypes.default.string, CustomPropTypes.nonNegative, _propTypes.default.func]),
className: _propTypes.default.string,

@@ -621,6 +607,6 @@ data: _propTypes.default.array,

labelPlacement: _propTypes.default.oneOf(["parallel", "perpendicular", "vertical"]),
lineHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes2.default.nonNegative, _propTypes.default.func, _propTypes.default.array]),
lineHeight: _propTypes.default.oneOfType([_propTypes.default.string, CustomPropTypes.nonNegative, _propTypes.default.func, _propTypes.default.array]),
origin: _propTypes.default.shape({
x: _propTypes2.default.nonNegative,
y: _propTypes2.default.nonNegative
x: CustomPropTypes.nonNegative,
y: CustomPropTypes.nonNegative
}),

@@ -630,4 +616,4 @@ polar: _propTypes.default.bool,

scale: _propTypes.default.shape({
x: _propTypes2.default.scale,
y: _propTypes2.default.scale
x: CustomPropTypes.scale,
y: CustomPropTypes.scale
}),

@@ -634,0 +620,0 @@ style: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]),

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

var _propTypes2 = _interopRequireDefault(require("../victory-util/prop-types"));
var CustomPropTypes = _interopRequireWildcard(require("../victory-util/prop-types"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -103,7 +105,7 @@

className: _propTypes.default.string,
height: _propTypes2.default.nonNegative,
height: CustomPropTypes.nonNegative,
style: _propTypes.default.object,
viewBox: _propTypes.default.string,
width: _propTypes2.default.nonNegative
width: CustomPropTypes.nonNegative
}
});

@@ -14,8 +14,10 @@ "use strict";

var _log = _interopRequireDefault(require("../victory-util/log"));
var Log = _interopRequireWildcard(require("../victory-util/log"));
var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _portalContext = _interopRequireDefault(require("./portal-context"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -52,5 +54,3 @@

var msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
_log.default.warn(msg);
Log.warn(msg);
this.renderInPlace = true;

@@ -100,3 +100,3 @@ }

} : {};
var newProps = (0, _defaults2.default)(standardProps, childProps, _helpers.default.omit(this.props, ["children", "groupComponent"]));
var newProps = (0, _defaults2.default)(standardProps, childProps, Helpers.omit(this.props, ["children", "groupComponent"]));

@@ -103,0 +103,0 @@ var child = children && _react.default.cloneElement(children, newProps);

@@ -14,8 +14,10 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));
var _path = _interopRequireDefault(require("./path"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,8 +38,8 @@

var halfAngle = Math.abs(endAngle - startAngle) / 2 + startAngle;
var x1 = cx + r * Math.cos(_helpers.default.degreesToRadians(startAngle));
var y1 = cy - r * Math.sin(_helpers.default.degreesToRadians(startAngle));
var x2 = cx + r * Math.cos(_helpers.default.degreesToRadians(halfAngle));
var y2 = cy - r * Math.sin(_helpers.default.degreesToRadians(halfAngle));
var x3 = cx + r * Math.cos(_helpers.default.degreesToRadians(endAngle));
var y3 = cy - r * Math.sin(_helpers.default.degreesToRadians(endAngle));
var x1 = cx + r * Math.cos(Helpers.degreesToRadians(startAngle));
var y1 = cy - r * Math.sin(Helpers.degreesToRadians(startAngle));
var x2 = cx + r * Math.cos(Helpers.degreesToRadians(halfAngle));
var y2 = cy - r * Math.sin(Helpers.degreesToRadians(halfAngle));
var x3 = cx + r * Math.cos(Helpers.degreesToRadians(endAngle));
var y3 = cy - r * Math.sin(Helpers.degreesToRadians(endAngle));
var largerArcFlag1 = halfAngle - startAngle <= 180 ? 0 : 1;

@@ -61,15 +63,10 @@ var largerArcFlag2 = endAngle - halfAngle <= 180 ? 0 : 1;

*/
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var desc = _helpers.default.evaluateProp(props.desc, props);
var id = _helpers.default.evaluateProp(props.id, props);
var style = _helpers.default.evaluateStyle((0, _assign2.default)({
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var desc = Helpers.evaluateProp(props.desc, props);
var id = Helpers.evaluateProp(props.id, props);
var style = Helpers.evaluateStyle((0, _assign2.default)({
stroke: "black",
fill: "none"
}, props.style), props);
var tabIndex = _helpers.default.evaluateProp(props.tabIndex, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return (0, _assign2.default)({}, props, {

@@ -100,3 +97,3 @@ ariaLabel: ariaLabel,

Arc.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
Arc.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
closedPath: _propTypes.default.bool,

@@ -103,0 +100,0 @@ cx: _propTypes.default.number,

@@ -14,5 +14,5 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));

@@ -23,2 +23,4 @@ var _rect = _interopRequireDefault(require("./rect"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -35,4 +37,3 @@

*/
var id = _helpers.default.evaluateProp(props.id, props);
var id = Helpers.evaluateProp(props.id, props);
return (0, _assign2.default)({}, props, {

@@ -67,3 +68,3 @@ id: id

Background.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
Background.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
circleComponent: _propTypes.default.element,

@@ -70,0 +71,0 @@ height: _propTypes.default.number,

@@ -14,8 +14,10 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));
var _rect = _interopRequireDefault(require("./rect"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,14 +38,9 @@

*/
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var desc = _helpers.default.evaluateProp(props.desc, props);
var id = _helpers.default.evaluateProp(props.id, props);
var style = _helpers.default.evaluateStyle((0, _assign2.default)({
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var desc = Helpers.evaluateProp(props.desc, props);
var id = Helpers.evaluateProp(props.id, props);
var style = Helpers.evaluateStyle((0, _assign2.default)({
fill: "none"
}, props.style), props);
var tabIndex = _helpers.default.evaluateProp(props.tabIndex, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return (0, _assign2.default)({}, props, {

@@ -77,3 +74,3 @@ ariaLabel: ariaLabel,

Border.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
Border.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
height: _propTypes.default.number,

@@ -80,0 +77,0 @@ rectComponent: _propTypes.default.element,

@@ -14,8 +14,10 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));
var _line = _interopRequireDefault(require("./line"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,14 +38,9 @@

*/
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var desc = _helpers.default.evaluateProp(props.desc, props);
var id = _helpers.default.evaluateProp(props.id, props);
var style = _helpers.default.evaluateStyle((0, _assign2.default)({
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var desc = Helpers.evaluateProp(props.desc, props);
var id = Helpers.evaluateProp(props.id, props);
var style = Helpers.evaluateStyle((0, _assign2.default)({
stroke: "black"
}, props.style), props);
var tabIndex = _helpers.default.evaluateProp(props.tabIndex, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return (0, _assign2.default)({}, props, {

@@ -77,3 +74,3 @@ ariaLabel: ariaLabel,

LineSegment.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
LineSegment.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
datum: _propTypes.default.any,

@@ -80,0 +77,0 @@ lineComponent: _propTypes.default.element,

@@ -14,10 +14,12 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _pathHelpers = _interopRequireDefault(require("./path-helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));
var _path = _interopRequireDefault(require("./path"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -65,16 +67,9 @@

*/
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var desc = _helpers.default.evaluateProp(props.desc, props);
var id = _helpers.default.evaluateProp(props.id, props);
var size = _helpers.default.evaluateProp(props.size, props);
var style = _helpers.default.evaluateStyle(props.style, props);
var symbol = _helpers.default.evaluateProp(props.symbol, props);
var tabIndex = _helpers.default.evaluateProp(props.tabIndex, props);
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var desc = Helpers.evaluateProp(props.desc, props);
var id = Helpers.evaluateProp(props.id, props);
var size = Helpers.evaluateProp(props.size, props);
var style = Helpers.evaluateStyle(props.style, props);
var symbol = Helpers.evaluateProp(props.symbol, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return (0, _assign2.default)({}, props, {

@@ -107,3 +102,3 @@ ariaLabel: ariaLabel,

Point.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
Point.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
datum: _propTypes.default.object,

@@ -110,0 +105,0 @@ getPath: _propTypes.default.func,

@@ -14,8 +14,10 @@ "use strict";

var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _commonProps = _interopRequireDefault(require("../victory-util/common-props"));
var CommonProps = _interopRequireWildcard(require("../victory-util/common-props"));
var _line = _interopRequireDefault(require("./line"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,12 +38,7 @@

*/
var ariaLabel = _helpers.default.evaluateProp(props.ariaLabel, props);
var desc = _helpers.default.evaluateProp(props.desc, props);
var id = _helpers.default.evaluateProp(props.id, props);
var style = _helpers.default.evaluateStyle(props.style, props);
var tabIndex = _helpers.default.evaluateProp(props.tabIndex, props);
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var desc = Helpers.evaluateProp(props.desc, props);
var id = Helpers.evaluateProp(props.id, props);
var style = Helpers.evaluateStyle(props.style, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return (0, _assign2.default)({}, props, {

@@ -94,3 +91,3 @@ ariaLabel: ariaLabel,

Whisker.propTypes = _objectSpread({}, _commonProps.default.primitiveProps, {
Whisker.propTypes = _objectSpread({}, CommonProps.primitiveProps, {
groupComponent: _propTypes.default.element,

@@ -97,0 +94,0 @@ lineComponent: _propTypes.default.element,

@@ -22,12 +22,14 @@ "use strict";

var _collection = _interopRequireDefault(require("../victory-util/collection"));
var Collection = _interopRequireWildcard(require("../victory-util/collection"));
var _helpers = _interopRequireDefault(require("../victory-util/helpers"));
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
var _timerContext = _interopRequireDefault(require("../victory-util/timer-context"));
var _transitions = _interopRequireDefault(require("../victory-util/transitions"));
var Transitions = _interopRequireWildcard(require("../victory-util/transitions"));
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -117,3 +119,3 @@

var _Transitions$getIniti = _transitions.default.getInitialTransitionState(oldChildren, nextChildren),
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
nodesWillExit = _Transitions$getIniti.nodesWillExit,

@@ -159,3 +161,3 @@ nodesWillEnter = _Transitions$getIniti.nodesWillEnter,

var childDomains = getChildDomains([child]);
return childDomains.length === 0 ? [0, 1] : [_collection.default.getMinValue(childDomains), _collection.default.getMaxValue(childDomains)];
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
}

@@ -187,4 +189,3 @@ }

var getDefaultClipWidth = function () {
var range = _helpers.default.getRange(child.props, "x");
var range = Helpers.getRange(child.props, "x");
return range ? Math.abs(range[1] - range[0]) : props.width;

@@ -202,3 +203,3 @@ };

var props = this.pickProps();
var getTransitionProps = (0, _isObject2.default)(this.props.animate) && this.props.animate.getTransitions ? this.props.animate.getTransitions : _transitions.default.getTransitionPropsFactory(props, this.state, function (newState) {
var getTransitionProps = (0, _isObject2.default)(this.props.animate) && this.props.animate.getTransitions ? this.props.animate.getTransitions : Transitions.getTransitionPropsFactory(props, this.state, function (newState) {
return _this3.setState(newState);

@@ -205,0 +206,0 @@ });

@@ -28,3 +28,3 @@ "use strict";

var _events = _interopRequireDefault(require("./events"));
var Events = _interopRequireWildcard(require("./events"));

@@ -35,2 +35,4 @@ var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -84,7 +86,4 @@

_this = _possibleConstructorReturn(this, (addEvents.__proto__ || Object.getPrototypeOf(addEvents)).call(this, props));
var getScopedEvents = _events.default.getScopedEvents.bind(_assertThisInitialized(_this));
var boundGetEvents = _events.default.getEvents.bind(_assertThisInitialized(_this));
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
_this.state = {};

@@ -96,3 +95,3 @@

_this.getEventState = _events.default.getEventState.bind(_assertThisInitialized(_this));
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));

@@ -184,7 +183,7 @@ var calculatedValues = _this.getCalculatedValues(props);

var listener = _this5.globalEvents[key];
return listener && listener(_events.default.emulateReactEvent(event));
return listener && listener(Events.emulateReactEvent(event));
};
this.boundGlobalEvents[key] = boundListener;
window.addEventListener(_events.default.getGlobalEventNameFromKey(key), boundListener);
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
}

@@ -194,3 +193,3 @@ }, {

value: function removeGlobalListener(key) {
window.removeEventListener(_events.default.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
} // compile all state changes from own and parent state. Order doesn't matter, as any state

@@ -248,5 +247,3 @@ // state change should trigger a re-render

var components = WrappedComponent.expectedComponents;
var componentEvents = _events.default.getComponentEvents(props, components);
var componentEvents = Events.getComponentEvents(props, components);
var getSharedEventState = sharedEvents && (0, _isFunction2.default)(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {

@@ -275,3 +272,3 @@ return undefined;

externalEventMutations = props.externalEventMutations;
return (0, _isEmpty2.default)(externalEventMutations) || sharedEvents ? undefined : _events.default.getExternalMutations(externalEventMutations, this.baseProps, this.state);
return (0, _isEmpty2.default)(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
}

@@ -330,3 +327,3 @@ }, {

});
var events = (0, _defaults2.default)({}, _events.default.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
var events = (0, _defaults2.default)({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
return (0, _assign2.default)({}, componentProps, {

@@ -351,4 +348,4 @@ events: events

if (parentProps.events) {
this.globalEvents = _events.default.getGlobalEvents(parentProps.events);
parentProps.events = _events.default.omitGlobalEvents(parentProps.events);
this.globalEvents = Events.getGlobalEvents(parentProps.events);
parentProps.events = Events.omitGlobalEvents(parentProps.events);
}

@@ -355,0 +352,0 @@

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

});
exports.default = void 0;
exports.getAxis = getAxis;
exports.findAxisComponents = findAxisComponents;
exports.getAxisComponent = getAxisComponent;
exports.getAxisComponentsWithParent = getAxisComponentsWithParent;
exports.getOrigin = getOrigin;
exports.getOriginSign = getOriginSign;
exports.isVertical = isVertical;
exports.stringTicks = stringTicks;
exports.getTickFormat = getTickFormat;
exports.getTicks = getTicks;
exports.getDomain = getDomain;
exports.getAxisValue = getAxisValue;
exports.modifyProps = modifyProps;

@@ -35,8 +47,10 @@ var _without2 = _interopRequireDefault(require("lodash/without"));

var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));
var _domain = _interopRequireDefault(require("./domain"));
var Domain = _interopRequireWildcard(require("./domain"));
var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -141,4 +155,4 @@

return {
x: _collection.default.containsDates(domain.x) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.x))) : getSingleOrigin(domain.x),
y: _collection.default.containsDates(domain.y) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.y))) : getSingleOrigin(domain.y)
x: Collection.containsDates(domain.x) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.x))) : getSingleOrigin(domain.x),
y: Collection.containsDates(domain.y) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.y))) : getSingleOrigin(domain.y)
};

@@ -152,3 +166,3 @@ }

return _collection.default.containsDates(domain) ? "positive" : getSign();
return Collection.containsDates(domain) ? "positive" : getSign();
}

@@ -178,3 +192,3 @@ /**

function stringTicks(props) {
return props.tickValues !== undefined && _collection.default.containsStrings(props.tickValues);
return props.tickValues !== undefined && Collection.containsStrings(props.tickValues);
}

@@ -186,3 +200,3 @@

var stringMap = props.stringMap && props.stringMap[axis];
var fallbackFormat = tickValues && !_collection.default.containsDates(tickValues) ? function (x) {
var fallbackFormat = tickValues && !Collection.containsDates(tickValues) ? function (x) {
return x;

@@ -215,3 +229,3 @@ } : undefined;

var categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis];
var ticksFromCategories = categories && _collection.default.containsOnlyStrings(categories) ? categories.map(function (tick) {
var ticksFromCategories = categories && Collection.containsOnlyStrings(categories) ? categories.map(function (tick) {
return stringMap[tick];

@@ -234,3 +248,3 @@ }) : undefined;

return _collection.default.containsStrings(tickFormat) ? tickFormat.map(function (t, i) {
return Collection.containsStrings(tickFormat) ? tickFormat.map(function (t, i) {
return i;

@@ -246,3 +260,3 @@ }) : tickFormat;

if (tickValues && _collection.default.containsStrings(tickValues)) {
if (tickValues && Collection.containsStrings(tickValues)) {
ticks = stringMap ? tickValues.map(function (tick) {

@@ -262,3 +276,3 @@ return stringMap[tick];

if (Array.isArray(domain)) {
if (t >= _collection.default.getMinValue(domain) && t <= _collection.default.getMaxValue(domain)) {
if (t >= Collection.getMinValue(domain) && t <= Collection.getMaxValue(domain)) {
newTickArray.push({

@@ -383,6 +397,4 @@ value: t,

var minDomain = _domain.default.getMinFromProps(props, axis);
var maxDomain = _domain.default.getMaxFromProps(props, axis);
var minDomain = Domain.getMinFromProps(props, axis);
var maxDomain = Domain.getMaxFromProps(props, axis);
var tickStrings = stringTicks(props);

@@ -392,11 +404,9 @@ var ticks = tickValues.map(function (value) {

});
var defaultMin = tickStrings ? 1 : _collection.default.getMinValue(ticks);
var defaultMax = tickStrings ? tickValues.length : _collection.default.getMaxValue(ticks);
var defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
var defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
var min = minDomain !== undefined ? minDomain : defaultMin;
var max = maxDomain !== undefined ? maxDomain : defaultMax;
var initialDomain = Domain.getDomainFromMinMax(min, max);
var domain = polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? Domain.getSymmetricDomain(initialDomain, ticks) : initialDomain;
var initialDomain = _domain.default.getDomainFromMinMax(min, max);
var domain = polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? _domain.default.getSymmetricDomain(initialDomain, ticks) : initialDomain;
if (isVertical(props) && !polar) {

@@ -417,3 +427,3 @@ domain.reverse();

return _domain.default.createDomainFunction(getDomainFromData)(props, inherentAxis);
return Domain.createDomainFunction(getDomainFromData)(props, inherentAxis);
}

@@ -441,3 +451,3 @@

if (!(0, _isObject2.default)(props.theme)) {
return _helpers.default.modifyProps(props, fallbackProps, "axis");
return Helpers.modifyProps(props, fallbackProps, "axis");
}

@@ -454,3 +464,3 @@

if (role === "axis") {
return _helpers.default.modifyProps(props, fallbackProps, "axis");
return Helpers.modifyProps(props, fallbackProps, "axis");
}

@@ -462,22 +472,5 @@

});
return _helpers.default.modifyProps((0, _assign2.default)({}, props, {
return Helpers.modifyProps((0, _assign2.default)({}, props, {
theme: theme
}), fallbackProps, "axis");
}
var _default = {
getTicks: getTicks,
getTickFormat: getTickFormat,
getAxis: getAxis,
getAxisComponent: getAxisComponent,
getAxisComponentsWithParent: getAxisComponentsWithParent,
getAxisValue: getAxisValue,
findAxisComponents: findAxisComponents,
getOrigin: getOrigin,
getOriginSign: getOriginSign,
getDomain: getDomain,
isVertical: isVertical,
modifyProps: modifyProps,
stringTicks: stringTicks
};
exports.default = _default;
}

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

});
exports.default = void 0;
exports.containsStrings = containsStrings;
exports.containsDates = containsDates;
exports.containsNumbers = containsNumbers;
exports.containsOnlyStrings = containsOnlyStrings;
exports.isArrayOfArrays = isArrayOfArrays;
exports.removeUndefined = removeUndefined;
exports.getMaxValue = getMaxValue;
exports.getMinValue = getMinValue;

@@ -74,14 +81,2 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

return containsDates(array) ? new Date(Math.min.apply(Math, _toConsumableArray(array))) : Math.min.apply(Math, _toConsumableArray(array));
}
var _default = {
containsDates: containsDates,
containsNumbers: containsNumbers,
containsOnlyStrings: containsOnlyStrings,
containsStrings: containsStrings,
getMaxValue: getMaxValue,
getMinValue: getMinValue,
isArrayOfArrays: isArrayOfArrays,
removeUndefined: removeUndefined
};
exports.default = _default;
}

@@ -6,8 +6,10 @@ "use strict";

});
exports.default = void 0;
exports.primitiveProps = exports.baseProps = exports.dataProps = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _propTypes2 = _interopRequireDefault(require("./prop-types"));
var CustomPropTypes = _interopRequireWildcard(require("./prop-types"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -25,4 +27,4 @@

labels: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.array]),
samples: _propTypes2.default.nonNegative,
sortKey: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
samples: CustomPropTypes.nonNegative,
sortKey: _propTypes.default.oneOfType([_propTypes.default.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
sortOrder: _propTypes.default.oneOf(["ascending", "descending"]),

@@ -34,12 +36,13 @@ style: _propTypes.default.shape({

}),
x: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
y: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
y0: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)])
x: _propTypes.default.oneOfType([_propTypes.default.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
y: _propTypes.default.oneOfType([_propTypes.default.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
y0: _propTypes.default.oneOfType([_propTypes.default.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)])
};
exports.dataProps = dataProps;
var baseProps = {
animate: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
containerComponent: _propTypes.default.element,
domain: _propTypes.default.oneOfType([_propTypes2.default.domain, _propTypes.default.shape({
x: _propTypes2.default.domain,
y: _propTypes2.default.domain
domain: _propTypes.default.oneOfType([CustomPropTypes.domain, _propTypes.default.shape({
x: CustomPropTypes.domain,
y: CustomPropTypes.domain
})]),

@@ -58,6 +61,6 @@ maxDomain: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.instanceOf(Date), _propTypes.default.shape({

}), _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.number)]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.func, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string]),
events: _propTypes.default.arrayOf(_propTypes.default.shape({
target: _propTypes.default.oneOf(["data", "labels", "parent"]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string]),
eventHandlers: _propTypes.default.object

@@ -68,3 +71,3 @@ })),

childName: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes2.default.allOfType([_propTypes2.default.integer, _propTypes2.default.nonNegative]), _propTypes.default.string]),
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string]),
mutation: _propTypes.default.function,

@@ -74,3 +77,3 @@ target: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array])

groupComponent: _propTypes.default.element,
height: _propTypes2.default.nonNegative,
height: CustomPropTypes.nonNegative,
name: _propTypes.default.string,

@@ -88,9 +91,9 @@ origin: _propTypes.default.shape({

polar: _propTypes.default.bool,
range: _propTypes.default.oneOfType([_propTypes2.default.domain, _propTypes.default.shape({
x: _propTypes2.default.domain,
y: _propTypes2.default.domain
range: _propTypes.default.oneOfType([CustomPropTypes.domain, _propTypes.default.shape({
x: CustomPropTypes.domain,
y: CustomPropTypes.domain
})]),
scale: _propTypes.default.oneOfType([_propTypes2.default.scale, _propTypes.default.shape({
x: _propTypes2.default.scale,
y: _propTypes2.default.scale
scale: _propTypes.default.oneOfType([CustomPropTypes.scale, _propTypes.default.shape({
x: CustomPropTypes.scale,
y: CustomPropTypes.scale
})]),

@@ -107,4 +110,5 @@ sharedEvents: _propTypes.default.shape({

theme: _propTypes.default.object,
width: _propTypes2.default.nonNegative
width: CustomPropTypes.nonNegative
};
exports.baseProps = baseProps;
var primitiveProps = {

@@ -127,5 +131,5 @@ active: _propTypes.default.bool,

role: _propTypes.default.string,
scale: _propTypes.default.oneOfType([_propTypes2.default.scale, _propTypes.default.shape({
x: _propTypes2.default.scale,
y: _propTypes2.default.scale
scale: _propTypes.default.oneOfType([CustomPropTypes.scale, _propTypes.default.shape({
x: CustomPropTypes.scale,
y: CustomPropTypes.scale
})]),

@@ -137,7 +141,2 @@ shapeRendering: _propTypes.default.string,

};
var _default = {
baseProps: baseProps,
dataProps: dataProps,
primitiveProps: primitiveProps
};
exports.default = _default;
exports.primitiveProps = primitiveProps;

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

});
exports.default = void 0;
exports.formatDataFromDomain = formatDataFromDomain;
exports.createStringMap = createStringMap;
exports.downsample = downsample;
exports.formatData = formatData;
exports.generateData = generateData;
exports.getCategories = getCategories;
exports.getData = getData;
exports.getStringsFromAxes = getStringsFromAxes;
exports.getStringsFromCategories = getStringsFromCategories;
exports.getStringsFromData = getStringsFromData;
exports.isDataComponent = isDataComponent;

@@ -37,10 +47,12 @@ var _omitBy2 = _interopRequireDefault(require("lodash/omitBy"));

var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));
var _scale = _interopRequireDefault(require("./scale"));
var Scale = _interopRequireWildcard(require("./scale"));
var _immutable = _interopRequireDefault(require("./immutable"));
var Immutable = _interopRequireWildcard(require("./immutable"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -62,7 +74,7 @@

};
return _immutable.default.isImmutable(datum) ? _immutable.default.shallowToJS(datum, immutableDatumWhitelist) : datum;
return Immutable.isImmutable(datum) ? Immutable.shallowToJS(datum, immutableDatumWhitelist) : datum;
}
function getLength(data) {
return _immutable.default.isIterable(data) ? data.size : data.length;
return Immutable.isIterable(data) ? data.size : data.length;
} // Returns generated data for a given axis based on domain and sample from props

@@ -73,5 +85,3 @@

var propsDomain = (0, _isPlainObject2.default)(props.domain) ? props.domain[axis] : props.domain;
var domain = propsDomain || _scale.default.getBaseScale(props, axis).domain();
var domain = propsDomain || Scale.getBaseScale(props, axis).domain();
var samples = props.samples || 1;

@@ -106,4 +116,4 @@ var domainMax = Math.max.apply(Math, _toConsumableArray(domain));

var scaleType = {
x: _scale.default.getScaleType(props, "x"),
y: _scale.default.getScaleType(props, "y")
x: Scale.getScaleType(props, "x"),
y: Scale.getScaleType(props, "y")
};

@@ -140,5 +150,40 @@

});
} // This method will remove data points that fall outside of the desired domain (non-continuous charts only)
} // Returns a data accessor given an eventKey prop
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if ((0, _isFunction2.default)(key)) {
return key;
} else if (key === null || key === undefined) {
return function () {
return undefined;
};
} // otherwise, assume it is an array index, property key or path (_.property handles all three)
return (0, _property2.default)(key);
} // Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
var hasEventKeyAccessor = !!props.eventKey;
var eventKeyAccessor = getEventKey(props.eventKey);
return data.map(function (datum, index) {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
var eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? (0, _assign2.default)({
eventKey: eventKey
}, datum) : datum;
} else {
return datum;
}
});
} // Exported Functions
// This method will remove data points that fall outside of the desired domain (non-continuous charts only)
function formatDataFromDomain(dataset, domain, defaultBaseline) {

@@ -149,10 +194,7 @@ var exists = function (val) {

var minDomainX = _collection.default.getMinValue(domain.x);
var minDomainX = Collection.getMinValue(domain.x);
var maxDomainX = Collection.getMaxValue(domain.x);
var minDomainY = Collection.getMinValue(domain.y);
var maxDomainY = Collection.getMaxValue(domain.y);
var maxDomainX = _collection.default.getMaxValue(domain.x);
var minDomainY = _collection.default.getMinValue(domain.y);
var maxDomainY = _collection.default.getMaxValue(domain.y);
var underMin = function (min) {

@@ -200,38 +242,3 @@ return function (val) {

});
} // Returns a data accessor given an eventKey prop
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if ((0, _isFunction2.default)(key)) {
return key;
} else if (key === null || key === undefined) {
return function () {
return undefined;
};
} // otherwise, assume it is an array index, property key or path (_.property handles all three)
return (0, _property2.default)(key);
} // Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
var hasEventKeyAccessor = !!props.eventKey;
var eventKeyAccessor = getEventKey(props.eventKey);
return data.map(function (datum, index) {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
var eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? (0, _assign2.default)({
eventKey: eventKey
}, datum) : datum;
} else {
return datum;
}
});
} // Exported Functions
}
/**

@@ -292,3 +299,3 @@ * Returns an object mapping string data to numeric data

function formatData(dataset, props, expectedKeys) {
var isArrayOrIterable = Array.isArray(dataset) || _immutable.default.isIterable(dataset);
var isArrayOrIterable = Array.isArray(dataset) || Immutable.isIterable(dataset);

@@ -303,3 +310,3 @@ if (!isArrayOrIterable || getLength(dataset) < 1) {

var createAccessor = function (name) {
return _helpers.default.createAccessor(props[name] !== undefined ? props[name] : name);
return Helpers.createAccessor(props[name] !== undefined ? props[name] : name);
};

@@ -436,3 +443,3 @@

});
return categoryStrings ? _collection.default.removeUndefined(categoryStrings) : [];
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
}

@@ -448,3 +455,3 @@ /**

function getStringsFromData(props, axis) {
var isArrayOrIterable = Array.isArray(props.data) || _immutable.default.isIterable(props.data);
var isArrayOrIterable = Array.isArray(props.data) || Immutable.isIterable(props.data);

@@ -456,6 +463,4 @@ if (!isArrayOrIterable) {

var key = props[axis] === undefined ? axis : props[axis];
var accessor = Helpers.createAccessor(key); // support immutable data
var accessor = _helpers.default.createAccessor(key); // support immutable data
var data = props.data.reduce(function (memo, d) {

@@ -504,17 +509,2 @@ memo.push(parseDatum(d));

return (0, _includes2.default)(whitelist, role);
}
var _default = {
createStringMap: createStringMap,
downsample: downsample,
formatData: formatData,
formatDataFromDomain: formatDataFromDomain,
generateData: generateData,
getCategories: getCategories,
getData: getData,
getStringsFromAxes: getStringsFromAxes,
getStringsFromCategories: getStringsFromCategories,
getStringsFromData: getStringsFromData,
isDataComponent: isDataComponent
};
exports.default = _default;
}

@@ -6,113 +6,114 @@ "use strict";

});
exports.default = void 0;
exports.continuousTransitions = continuousTransitions;
exports.continuousPolarTransitions = continuousPolarTransitions;
exports.discreteTransitions = discreteTransitions;
/* eslint-disable func-style */
var _default = {
continuousTransitions: function () {
return {
onLoad: {
duration: 2000
function continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
}
};
}
function continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: function () {
return {
_y: 0,
_y1: 0,
_y0: 0
};
},
onExit: {
duration: 500
after: function (datum) {
return {
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
},
onExit: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
},
onEnter: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
onEnter: {
duration: 500
after: function (datum) {
return {
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
};
},
continuousPolarTransitions: function () {
return {
onLoad: {
duration: 2000,
before: function () {
return {
_y: 0,
_y1: 0,
_y0: 0
};
},
after: function (datum) {
return {
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
},
onExit: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
}
};
}
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
function discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: function () {
return {
opacity: 0
};
},
onEnter: {
duration: 500,
before: function (datum, index, data) {
var adjacent = function (attr) {
var adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
after: function (datum) {
return {
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
};
}
after: function (datum) {
return datum;
}
};
},
discreteTransitions: function () {
return {
onLoad: {
duration: 2000,
before: function () {
return {
opacity: 0
};
},
after: function (datum) {
return datum;
}
},
onExit: {
duration: 600,
before: function () {
return {
opacity: 0
};
}
},
onEnter: {
duration: 600,
before: function () {
return {
opacity: 0
};
},
onExit: {
duration: 600,
before: function () {
return {
opacity: 0
};
}
},
onEnter: {
duration: 600,
before: function () {
return {
opacity: 0
};
},
after: function (datum) {
return datum;
}
after: function (datum) {
return datum;
}
};
}
};
exports.default = _default;
}
};
}

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

});
exports.default = void 0;
exports.createDomainFunction = createDomainFunction;
exports.formatDomain = formatDomain;
exports.getDomain = getDomain;
exports.getDomainFromCategories = getDomainFromCategories;
exports.getDomainFromData = getDomainFromData;
exports.getDomainFromMinMax = getDomainFromMinMax;
exports.getDomainFromProps = getDomainFromProps;
exports.getDomainWithZero = getDomainWithZero;
exports.getMaxFromProps = getMaxFromProps;
exports.getMinFromProps = getMinFromProps;
exports.getSymmetricDomain = getSymmetricDomain;
exports.isDomainComponent = isDomainComponent;

@@ -23,10 +34,12 @@ var _isDate2 = _interopRequireDefault(require("lodash/isDate"));

var _data = _interopRequireDefault(require("./data"));
var Data = _interopRequireWildcard(require("./data"));
var _scale = _interopRequireDefault(require("./scale"));
var Scale = _interopRequireWildcard(require("./scale"));
var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -44,3 +57,3 @@

function cleanDomain(domain, props, axis) {
var scaleType = _scale.default.getScaleType(props, axis);
var scaleType = Scale.getScaleType(props, axis);

@@ -114,10 +127,6 @@ if (scaleType !== "log") {

var min = _collection.default.getMinValue(domain);
var max = _collection.default.getMaxValue(domain);
var currentAxis = _helpers.default.getCurrentAxis(axis, props.horizontal);
var range = _helpers.default.getRange(props, currentAxis);
var min = Collection.getMinValue(domain);
var max = Collection.getMaxValue(domain);
var currentAxis = Helpers.getCurrentAxis(axis, props.horizontal);
var range = Helpers.getRange(props, currentAxis);
var rangeExtent = Math.abs(range[0] - range[1]);

@@ -193,4 +202,3 @@ var paddedRangeExtent = Math.max(rangeExtent - padding.left - padding.right, 1);

var categories = _data.default.getCategories(props, axis);
var categories = Data.getCategories(props, axis);
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFunction(props, axis);

@@ -233,3 +241,3 @@ return domain ? formatDomainFunction(domain, props, axis) : undefined;

function getDomainFromCategories(props, axis, categories) {
categories = categories || _data.default.getCategories(props, axis);
categories = categories || Data.getCategories(props, axis);
var polar = props.polar,

@@ -247,3 +255,3 @@ _props$startAngle = props.startAngle,

var maxDomain = getMaxFromProps(props, axis);
var stringArray = _collection.default.containsStrings(categories) ? _data.default.getStringsFromCategories(props, axis) : [];
var stringArray = Collection.containsStrings(categories) ? Data.getStringsFromCategories(props, axis) : [];
var stringMap = stringArray.length === 0 ? null : stringArray.reduce(function (memo, string, index) {

@@ -256,4 +264,4 @@ memo[string] = index + 1;

}) : categories;
var min = minDomain !== undefined ? minDomain : _collection.default.getMinValue(categoryValues);
var max = maxDomain !== undefined ? maxDomain : _collection.default.getMaxValue(categoryValues);
var min = minDomain !== undefined ? minDomain : Collection.getMinValue(categoryValues);
var max = maxDomain !== undefined ? maxDomain : Collection.getMaxValue(categoryValues);
var categoryDomain = getDomainFromMinMax(min, max);

@@ -272,3 +280,3 @@ return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(categoryDomain, categoryValues) : categoryDomain;

function getDomainFromData(props, axis, dataset) {
dataset = dataset || _data.default.getData(props);
dataset = dataset || Data.getData(props);
var polar = props.polar,

@@ -350,4 +358,3 @@ _props$startAngle2 = props.startAngle,

var dataset = _data.default.getData(props);
var dataset = Data.getData(props);
var y0Min = dataset.reduce(function (min, datum) {

@@ -365,4 +372,4 @@ return datum._y0 < min ? datum._y0 : min;

var minDomainProp = getMinFromProps(props, axis);
var max = maxDomainProp !== undefined ? maxDomainProp : _collection.default.getMaxValue(domain, defaultMin);
var min = minDomainProp !== undefined ? minDomainProp : _collection.default.getMinValue(domain, defaultMin);
var max = maxDomainProp !== undefined ? maxDomainProp : Collection.getMaxValue(domain, defaultMin);
var min = minDomainProp !== undefined ? minDomainProp : Collection.getMinValue(domain, defaultMin);
return getDomainFromMinMax(min, max);

@@ -449,18 +456,2 @@ };

return (0, _includes2.default)(whitelist, role);
}
var _default = {
createDomainFunction: createDomainFunction,
formatDomain: formatDomain,
getDomain: getDomain,
getDomainFromCategories: getDomainFromCategories,
getDomainFromData: getDomainFromData,
getDomainFromMinMax: getDomainFromMinMax,
getDomainFromProps: getDomainFromProps,
getDomainWithZero: getDomainWithZero,
getMaxFromProps: getMaxFromProps,
getMinFromProps: getMinFromProps,
getSymmetricDomain: getSymmetricDomain,
isDomainComponent: isDomainComponent
};
exports.default = _default;
}

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

});
exports.default = void 0;
exports.getEvents = getEvents;
exports.getScopedEvents = getScopedEvents;
exports.getPartialEvents = getPartialEvents;
exports.getEventState = getEventState;
exports.getExternalMutationsWithChildren = getExternalMutationsWithChildren;
exports.getExternalMutations = getExternalMutations;
exports.getExternalMutation = getExternalMutation;
exports.getComponentEvents = getComponentEvents;
exports.getGlobalEventNameFromKey = getGlobalEventNameFromKey;
exports.emulateReactEvent = exports.omitGlobalEvents = exports.getGlobalEvents = void 0;

@@ -40,431 +49,446 @@ var _keys2 = _interopRequireDefault(require("lodash/keys"));

var GLOBAL_EVENT_REGEX = /^onGlobal(.*)$/;
var _default = {
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params
getEvents: function (props, target, eventKey, getScopedEvents) {
var _this = this;
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params,no-shadow
// Returns all events that apply to a particular target element
var getEventsByTarget = function (events) {
var getSelectedEvents = function () {
var targetEvents = events.reduce(function (memo, event) {
if (event.target !== undefined) {
var matchesTarget = Array.isArray(event.target) ? (0, _includes2.default)(event.target, target) : "".concat(event.target) === "".concat(target);
return matchesTarget ? memo.concat(event) : memo;
}
function getEvents(props, target, eventKey, getScopedEvents) {
var _this = this;
return memo.concat(event);
}, []);
// Returns all events that apply to a particular target element
var getEventsByTarget = function (events) {
var getSelectedEvents = function () {
var targetEvents = events.reduce(function (memo, event) {
if (event.target !== undefined) {
var matchesTarget = Array.isArray(event.target) ? (0, _includes2.default)(event.target, target) : "".concat(event.target) === "".concat(target);
return matchesTarget ? memo.concat(event) : memo;
}
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter(function (obj) {
var targetKeys = obj.eventKey;
return memo.concat(event);
}, []);
var useKey = function (key) {
return key ? "".concat(key) === "".concat(eventKey) : true;
};
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter(function (obj) {
var targetKeys = obj.eventKey;
return Array.isArray(targetKeys) ? targetKeys.some(function (k) {
return useKey(k);
}) : useKey(targetKeys);
});
}
var useKey = function (key) {
return key ? "".concat(key) === "".concat(eventKey) : true;
};
return targetEvents;
};
return Array.isArray(targetKeys) ? targetKeys.some(function (k) {
return useKey(k);
}) : useKey(targetKeys);
});
}
var selectedEvents = getSelectedEvents();
return Array.isArray(selectedEvents) && selectedEvents.reduce(function (memo, event) {
return event ? (0, _assign6.default)(memo, event.eventHandlers) : memo;
}, {});
return targetEvents;
};
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
var selectedEvents = getSelectedEvents();
return Array.isArray(selectedEvents) && selectedEvents.reduce(function (memo, event) {
return event ? (0, _assign6.default)(memo, event.eventHandlers) : memo;
}, {});
};
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
var getAllEvents = function () {
if (Array.isArray(_this.componentEvents)) {
var _this$componentEvents;
return Array.isArray(props.events) ? (_this$componentEvents = _this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : _this.componentEvents;
}
var getAllEvents = function () {
if (Array.isArray(_this.componentEvents)) {
var _this$componentEvents;
return props.events;
};
return Array.isArray(props.events) ? (_this$componentEvents = _this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : _this.componentEvents;
}
var allEvents = getAllEvents();
var ownEvents = allEvents && (0, _isFunction2.default)(getScopedEvents) ? getScopedEvents(getEventsByTarget(allEvents), target) : undefined;
return props.events;
};
if (!props.sharedEvents) {
return ownEvents;
}
var allEvents = getAllEvents();
var ownEvents = allEvents && (0, _isFunction2.default)(getScopedEvents) ? getScopedEvents(getEventsByTarget(allEvents), target) : undefined;
var getSharedEvents = props.sharedEvents.getEvents;
var sharedEvents = props.sharedEvents.events && getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return (0, _assign6.default)({}, sharedEvents, ownEvents);
},
if (!props.sharedEvents) {
return ownEvents;
}
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
*/
// eslint-disable-next-line max-params
getScopedEvents: function (events, namespace, childType, baseProps) {
var _this2 = this;
var getSharedEvents = props.sharedEvents.getEvents;
var sharedEvents = props.sharedEvents.events && getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return (0, _assign6.default)({}, sharedEvents, ownEvents);
}
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
*/
// eslint-disable-next-line max-params
if ((0, _isEmpty2.default)(events)) {
return {};
}
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element
function getScopedEvents(events, namespace, childType, baseProps) {
var _this2 = this;
var getTargetProps = function (identifier, type) {
var childName = identifier.childName,
target = identifier.target,
key = identifier.key;
var baseType = type === "props" ? baseProps : _this2.state || {};
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
}; // Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
if ((0, _isEmpty2.default)(events)) {
return {};
}
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element
var parseEvent = function (eventReturn, eventKey) {
var childNames = namespace === "parent" ? eventReturn.childName : eventReturn.childName || childType;
var target = eventReturn.target || namespace; // returns all eventKeys to modify for a targeted childName
var getTargetProps = function (identifier, type) {
var childName = identifier.childName,
target = identifier.target,
key = identifier.key;
var baseType = type === "props" ? baseProps : _this2.state || {};
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
}; // Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
var getKeys = function (childName) {
if (target === "parent") {
return "parent";
var parseEvent = function (eventReturn, eventKey) {
var childNames = namespace === "parent" ? eventReturn.childName : eventReturn.childName || childType;
var target = eventReturn.target || namespace; // returns all eventKeys to modify for a targeted childName
var getKeys = function (childName) {
if (target === "parent") {
return "parent";
}
if (eventReturn.eventKey === "all") {
return baseProps[childName] ? (0, _without2.default)((0, _keys2.default)(baseProps[childName]), "parent") : (0, _without2.default)((0, _keys2.default)(baseProps), "parent");
} else if (eventReturn.eventKey === undefined && eventKey === "parent") {
return baseProps[childName] ? (0, _keys2.default)(baseProps[childName]) : (0, _keys2.default)(baseProps);
}
return eventReturn.eventKey !== undefined ? eventReturn.eventKey : eventKey;
}; // returns the state object with mutated props applied for a single key
var getMutationObject = function (key, childName) {
var baseState = _this2.state || {};
if (!(0, _isFunction2.default)(eventReturn.mutation)) {
return baseState;
}
var mutationTargetProps = getTargetProps({
childName: childName,
key: key,
target: target
}, "props");
var mutationTargetState = getTargetProps({
childName: childName,
key: key,
target: target
}, "state");
var mutatedProps = eventReturn.mutation((0, _assign6.default)({}, mutationTargetProps, mutationTargetState), baseProps);
var childState = baseState[childName] || {};
var filterState = function (state) {
if (state[key] && state[key][target]) {
delete state[key][target];
}
if (eventReturn.eventKey === "all") {
return baseProps[childName] ? (0, _without2.default)((0, _keys2.default)(baseProps[childName]), "parent") : (0, _without2.default)((0, _keys2.default)(baseProps), "parent");
} else if (eventReturn.eventKey === undefined && eventKey === "parent") {
return baseProps[childName] ? (0, _keys2.default)(baseProps[childName]) : (0, _keys2.default)(baseProps);
if (state[key] && !(0, _keys2.default)(state[key]).length) {
delete state[key];
}
return eventReturn.eventKey !== undefined ? eventReturn.eventKey : eventKey;
}; // returns the state object with mutated props applied for a single key
return state;
};
var extendState = function (state) {
return target === "parent" ? (0, _assign6.default)(state, _defineProperty({}, key, (0, _assign6.default)(state[key], mutatedProps))) : (0, _assign6.default)(state, _defineProperty({}, key, (0, _assign6.default)(state[key], _defineProperty({}, target, mutatedProps))));
};
var getMutationObject = function (key, childName) {
var baseState = _this2.state || {};
var updateState = function (state) {
return mutatedProps ? extendState(state) : filterState(state);
};
if (!(0, _isFunction2.default)(eventReturn.mutation)) {
return baseState;
}
return childName !== undefined && childName !== null ? (0, _assign6.default)(baseState, _defineProperty({}, childName, updateState(childState))) : updateState(baseState);
}; // returns entire mutated state for a given childName
var mutationTargetProps = getTargetProps({
childName: childName,
key: key,
target: target
}, "props");
var mutationTargetState = getTargetProps({
childName: childName,
key: key,
target: target
}, "state");
var mutatedProps = eventReturn.mutation((0, _assign6.default)({}, mutationTargetProps, mutationTargetState), baseProps);
var childState = baseState[childName] || {};
var filterState = function (state) {
if (state[key] && state[key][target]) {
delete state[key][target];
}
var getReturnByChild = function (childName) {
var mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys) ? mutationKeys.reduce(function (memo, key) {
return (0, _assign6.default)(memo, getMutationObject(key, childName));
}, {}) : getMutationObject(mutationKeys, childName);
}; // returns an entire mutated state for all children
if (state[key] && !(0, _keys2.default)(state[key]).length) {
delete state[key];
}
return state;
};
var allChildNames = childNames === "all" ? (0, _without2.default)((0, _keys2.default)(baseProps), "parent") : childNames;
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) {
return (0, _assign6.default)(memo, getReturnByChild(childName));
}, {}) : getReturnByChild(allChildNames);
}; // Parses an array of event returns into a single state mutation
var extendState = function (state) {
return target === "parent" ? (0, _assign6.default)(state, _defineProperty({}, key, (0, _assign6.default)(state[key], mutatedProps))) : (0, _assign6.default)(state, _defineProperty({}, key, (0, _assign6.default)(state[key], _defineProperty({}, target, mutatedProps))));
};
var updateState = function (state) {
return mutatedProps ? extendState(state) : filterState(state);
};
var parseEventReturn = function (eventReturn, eventKey) {
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) {
memo = (0, _assign6.default)({}, memo, parseEvent(props, eventKey));
return memo;
}, {}) : parseEvent(eventReturn, eventKey);
};
return childName !== undefined && childName !== null ? (0, _assign6.default)(baseState, _defineProperty({}, childName, updateState(childState))) : updateState(baseState);
}; // returns entire mutated state for a given childName
var compileCallbacks = function (eventReturn) {
var getCallback = function (obj) {
return (0, _isFunction2.default)(obj.callback) && obj.callback;
};
var callbacks = Array.isArray(eventReturn) ? eventReturn.map(function (evtObj) {
return getCallback(evtObj);
}) : [getCallback(eventReturn)];
var callbackArray = callbacks.filter(function (callback) {
return callback !== false;
});
return callbackArray.length ? function () {
return callbackArray.forEach(function (callback) {
return callback();
});
} : undefined;
}; // A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
var getReturnByChild = function (childName) {
var mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys) ? mutationKeys.reduce(function (memo, key) {
return (0, _assign6.default)(memo, getMutationObject(key, childName));
}, {}) : getMutationObject(mutationKeys, childName);
}; // returns an entire mutated state for all children
var onEvent = function (evt, childProps, eventKey, eventName) {
var eventReturn = events[eventName](evt, childProps, eventKey, _this2);
var allChildNames = childNames === "all" ? (0, _without2.default)((0, _keys2.default)(baseProps), "parent") : childNames;
return Array.isArray(allChildNames) ? allChildNames.reduce(function (memo, childName) {
return (0, _assign6.default)(memo, getReturnByChild(childName));
}, {}) : getReturnByChild(allChildNames);
}; // Parses an array of event returns into a single state mutation
if (!(0, _isEmpty2.default)(eventReturn)) {
var callbacks = compileCallbacks(eventReturn);
_this2.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
}; // returns a new events object with enhanced event handlers
var parseEventReturn = function (eventReturn, eventKey) {
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) {
memo = (0, _assign6.default)({}, memo, parseEvent(props, eventKey));
return memo;
}, {}) : parseEvent(eventReturn, eventKey);
};
var compileCallbacks = function (eventReturn) {
var getCallback = function (obj) {
return (0, _isFunction2.default)(obj.callback) && obj.callback;
};
return (0, _keys2.default)(events).reduce(function (memo, event) {
memo[event] = onEvent;
return memo;
}, {});
}
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
var callbacks = Array.isArray(eventReturn) ? eventReturn.map(function (evtObj) {
return getCallback(evtObj);
}) : [getCallback(eventReturn)];
var callbackArray = callbacks.filter(function (callback) {
return callback !== false;
});
return callbackArray.length ? function () {
return callbackArray.forEach(function (callback) {
return callback();
});
} : undefined;
}; // A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
function getPartialEvents(events, eventKey, childProps) {
return events ? (0, _keys2.default)(events).reduce(function (memo, eventName) {
var appliedEvent = function (evt) {
return events[eventName](evt, childProps, eventKey, eventName);
};
var onEvent = function (evt, childProps, eventKey, eventName) {
var eventReturn = events[eventName](evt, childProps, eventKey, _this2);
memo[eventName] = appliedEvent;
return memo;
}, {}) : {};
}
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
if (!(0, _isEmpty2.default)(eventReturn)) {
var callbacks = compileCallbacks(eventReturn);
_this2.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
}; // returns a new events object with enhanced event handlers
function getEventState(eventKey, namespace, childType) {
var state = this.state || {};
if (!childType) {
return eventKey === "parent" ? state[eventKey] && state[eventKey][namespace] || state[eventKey] : state[eventKey] && state[eventKey][namespace];
}
return (0, _keys2.default)(events).reduce(function (memo, event) {
memo[event] = onEvent;
return memo;
}, {});
},
return state[childType] && state[childType][eventKey] && state[childType][eventKey][namespace];
}
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
getPartialEvents: function (events, eventKey, childProps) {
return events ? (0, _keys2.default)(events).reduce(function (memo, eventName) {
var appliedEvent = function (evt) {
return events[eventName](evt, childProps, eventKey, eventName);
};
memo[eventName] = appliedEvent;
return memo;
}, {}) : {};
},
function getExternalMutationsWithChildren(mutations, baseProps, baseState, childNames) {
var _this3 = this;
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
getEventState: function (eventKey, namespace, childType) {
var state = this.state || {};
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce(function (memo, childName) {
var childState = baseState[childName];
if (!childType) {
return eventKey === "parent" ? state[eventKey] && state[eventKey][namespace] || state[eventKey] : state[eventKey] && state[eventKey][namespace];
}
var mutation = _this3.getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
return state[childType] && state[childType][eventKey] && state[childType][eventKey][namespace];
},
memo[childName] = mutation ? mutation : childState;
return (0, _pickBy2.default)(memo, function (v) {
return !(0, _isEmpty2.default)(v);
});
}, {});
}
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
getExternalMutationsWithChildren: function (mutations, baseProps, baseState, childNames) {
var _this3 = this;
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce(function (memo, childName) {
var childState = baseState[childName];
function getExternalMutations(mutations, baseProps, baseState, childName) {
var _this4 = this;
var mutation = _this3.getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
baseProps = baseProps || {};
baseState = baseState || {};
var eventKeys = (0, _keys2.default)(baseProps);
return eventKeys.reduce(function (memo, eventKey) {
var keyState = baseState[eventKey] || {};
var keyProps = baseProps[eventKey] || {};
memo[childName] = mutation ? mutation : childState;
return (0, _pickBy2.default)(memo, function (v) {
return !(0, _isEmpty2.default)(v);
});
}, {});
},
if (eventKey === "parent") {
var identifier = {
eventKey: eventKey,
target: "parent"
};
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
getExternalMutations: function (mutations, baseProps, baseState, childName) {
var _this4 = this;
var mutation = _this4.getExternalMutation(mutations, keyProps, keyState, identifier);
baseProps = baseProps || {};
baseState = baseState || {};
var eventKeys = (0, _keys2.default)(baseProps);
return eventKeys.reduce(function (memo, eventKey) {
var keyState = baseState[eventKey] || {};
var keyProps = baseProps[eventKey] || {};
if (eventKey === "parent") {
memo[eventKey] = mutation !== undefined ? (0, _assign6.default)({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
var targets = (0, _uniq2.default)((0, _keys2.default)(keyProps).concat((0, _keys2.default)(keyState)));
memo[eventKey] = targets.reduce(function (m, target) {
var identifier = {
eventKey: eventKey,
target: "parent"
target: target,
childName: childName
};
var mutation = _this4.getExternalMutation(mutations, keyProps, keyState, identifier);
var mutation = _this4.getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
memo[eventKey] = mutation !== undefined ? (0, _assign6.default)({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
var targets = (0, _uniq2.default)((0, _keys2.default)(keyProps).concat((0, _keys2.default)(keyState)));
memo[eventKey] = targets.reduce(function (m, target) {
var identifier = {
eventKey: eventKey,
target: target,
childName: childName
};
m[target] = mutation !== undefined ? (0, _assign6.default)({}, keyState[target], mutation) : keyState[target];
return (0, _pickBy2.default)(m, function (v) {
return !(0, _isEmpty2.default)(v);
});
}, {});
}
var mutation = _this4.getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
return (0, _pickBy2.default)(memo, function (v) {
return !(0, _isEmpty2.default)(v);
});
}, {});
}
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
m[target] = mutation !== undefined ? (0, _assign6.default)({}, keyState[target], mutation) : keyState[target];
return (0, _pickBy2.default)(m, function (v) {
return !(0, _isEmpty2.default)(v);
});
}, {});
}
return (0, _pickBy2.default)(memo, function (v) {
return !(0, _isEmpty2.default)(v);
function getExternalMutation(mutations, baseProps, baseState, identifier) {
var filterMutations = function (mutation, type) {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
var stringArray = mutation[type].map(function (m) {
return "".concat(m);
});
}, {});
},
return (0, _includes2.default)(stringArray, identifier[type]);
} else {
return false;
}
};
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
getExternalMutation: function (mutations, baseProps, baseState, identifier) {
var filterMutations = function (mutation, type) {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
var stringArray = mutation[type].map(function (m) {
return "".concat(m);
});
return (0, _includes2.default)(stringArray, identifier[type]);
} else {
return false;
}
};
mutations = Array.isArray(mutations) ? mutations : [mutations];
var scopedMutations = mutations;
mutations = Array.isArray(mutations) ? mutations : [mutations];
var scopedMutations = mutations;
if (identifier.childName) {
scopedMutations = mutations.filter(function (m) {
return filterMutations(m, "childName");
});
} // find any mutation objects that match the target
if (identifier.childName) {
scopedMutations = mutations.filter(function (m) {
return filterMutations(m, "childName");
});
} // find any mutation objects that match the target
var targetMutations = scopedMutations.filter(function (m) {
return filterMutations(m, "target");
});
var targetMutations = scopedMutations.filter(function (m) {
return filterMutations(m, "target");
});
if ((0, _isEmpty2.default)(targetMutations)) {
return undefined;
}
if ((0, _isEmpty2.default)(targetMutations)) {
return undefined;
}
var keyMutations = targetMutations.filter(function (m) {
return filterMutations(m, "eventKey");
});
var keyMutations = targetMutations.filter(function (m) {
return filterMutations(m, "eventKey");
});
if ((0, _isEmpty2.default)(keyMutations)) {
return undefined;
}
if ((0, _isEmpty2.default)(keyMutations)) {
return keyMutations.reduce(function (memo, curr) {
var mutationFunction = curr && (0, _isFunction2.default)(curr.mutation) ? curr.mutation : function () {
return undefined;
}
};
var currentMutation = mutationFunction((0, _assign6.default)({}, baseProps, baseState));
return (0, _assign6.default)({}, memo, currentMutation);
}, {});
}
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
return keyMutations.reduce(function (memo, curr) {
var mutationFunction = curr && (0, _isFunction2.default)(curr.mutation) ? curr.mutation : function () {
return undefined;
};
var currentMutation = mutationFunction((0, _assign6.default)({}, baseProps, baseState));
return (0, _assign6.default)({}, memo, currentMutation);
}, {});
},
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
getComponentEvents: function (props, components) {
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
var _memo;
function getComponentEvents(props, components) {
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
var _memo;
var component = props[componentName];
var defaultEvents = component && component.type && component.type.defaultEvents;
var componentEvents = (0, _isFunction2.default)(defaultEvents) ? defaultEvents(component.props) : defaultEvents;
memo = Array.isArray(componentEvents) ? (_memo = memo).concat.apply(_memo, _toConsumableArray(componentEvents)) : memo;
return memo;
}, []);
return events && events.length ? events : undefined;
},
getGlobalEventNameFromKey: function (key) {
var match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
},
getGlobalEvents: function (events) {
return (0, _pickBy2.default)(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
},
omitGlobalEvents: function (events) {
return (0, _omitBy2.default)(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
},
emulateReactEvent: function (event) {
return (0, _assign6.default)(event, {
nativeEvent: event
});
}
var component = props[componentName];
var defaultEvents = component && component.type && component.type.defaultEvents;
var componentEvents = (0, _isFunction2.default)(defaultEvents) ? defaultEvents(component.props) : defaultEvents;
memo = Array.isArray(componentEvents) ? (_memo = memo).concat.apply(_memo, _toConsumableArray(componentEvents)) : memo;
return memo;
}, []);
return events && events.length ? events : undefined;
}
function getGlobalEventNameFromKey(key) {
var match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
}
var getGlobalEvents = function (events) {
return (0, _pickBy2.default)(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
};
exports.default = _default;
exports.getGlobalEvents = getGlobalEvents;
var omitGlobalEvents = function (events) {
return (0, _omitBy2.default)(events, function (_, key) {
return GLOBAL_EVENT_REGEX.test(key);
});
};
exports.omitGlobalEvents = omitGlobalEvents;
var emulateReactEvent = function (event) {
return (0, _assign6.default)(event, {
nativeEvent: event
});
};
exports.emulateReactEvent = emulateReactEvent;

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

});
exports.default = void 0;
exports.omit = omit;
exports.getPoint = getPoint;
exports.scalePoint = scalePoint;
exports.getPadding = getPadding;
exports.isTooltip = isTooltip;
exports.getDefaultStyles = getDefaultStyles;
exports.getStyles = getStyles;
exports.evaluateProp = evaluateProp;
exports.evaluateStyle = evaluateStyle;
exports.degreesToRadians = degreesToRadians;
exports.radiansToDegrees = radiansToDegrees;
exports.getRadius = getRadius;
exports.getPolarOrigin = getPolarOrigin;
exports.getRange = getRange;
exports.createAccessor = createAccessor;
exports.modifyProps = modifyProps;
exports.getCurrentAxis = getCurrentAxis;
exports.reduceChildren = reduceChildren;
exports.isHorizontal = isHorizontal;

@@ -378,25 +396,2 @@ var _keys2 = _interopRequireDefault(require("lodash/keys"));

return traverseChildren(_react.default.Children.toArray(props.children));
}
var _default = {
omit: omit,
getPoint: getPoint,
scalePoint: scalePoint,
getPadding: getPadding,
getDefaultStyles: getDefaultStyles,
getStyles: getStyles,
evaluateProp: evaluateProp,
evaluateStyle: evaluateStyle,
degreesToRadians: degreesToRadians,
radiansToDegrees: radiansToDegrees,
getRadius: getRadius,
getPolarOrigin: getPolarOrigin,
getRange: getRange,
createAccessor: createAccessor,
modifyProps: modifyProps,
getCurrentAxis: getCurrentAxis,
reduceChildren: reduceChildren,
isHorizontal: isHorizontal,
isTooltip: isTooltip
};
exports.default = _default;
}

@@ -6,36 +6,49 @@ "use strict";

});
exports.default = void 0;
var _default = {
IMMUTABLE_ITERABLE: "@@__IMMUTABLE_ITERABLE__@@",
IMMUTABLE_RECORD: "@@__IMMUTABLE_RECORD__@@",
IMMUTABLE_LIST: "@@__IMMUTABLE_LIST__@@",
IMMUTABLE_MAP: "@@__IMMUTABLE_MAP__@@",
isImmutable: function (x) {
return this.isIterable(x) || this.isRecord(x);
},
isIterable: function (x) {
return !!(x && x[this.IMMUTABLE_ITERABLE]);
},
isRecord: function (x) {
return !!(x && x[this.IMMUTABLE_RECORD]);
},
isList: function (x) {
return !!(x && x[this.IMMUTABLE_LIST]);
},
isMap: function (x) {
return !!(x && x[this.IMMUTABLE_MAP]);
},
shallowToJS: function (x, whitelist) {
var _this = this;
exports.isIterable = isIterable;
exports.isRecord = isRecord;
exports.isImmutable = isImmutable;
exports.isList = isList;
exports.isMap = isMap;
exports.shallowToJS = shallowToJS;
exports.IMMUTABLE_MAP = exports.IMMUTABLE_LIST = exports.IMMUTABLE_RECORD = exports.IMMUTABLE_ITERABLE = void 0;
return this.isIterable(x) ? x.reduce(function (prev, curr, key) {
if (whitelist && whitelist[key]) {
curr = _this.shallowToJS(curr);
}
/* eslint-disable func-style */
var IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
exports.IMMUTABLE_ITERABLE = IMMUTABLE_ITERABLE;
var IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
exports.IMMUTABLE_RECORD = IMMUTABLE_RECORD;
var IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
exports.IMMUTABLE_LIST = IMMUTABLE_LIST;
var IMMUTABLE_MAP = "@@__IMMUTABLE_MAP__@@";
exports.IMMUTABLE_MAP = IMMUTABLE_MAP;
prev[key] = curr;
return prev;
}, this.isList(x) ? [] : {}) : x;
}
};
exports.default = _default;
function isIterable(x) {
return !!(x && x[IMMUTABLE_ITERABLE]);
}
function isRecord(x) {
return !!(x && x[IMMUTABLE_RECORD]);
}
function isImmutable(x) {
return isIterable(x) || isRecord(x);
}
function isList(x) {
return !!(x && x[IMMUTABLE_LIST]);
}
function isMap(x) {
return !!(x && x[IMMUTABLE_MAP]);
}
function shallowToJS(x, whitelist) {
return isIterable(x) ? x.reduce(function (prev, curr, key) {
if (whitelist && whitelist[key]) {
curr = shallowToJS(curr);
}
prev[key] = curr;
return prev;
}, isList(x) ? [] : {}) : x;
}

@@ -6,8 +6,15 @@ "use strict";

});
exports.default = void 0;
exports.getText = getText;
exports.getPolarTextAnchor = getPolarTextAnchor;
exports.getPolarVerticalAnchor = getPolarVerticalAnchor;
exports.getPolarAngle = getPolarAngle;
exports.getDegrees = getDegrees;
exports.getProps = getProps;
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -60,3 +67,3 @@

var labelStyle = style.labels || {};
var defaultPadding = _helpers.default.evaluateProp(labelStyle.padding, props) || 0;
var defaultPadding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
var sign = datum._y < 0 ? -1 : 1;

@@ -84,3 +91,3 @@ return {

var _Helpers$scalePoint = _helpers.default.scalePoint(props, datum),
var _Helpers$scalePoint = Helpers.scalePoint(props, datum),
x = _Helpers$scalePoint.x,

@@ -107,6 +114,4 @@ y = _Helpers$scalePoint.y;

var labelStyle = style.labels || {};
var padding = _helpers.default.evaluateProp(labelStyle.padding, props) || 0;
var angle = _helpers.default.degreesToRadians(degrees);
var padding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
var angle = Helpers.degreesToRadians(degrees);
return {

@@ -196,6 +201,6 @@ x: padding * Math.cos(angle),

function getDegrees(props, datum) {
var _Helpers$getPoint = _helpers.default.getPoint(datum),
var _Helpers$getPoint = Helpers.getPoint(datum),
x = _Helpers$getPoint.x;
return _helpers.default.radiansToDegrees(props.scale.x(x)) % 360;
return Helpers.radiansToDegrees(props.scale.x(x)) % 360;
}

@@ -252,3 +257,3 @@

if (!_helpers.default.isTooltip(labelComponent)) {
if (!Helpers.isTooltip(labelComponent)) {
return labelProps;

@@ -258,13 +263,3 @@ }

var tooltipTheme = theme && theme.tooltip || {};
return (0, _defaults2.default)({}, labelProps, _helpers.default.omit(tooltipTheme, ["style"]));
}
var _default = {
getText: getText,
getPolarTextAnchor: getPolarTextAnchor,
getPolarVerticalAnchor: getPolarVerticalAnchor,
getPolarAngle: getPolarAngle,
getDegrees: getDegrees,
getProps: getProps
};
exports.default = _default;
return (0, _defaults2.default)({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
}

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

});
exports.default = void 0;
exports.warn = warn;

@@ -13,11 +13,9 @@ /* global console */

// TODO: Use "warning" npm module like React is switching to.
var _default = {
warn: function (message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
// eslint-disable-next-line func-style
function warn(message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
}
};
exports.default = _default;
}

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

});
exports.default = void 0;
exports.deprecated = deprecated;
exports.allOfType = allOfType;
exports.regExp = exports.matchDataLength = exports.homogeneousArray = exports.scale = exports.domain = exports.greaterThanZero = exports.integer = exports.nonNegative = void 0;

@@ -15,6 +17,8 @@ var _isRegExp2 = _interopRequireDefault(require("lodash/isRegExp"));

var _log = _interopRequireDefault(require("./log"));
var Log = _interopRequireWildcard(require("./log"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -99,169 +103,177 @@

};
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
var _default = {
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
deprecated: function (propType, explanation) {
return function (props, propName, componentName) {
var value = props[propName];
if (value !== null && value !== undefined) {
_log.default.warn("\"".concat(propName, "\" property of \"").concat(componentName, "\" has been deprecated ").concat(explanation));
}
function deprecated(propType, explanation) {
return function (props, propName, componentName) {
var value = props[propName];
return _propTypes.default.checkPropTypes(_defineProperty({}, propName, propType), props, propName, componentName);
};
},
if (value !== null && value !== undefined) {
Log.warn("\"".concat(propName, "\" property of \"").concat(componentName, "\" has been deprecated ").concat(explanation));
}
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
allOfType: function (validators) {
return makeChainable(function (props, propName, componentName) {
for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
rest[_key2 - 3] = arguments[_key2];
}
return _propTypes.default.checkPropTypes(_defineProperty({}, propName, propType), props, propName, componentName);
};
}
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
return validators.reduce(function (result, validator) {
return result || validator.apply(void 0, [props, propName, componentName].concat(rest));
}, undefined);
});
},
/**
* Check that the value is a non-negative number.
*/
nonNegative: makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (typeof value !== "number" || value < 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a non-negative number."));
function allOfType(validators) {
return makeChainable(function (props, propName, componentName) {
for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
rest[_key2 - 3] = arguments[_key2];
}
return undefined;
}),
return validators.reduce(function (result, validator) {
return result || validator.apply(void 0, [props, propName, componentName].concat(rest));
}, undefined);
});
}
/**
* Check that the value is a non-negative number.
*/
/**
* Check that the value is an integer.
*/
integer: makeChainable(function (props, propName, componentName) {
var value = props[propName];
if (typeof value !== "number" || value % 1 !== 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an integer."));
}
var nonNegative = makeChainable(function (props, propName, componentName) {
var value = props[propName];
return undefined;
}),
if (typeof value !== "number" || value < 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a non-negative number."));
}
/**
* Check that the value is greater than zero.
*/
greaterThanZero: makeChainable(function (props, propName, componentName) {
var value = props[propName];
return undefined;
});
/**
* Check that the value is an integer.
*/
if (typeof value !== "number" || value <= 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a number greater than zero."));
}
exports.nonNegative = nonNegative;
var integer = makeChainable(function (props, propName, componentName) {
var value = props[propName];
return undefined;
}),
if (typeof value !== "number" || value % 1 !== 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an integer."));
}
/**
* Check that the value is an Array of two unique values.
*/
domain: makeChainable(function (props, propName, componentName) {
var value = props[propName];
return undefined;
});
/**
* Check that the value is greater than zero.
*/
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array of two unique numeric values."));
}
exports.integer = integer;
var greaterThanZero = makeChainable(function (props, propName, componentName) {
var value = props[propName];
return undefined;
}),
if (typeof value !== "number" || value <= 0) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a number greater than zero."));
}
/**
* Check that the value looks like a d3 `scale` function.
*/
scale: makeChainable(function (props, propName, componentName) {
var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
return undefined;
});
/**
* Check that the value is an Array of two unique values.
*/
var validScale = function (scl) {
if ((0, _isFunction2.default)(scl)) {
return (0, _isFunction2.default)(scl.copy) && (0, _isFunction2.default)(scl.domain) && (0, _isFunction2.default)(scl.range);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
exports.greaterThanZero = greaterThanZero;
var domain = makeChainable(function (props, propName, componentName) {
var value = props[propName];
return false;
};
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array of two unique numeric values."));
}
var value = props[propName];
return undefined;
});
/**
* Check that the value looks like a d3 `scale` function.
*/
if (!validScale(value)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a d3 scale."));
exports.domain = domain;
var scale = makeChainable(function (props, propName, componentName) {
var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
var validScale = function (scl) {
if ((0, _isFunction2.default)(scl)) {
return (0, _isFunction2.default)(scl.copy) && (0, _isFunction2.default)(scl.domain) && (0, _isFunction2.default)(scl.range);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
return undefined;
}),
return false;
};
/**
* Check that an array contains items of the same type.
*/
homogeneousArray: makeChainable(function (props, propName, componentName) {
var values = props[propName];
var value = props[propName];
if (!Array.isArray(values)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array."));
}
if (!validScale(value)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a d3 scale."));
}
if (values.length < 2) {
return undefined;
}
return undefined;
});
/**
* Check that an array contains items of the same type.
*/
var comparisonConstructor = getConstructor(values[0]);
var typeMismatchedValue = (0, _find2.default)(values, function (value) {
return comparisonConstructor !== getConstructor(value);
});
exports.scale = scale;
var homogeneousArray = makeChainable(function (props, propName, componentName) {
var values = props[propName];
if (typeMismatchedValue) {
var constructorName = getConstructorName(values[0]);
var otherConstructorName = getConstructorName(typeMismatchedValue);
return new Error("Expected `".concat(propName, "` in `").concat(componentName, "` to be a ") + "homogeneous array, but found types `".concat(constructorName, "` and ") + "`".concat(otherConstructorName, "`."));
}
if (!Array.isArray(values)) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be an array."));
}
if (values.length < 2) {
return undefined;
}),
}
/**
* Check that array prop length matches props.data.length
*/
matchDataLength: makeChainable(function (props, propName) {
if (props[propName] && Array.isArray(props[propName]) && props[propName].length !== props.data.length) {
return new Error("Length of data and ".concat(propName, " arrays must match."));
}
var comparisonConstructor = getConstructor(values[0]);
var typeMismatchedValue = (0, _find2.default)(values, function (value) {
return comparisonConstructor !== getConstructor(value);
});
return undefined;
}),
if (typeMismatchedValue) {
var constructorName = getConstructorName(values[0]);
var otherConstructorName = getConstructorName(typeMismatchedValue);
return new Error("Expected `".concat(propName, "` in `").concat(componentName, "` to be a ") + "homogeneous array, but found types `".concat(constructorName, "` and ") + "`".concat(otherConstructorName, "`."));
}
/**
* Check that the value is a regular expression
*/
regExp: makeChainable(function (props, propName, componentName) {
if (props[propName] && !(0, _isRegExp2.default)(props[propName])) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a regular expression."));
}
return undefined;
});
/**
* Check that array prop length matches props.data.length
*/
return undefined;
})
};
exports.default = _default;
exports.homogeneousArray = homogeneousArray;
var matchDataLength = makeChainable(function (props, propName) {
if (props[propName] && Array.isArray(props[propName]) && props[propName].length !== props.data.length) {
return new Error("Length of data and ".concat(propName, " arrays must match."));
}
return undefined;
});
/**
* Check that the value is a regular expression
*/
exports.matchDataLength = matchDataLength;
var regExp = makeChainable(function (props, propName, componentName) {
if (props[propName] && !(0, _isRegExp2.default)(props[propName])) {
return new Error("`".concat(propName, "` in `").concat(componentName, "` must be a regular expression."));
}
return undefined;
});
exports.regExp = regExp;

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

});
exports.default = void 0;
exports.getScaleFromName = getScaleFromName;
exports.getBaseScale = getBaseScale;
exports.getDefaultScale = getDefaultScale;
exports.getScaleFromProps = getScaleFromProps;
exports.getScaleType = getScaleType;
exports.getType = getType;

@@ -15,5 +20,5 @@ var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));

var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));

@@ -79,3 +84,3 @@ var d3Scale = _interopRequireWildcard(require("d3-scale"));

return _collection.default.containsDates(domain) ? "time" : "linear";
return Collection.containsDates(domain) ? "time" : "linear";
}

@@ -88,4 +93,3 @@

var accessor = _helpers.default.createAccessor(props[axis]);
var accessor = Helpers.createAccessor(props[axis]);
var axisData = props.data.map(function (datum) {

@@ -95,3 +99,3 @@ var processedData = (0, _isPlainObject2.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);

});
return _collection.default.containsDates(axisData) ? "time" : "linear";
return Collection.containsDates(axisData) ? "time" : "linear";
} // Exported Functions

@@ -163,12 +167,2 @@

return scaleType ? scaleType.name : undefined;
}
var _default = {
getBaseScale: getBaseScale,
getDefaultScale: getDefaultScale,
getScaleFromProps: getScaleFromProps,
getScaleType: getScaleType,
getType: getType,
getScaleFromName: getScaleFromName
};
exports.default = _default;
}

@@ -6,7 +6,11 @@ "use strict";

});
exports.default = void 0;
exports.getParentSVG = getParentSVG;
exports.getSVGEventCoordinates = getSVGEventCoordinates;
exports.getDomainCoordinates = getDomainCoordinates;
exports.getDataCoordinates = getDataCoordinates;
exports.getBounds = getBounds;
var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

@@ -114,3 +118,3 @@ /* eslint-disable func-style */

var makeBound = function (a, b) {
return [_collection.default.getMinValue([a, b]), _collection.default.getMaxValue([a, b])];
return [Collection.getMinValue([a, b]), Collection.getMaxValue([a, b])];
};

@@ -122,11 +126,2 @@

};
}
var _default = {
getParentSVG: getParentSVG,
getSVGEventCoordinates: getSVGEventCoordinates,
getDomainCoordinates: getDomainCoordinates,
getDataCoordinates: getDataCoordinates,
getBounds: getBounds
};
exports.default = _default;
}

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

});
exports.default = void 0;
exports.getColorScale = getColorScale;
exports.toTransformString = void 0;
/* eslint-disable func-style */
/**

@@ -44,27 +47,25 @@ * Given an object with CSS/SVG transform definitions, return the string value

};
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
var _default = {
toTransformString: toTransformString,
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
getColorScale: function (name) {
var scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}
};
exports.default = _default;
exports.toTransformString = toTransformString;
function getColorScale(name) {
var scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}

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

});
exports.default = void 0;
exports.approximateTextSize = exports._approximateTextSizeInternal = exports.convertLengthToPixels = void 0;

@@ -209,2 +209,4 @@ var _defaults2 = _interopRequireDefault(require("lodash/defaults"));

exports.convertLengthToPixels = convertLengthToPixels;
var _prepareParams = function (inputStyle, index) {

@@ -258,2 +260,20 @@ var lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;

}, 0);
}; // Stubbable implementation.
var _approximateTextSizeInternal = {
impl: function (text, style) {
var angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
var height = _approximateTextHeightInternal(text, style);
var width = _approximateTextWidthInternal(text, style);
var widthWithRotate = angle ? _getSizeWithRotate(width, height, angle) : width;
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
}
};

@@ -272,22 +292,8 @@ /**

exports._approximateTextSizeInternal = _approximateTextSizeInternal;
var approximateTextSize = function (text, style) {
var angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
var height = _approximateTextHeightInternal(text, style);
var width = _approximateTextWidthInternal(text, style);
var widthWithRotate = angle ? _getSizeWithRotate(width, height, angle) : width;
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
return _approximateTextSizeInternal.impl(text, style);
};
var _default = {
approximateTextSize: approximateTextSize,
convertLengthToPixels: convertLengthToPixels
};
exports.default = _default;
exports.approximateTextSize = approximateTextSize;

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

});
exports.default = void 0;
exports.getInitialTransitionState = getInitialTransitionState;
exports.getTransitionPropsFactory = getTransitionPropsFactory;

@@ -419,8 +420,2 @@ var _keys2 = _interopRequireDefault(require("lodash/keys"));

};
}
var _default = {
getInitialTransitionState: getInitialTransitionState,
getTransitionPropsFactory: getTransitionPropsFactory
};
exports.default = _default;
}

@@ -30,22 +30,24 @@ "use strict";

var _axis = _interopRequireDefault(require("./axis"));
var Axis = _interopRequireWildcard(require("./axis"));
var _style = _interopRequireDefault(require("./style"));
var Style = _interopRequireWildcard(require("./style"));
var _transitions = _interopRequireDefault(require("./transitions"));
var Transitions = _interopRequireWildcard(require("./transitions"));
var _data = _interopRequireDefault(require("./data"));
var Data = _interopRequireWildcard(require("./data"));
var _domain = _interopRequireDefault(require("./domain"));
var Domain = _interopRequireWildcard(require("./domain"));
var _events = _interopRequireDefault(require("./events"));
var Events = _interopRequireWildcard(require("./events"));
var _collection = _interopRequireDefault(require("./collection"));
var Collection = _interopRequireWildcard(require("./collection"));
var _helpers = _interopRequireDefault(require("./helpers"));
var Helpers = _interopRequireWildcard(require("./helpers"));
var _scale = _interopRequireDefault(require("./scale"));
var Scale = _interopRequireWildcard(require("./scale"));
var _log = _interopRequireDefault(require("./log"));
var Log = _interopRequireWildcard(require("./log"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -68,3 +70,3 @@

if (props.data) {
return _data.default.getData(props);
return Data.getData(props);
}

@@ -123,5 +125,3 @@

childComponents = childComponents || _react.default.Children.toArray(props.children);
var propsDomain = _domain.default.getDomainFromProps(props, axis);
var propsDomain = Domain.getDomainFromProps(props, axis);
var domainPadding = this.getDefaultDomainPadding(props, axis, childComponents);

@@ -133,19 +133,13 @@ var domain;

} else {
var minDomain = _domain.default.getMinFromProps(props, axis);
var maxDomain = _domain.default.getMaxFromProps(props, axis);
var dataset = (props.data || props.y) && _data.default.getData(props);
var dataDomain = dataset ? _domain.default.getDomainFromData(props, axis, dataset) : [];
var minDomain = Domain.getMinFromProps(props, axis);
var maxDomain = Domain.getMaxFromProps(props, axis);
var dataset = (props.data || props.y) && Data.getData(props);
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
var childDomain = this.getDomainFromChildren(props, axis, childComponents);
var min = minDomain || _collection.default.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
var max = maxDomain || _collection.default.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
domain = _domain.default.getDomainFromMinMax(min, max);
var min = minDomain || Collection.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
var max = maxDomain || Collection.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
domain = Domain.getDomainFromMinMax(min, max);
}
return _domain.default.formatDomain(domain, (0, _assign2.default)({
return Domain.formatDomain(domain, (0, _assign2.default)({
domainPadding: domainPadding

@@ -156,3 +150,3 @@ }, props), axis);

if (props.data) {
return _scale.default.getBaseScale(props, axis);
return Scale.getBaseScale(props, axis);
}

@@ -166,8 +160,8 @@

});
return _scale.default.getScaleType(sharedProps, axis);
return Scale.getScaleType(sharedProps, axis);
};
var childScale = (0, _uniq2.default)(_helpers.default.reduceChildren(children, iteratee, props)); // default to linear scale if more than one uniq scale type is given by children
var childScale = (0, _uniq2.default)(Helpers.reduceChildren(children, iteratee, props)); // default to linear scale if more than one uniq scale type is given by children
return childScale.length > 1 ? _scale.default.getScaleFromName("linear") : _scale.default.getScaleFromName(childScale[0]);
return childScale.length > 1 ? Scale.getScaleFromName("linear") : Scale.getScaleFromName(childScale[0]);
},

@@ -203,3 +197,3 @@ setAnimationState: function (props, nextProps) {

var _Transitions$getIniti = _transitions.default.getInitialTransitionState(oldChildren, nextChildren),
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
_nodesWillExit = _Transitions$getIniti.nodesWillExit,

@@ -214,3 +208,3 @@ nodesWillEnter = _Transitions$getIniti.nodesWillEnter,

nodesShouldEnter: nodesShouldEnter,
childrenTransitions: _collection.default.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
oldProps: _nodesWillExit ? props : null,

@@ -224,3 +218,3 @@ nextProps: nextProps,

var components = ["groupComponent", "containerComponent", "labelComponent"];
this.componentEvents = _events.default.getComponentEvents(props, components);
this.componentEvents = Events.getComponentEvents(props, components);
var events = props.events;

@@ -245,3 +239,3 @@

var childrenTransitions = _this.state && _this.state.childrenTransitions;
childrenTransitions = _collection.default.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
return (0, _defaults2.default)({

@@ -257,3 +251,3 @@ childrenTransitions: childrenTransitions

if (!getTransitions) {
var getTransitionProps = _transitions.default.getTransitionPropsFactory(props, state, function (newState) {
var getTransitionProps = Transitions.getTransitionPropsFactory(props, state, function (newState) {
return _this.setState(newState);

@@ -275,3 +269,3 @@ });

var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
var parentData = props.data ? _data.default.getData(props, axis) : undefined;
var parentData = props.data ? Data.getData(props, axis) : undefined;
var polar = props.polar,

@@ -300,3 +294,3 @@ startAngle = props.startAngle,

if (!_domain.default.isDomainComponent(child)) {
if (!Domain.isDomainComponent(child)) {
return null;

@@ -306,10 +300,9 @@ } else if (child.type && (0, _isFunction2.default)(child.type.getDomain)) {

} else {
return _domain.default.getDomain(sharedProps, axis);
return Domain.getDomain(sharedProps, axis);
}
};
var childDomains = _helpers.default.reduceChildren(children, iteratee, props);
var min = childDomains.length === 0 ? 0 : _collection.default.getMinValue(childDomains);
var max = childDomains.length === 0 ? 1 : _collection.default.getMaxValue(childDomains);
var childDomains = Helpers.reduceChildren(children, iteratee, props);
var min = childDomains.length === 0 ? 0 : Collection.getMinValue(childDomains);
var max = childDomains.length === 0 ? 1 : Collection.getMaxValue(childDomains);
return [min, max];

@@ -330,3 +323,3 @@ },

if (someChildrenAreHistograms && !allChildrenAreHistograms) {
_log.default.warn("VictoryHistogram only supports being stacked with other VictoryHistogram components. Check to make sure that you are only passing VictoryHistogram components to VictoryStack");
Log.warn("VictoryHistogram only supports being stacked with other VictoryHistogram components. Check to make sure that you are only passing VictoryHistogram components to VictoryStack");
} // if we are stacking histograms, we need to generate explicit bins

@@ -344,4 +337,3 @@ // or else each histogram may end up having different bins

var combinedData = children.reduce(function (memo, child) {
var xAccessor = _helpers.default.createAccessor(child.props.x || "x");
var xAccessor = Helpers.createAccessor(child.props.x || "x");
return memo.concat(child.props.data.map(function (datum) {

@@ -398,3 +390,3 @@ return {

if (!_data.default.isDataComponent(child)) {
if (!Data.isDataComponent(child)) {
return null;

@@ -405,3 +397,3 @@ } else if (child.type && (0, _isFunction2.default)(child.type.getData)) {

} else {
childData = _data.default.getData(childProps);
childData = Data.getData(childProps);
}

@@ -426,4 +418,3 @@

var datasets = _helpers.default.reduceChildren(children, iteratee, props, [], combine);
var datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
var group = stacked ? "_group" : "_stack";

@@ -449,3 +440,3 @@ return (0, _values2.default)((0, _groupBy2.default)(datasets, group));

var colors = Array.isArray(colorScale) ? colorScale : _style.default.getColorScale(colorScale);
var colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale);
return color || colors[index % colors.length];

@@ -456,3 +447,3 @@ },

horizontal = props.horizontal;
var range = horizontal ? _helpers.default.getRange(props, "y") : _helpers.default.getRange(props, "x");
var range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
var extent = Math.abs(range[1] - range[0]);

@@ -467,3 +458,3 @@ seriesLength = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;

var defaultStyle = theme && theme[role] && theme[role].style ? theme[role].style : {};
return _helpers.default.getStyles(style, defaultStyle);
return Helpers.getStyles(style, defaultStyle);
},

@@ -502,3 +493,3 @@ getChildStyle: function (child, index, calculatedProps) {

if (!_domain.default.isDomainComponent(child) || !childProps.categories) {
if (!Domain.isDomainComponent(child) || !childProps.categories) {
return null;

@@ -510,7 +501,7 @@ } else {

});
return categoryStrings ? _collection.default.removeUndefined(categoryStrings) : [];
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
}
};
return _helpers.default.reduceChildren(childComponents.slice(0), iteratee);
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
},

@@ -522,3 +513,3 @@ getStringsFromData: function (childComponents) {

if (!_data.default.isDataComponent(child)) {
if (!Data.isDataComponent(child)) {
return null;

@@ -528,3 +519,3 @@ } else if (child.type && (0, _isFunction2.default)(child.type.getData)) {

} else {
data = _data.default.getData(childProps);
data = Data.getData(childProps);
}

@@ -558,10 +549,8 @@

return _helpers.default.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
return Helpers.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
},
getCategoryAndAxisStringsFromChildren: function (props, axis, childComponents) {
var categories = (0, _isPlainObject2.default)(props.categories) ? props.categories[axis] : props.categories;
var axisComponent = _axis.default.getAxisComponent(childComponents, axis);
var axisStrings = axisComponent ? _data.default.getStringsFromAxes(axisComponent.props, axis) : [];
var axisComponent = Axis.getAxisComponent(childComponents, axis);
var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
var categoryStrings = categories || this.getStringsFromCategories(childComponents, axis);

@@ -568,0 +557,0 @@ return (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));

{
"name": "victory-core",
"version": "35.9.3",
"version": "35.10.0",
"description": "Victory Core",

@@ -31,2 +31,5 @@ "keywords": [

},
"peerDependencies": {
"react": "^16.6.0 || ^17.0.0"
},
"scripts": {

@@ -33,0 +36,0 @@ "version": "nps build-libs && nps build-dists"

@@ -919,2 +919,4 @@ import * as React from "react";

desc?: string;
rx?: number;
ry?: number;
}

@@ -921,0 +923,0 @@

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

// This rule doesn't play well with namespaced exports
/* eslint-disable import/export */
export { default as VictoryAccessibleGroup } from "./victory-accessible-group/victory-accessible-group";

@@ -24,22 +26,22 @@ export { default as VictoryAnimation } from "./victory-animation/victory-animation";

export { default as addEvents } from "./victory-util/add-events";
export { default as Collection } from "./victory-util/collection";
export { default as Data } from "./victory-util/data";
export { default as DefaultTransitions } from "./victory-util/default-transitions";
export { default as Domain } from "./victory-util/domain";
export { default as Events } from "./victory-util/events";
export { default as Helpers } from "./victory-util/helpers";
export { default as Immutable } from "./victory-util/immutable";
export { default as LabelHelpers } from "./victory-util/label-helpers";
export { default as Log } from "./victory-util/log";
export { default as PropTypes } from "./victory-util/prop-types";
export { default as Scale } from "./victory-util/scale";
export { default as Selection } from "./victory-util/selection";
export { default as Style } from "./victory-util/style";
export { default as TextSize } from "./victory-util/textsize";
export * as Collection from "./victory-util/collection";
export * as Data from "./victory-util/data";
export * as DefaultTransitions from "./victory-util/default-transitions";
export * as Domain from "./victory-util/domain";
export * as Events from "./victory-util/events";
export * as Helpers from "./victory-util/helpers";
export * as Immutable from "./victory-util/immutable";
export * as LabelHelpers from "./victory-util/label-helpers";
export * as Log from "./victory-util/log";
export * as PropTypes from "./victory-util/prop-types";
export * as Scale from "./victory-util/scale";
export * as Selection from "./victory-util/selection";
export * as Style from "./victory-util/style";
export * as TextSize from "./victory-util/textsize";
export { default as Timer } from "./victory-util/timer";
export { default as Transitions } from "./victory-util/transitions";
export { default as CommonProps } from "./victory-util/common-props";
export * as Transitions from "./victory-util/transitions";
export * as CommonProps from "./victory-util/common-props";
export { default as Wrapper } from "./victory-util/wrapper";
export { default as Axis } from "./victory-util/axis";
export * as Axis from "./victory-util/axis";
export { default as TimerContext } from "./victory-util/timer-context";
export { default as PortalContext } from "./victory-portal/portal-context";
import React from "react";
import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import Helpers from "../victory-util/helpers";
import * as CustomPropTypes from "../victory-util/prop-types";
import * as Helpers from "../victory-util/helpers";
import { assign, defaults, isObject, uniqueId } from "lodash";

@@ -6,0 +6,0 @@ import ClipPath from "../victory-primitives/clip-path";

import React from "react";
import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import * as CustomPropTypes from "../victory-util/prop-types";
import { assign, defaults, uniqueId, isObject, isFunction } from "lodash";

@@ -8,3 +8,3 @@ import Portal from "../victory-portal/portal";

import TimerContext from "../victory-util/timer-context";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";

@@ -11,0 +11,0 @@ export default class VictoryContainer extends React.Component {

@@ -6,8 +6,8 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/

import Rect from "../victory-primitives/rect";
import CustomPropTypes from "../victory-util/prop-types";
import Helpers from "../victory-util/helpers";
import LabelHelpers from "../victory-util/label-helpers";
import Style from "../victory-util/style";
import Log from "../victory-util/log";
import TextSize from "../victory-util/textsize";
import * as CustomPropTypes from "../victory-util/prop-types";
import * as Helpers from "../victory-util/helpers";
import * as LabelHelpers from "../victory-util/label-helpers";
import * as Style from "../victory-util/style";
import * as Log from "../victory-util/log";
import * as TextSize from "../victory-util/textsize";
import TSpan from "../victory-primitives/tspan";

@@ -14,0 +14,0 @@ import Text from "../victory-primitives/text";

import React from "react";
import PropTypes from "prop-types";
import CustomPropTypes from "../victory-util/prop-types";
import * as CustomPropTypes from "../victory-util/prop-types";
import { keys } from "lodash";

@@ -5,0 +5,0 @@

import React from "react";
import PropTypes from "prop-types";
import { defaults } from "lodash";
import Log from "../victory-util/log";
import Helpers from "../victory-util/helpers";
import * as Log from "../victory-util/log";
import * as Helpers from "../victory-util/helpers";
import PortalContext from "./portal-context";

@@ -7,0 +7,0 @@

/*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
import React from "react";
import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";
import { assign } from "lodash";
import CommonProps from "../victory-util/common-props";
import * as CommonProps from "../victory-util/common-props";
import Path from "./path";

@@ -8,0 +8,0 @@

import React from "react";
import PropTypes from "prop-types";
import { assign } from "lodash";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Rect from "./rect";

@@ -7,0 +7,0 @@ import Circle from "./circle";

import React from "react";
import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";
import { assign } from "lodash";
import CommonProps from "../victory-util/common-props";
import * as CommonProps from "../victory-util/common-props";
import Rect from "./rect";

@@ -7,0 +7,0 @@

import React from "react";
import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";
import { assign } from "lodash";
import CommonProps from "../victory-util/common-props";
import * as CommonProps from "../victory-util/common-props";
import Line from "./line";

@@ -7,0 +7,0 @@

import React from "react";
import PropTypes from "prop-types";
import { assign } from "lodash";
import Helpers from "../victory-util/helpers";
import * as Helpers from "../victory-util/helpers";
import pathHelpers from "./path-helpers";
import CommonProps from "../victory-util/common-props";
import * as CommonProps from "../victory-util/common-props";
import Path from "./path";

@@ -8,0 +8,0 @@

import React from "react";
import { assign } from "lodash";
import PropTypes from "prop-types";
import Helpers from "../victory-util/helpers";
import CommonProps from "../victory-util/common-props";
import * as Helpers from "../victory-util/helpers";
import * as CommonProps from "../victory-util/common-props";
import Line from "./line";

@@ -7,0 +7,0 @@

import React from "react";
import PropTypes from "prop-types";
import VictoryAnimation from "../victory-animation/victory-animation";
import Collection from "../victory-util/collection";
import Helpers from "../victory-util/helpers";
import * as Collection from "../victory-util/collection";
import * as Helpers from "../victory-util/helpers";
import TimerContext from "../victory-util/timer-context";
import Transitions from "../victory-util/transitions";
import * as Transitions from "../victory-util/transitions";
import { defaults, isFunction, pick, isObject } from "lodash";

@@ -9,0 +9,0 @@ import isEqual from "react-fast-compare";

@@ -14,3 +14,3 @@ /*global window:false */

} from "lodash";
import Events from "./events";
import * as Events from "./events";
import isEqual from "react-fast-compare";

@@ -17,0 +17,0 @@ import VictoryTransition from "../victory-transition/victory-transition";

@@ -17,5 +17,5 @@ /* eslint-disable func-style */

} from "lodash";
import Collection from "./collection";
import Domain from "./domain";
import Helpers from "./helpers";
import * as Collection from "./collection";
import * as Domain from "./domain";
import * as Helpers from "./helpers";

@@ -28,3 +28,3 @@ /**

*/
function getAxis(props) {
export function getAxis(props) {
const { dependentAxis } = props;

@@ -40,3 +40,3 @@ return dependentAxis ? "y" : "x";

*/
function findAxisComponents(childComponents, predicate) {
export function findAxisComponents(childComponents, predicate) {
predicate = predicate || identity;

@@ -65,3 +65,3 @@ const findAxes = (children) => {

*/
function getAxisComponent(childComponents, axis) {
export function getAxisComponent(childComponents, axis) {
const matchesAxis = (component) => {

@@ -81,3 +81,3 @@ const type = component.type.getAxis(component.props);

*/
function getAxisComponentsWithParent(childComponents, type) {
export function getAxisComponentsWithParent(childComponents, type) {
const matchesType = (child) => {

@@ -106,3 +106,3 @@ return type === "dependent"

function getOrigin(domain) {
export function getOrigin(domain) {
const getSingleOrigin = (d) => {

@@ -124,3 +124,3 @@ const domainMin = Math.min(...d);

function getOriginSign(origin, domain) {
export function getOriginSign(origin, domain) {
const getSign = () => {

@@ -136,3 +136,3 @@ return origin <= 0 && Math.max(...domain) <= 0 ? "negative" : "positive";

*/
function isVertical(props) {
export function isVertical(props) {
const orientation =

@@ -148,3 +148,3 @@ props.orientation || (props.dependentAxis ? "left" : "bottom");

*/
function stringTicks(props) {
export function stringTicks(props) {
return (

@@ -245,3 +245,3 @@ props.tickValues !== undefined &&

function getTickFormat(props, scale) {
export function getTickFormat(props, scale) {
const { tickFormat } = props;

@@ -286,3 +286,3 @@ const axis = getAxis(props);

function getTicks(props, scale, filterZero) {
export function getTicks(props, scale, filterZero) {
const { tickCount } = props;

@@ -347,3 +347,3 @@ const tickArray = getTickArray(props);

// exposed for use by VictoryChart
function getDomain(props, axis) {
export function getDomain(props, axis) {
const inherentAxis = getAxis(props);

@@ -356,3 +356,3 @@ if (axis && axis !== inherentAxis) {

function getAxisValue(props, axis) {
export function getAxisValue(props, axis) {
if (!props.axisValue) {

@@ -378,3 +378,3 @@ return undefined;

function modifyProps(props, fallbackProps) {
export function modifyProps(props, fallbackProps) {
if (!isObject(props.theme)) {

@@ -400,17 +400,1 @@ return Helpers.modifyProps(props, fallbackProps, "axis");

}
export default {
getTicks,
getTickFormat,
getAxis,
getAxisComponent,
getAxisComponentsWithParent,
getAxisValue,
findAxisComponents,
getOrigin,
getOriginSign,
getDomain,
isVertical,
modifyProps,
stringTicks
};

@@ -8,3 +8,3 @@ /* eslint-disable func-style */

function containsStrings(collection) {
export function containsStrings(collection) {
return (

@@ -16,3 +16,3 @@ Array.isArray(collection) &&

function containsDates(collection) {
export function containsDates(collection) {
return (

@@ -24,3 +24,3 @@ Array.isArray(collection) &&

function containsNumbers(collection) {
export function containsNumbers(collection) {
return (

@@ -32,3 +32,3 @@ Array.isArray(collection) &&

function containsOnlyStrings(collection) {
export function containsOnlyStrings(collection) {
return (

@@ -40,11 +40,11 @@ isNonEmptyArray(collection) &&

function isArrayOfArrays(collection) {
export function isArrayOfArrays(collection) {
return isNonEmptyArray(collection) && collection.every(Array.isArray);
}
function removeUndefined(arr) {
export function removeUndefined(arr) {
return arr.filter((el) => el !== undefined);
}
function getMaxValue(arr, ...values) {
export function getMaxValue(arr, ...values) {
const array = arr.concat(values);

@@ -56,3 +56,3 @@ return containsDates(array)

function getMinValue(arr, ...values) {
export function getMinValue(arr, ...values) {
const array = arr.concat(values);

@@ -63,12 +63,1 @@ return containsDates(array)

}
export default {
containsDates,
containsNumbers,
containsOnlyStrings,
containsStrings,
getMaxValue,
getMinValue,
isArrayOfArrays,
removeUndefined
};
import PropTypes from "prop-types";
import CustomPropTypes from "./prop-types";
import * as CustomPropTypes from "./prop-types";
const dataProps = {
export const dataProps = {
categories: PropTypes.oneOfType([

@@ -62,3 +62,3 @@ PropTypes.arrayOf(PropTypes.string),

const baseProps = {
export const baseProps = {
animate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),

@@ -176,3 +176,3 @@ containerComponent: PropTypes.element,

const primitiveProps = {
export const primitiveProps = {
active: PropTypes.bool,

@@ -200,3 +200,1 @@ ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),

};
export default { baseProps, dataProps, primitiveProps };

@@ -19,6 +19,6 @@ /* eslint-disable func-style */

} from "lodash";
import Helpers from "./helpers";
import Collection from "./collection";
import Scale from "./scale";
import Immutable from "./immutable";
import * as Helpers from "./helpers";
import * as Collection from "./collection";
import * as Scale from "./scale";
import * as Immutable from "./immutable";

@@ -99,4 +99,35 @@ // Private Functions

// Returns a data accessor given an eventKey prop
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if (isFunction(key)) {
return key;
} else if (key === null || key === undefined) {
return () => undefined;
}
// otherwise, assume it is an array index, property key or path (_.property handles all three)
return property(key);
}
// Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
const hasEventKeyAccessor = !!props.eventKey;
const eventKeyAccessor = getEventKey(props.eventKey);
return data.map((datum, index) => {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
const eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? assign({ eventKey }, datum) : datum;
} else {
return datum;
}
});
}
// Exported Functions
// This method will remove data points that fall outside of the desired domain (non-continuous charts only)
function formatDataFromDomain(dataset, domain, defaultBaseline) {
export function formatDataFromDomain(dataset, domain, defaultBaseline) {
const exists = (val) => val !== undefined;

@@ -149,33 +180,2 @@

// Returns a data accessor given an eventKey prop
function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if (isFunction(key)) {
return key;
} else if (key === null || key === undefined) {
return () => undefined;
}
// otherwise, assume it is an array index, property key or path (_.property handles all three)
return property(key);
}
// Returns data with an eventKey prop added to each datum
function addEventKeys(props, data) {
const hasEventKeyAccessor = !!props.eventKey;
const eventKeyAccessor = getEventKey(props.eventKey);
return data.map((datum, index) => {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
const eventKey = eventKeyAccessor(datum, index);
return eventKey !== undefined ? assign({ eventKey }, datum) : datum;
} else {
return datum;
}
});
}
// Exported Functions
/**

@@ -187,3 +187,3 @@ * Returns an object mapping string data to numeric data

*/
function createStringMap(props, axis) {
export function createStringMap(props, axis) {
const stringsFromAxes = getStringsFromAxes(props, axis);

@@ -214,3 +214,3 @@ const stringsFromCategories = getStringsFromCategories(props, axis);

*/
function downsample(data, maxPoints, startingIndex = 0) {
export function downsample(data, maxPoints, startingIndex = 0) {
// ensures that the downampling of data while zooming looks good.

@@ -237,3 +237,3 @@ const dataLength = getLength(data);

*/
function formatData(dataset, props, expectedKeys) {
export function formatData(dataset, props, expectedKeys) {
const isArrayOrIterable =

@@ -325,3 +325,3 @@ Array.isArray(dataset) || Immutable.isIterable(dataset);

*/
function generateData(props) {
export function generateData(props) {
const xValues = generateDataArray(props, "x");

@@ -341,3 +341,3 @@ const yValues = generateDataArray(props, "y");

*/
function getCategories(props, axis) {
export function getCategories(props, axis) {
return props.categories && !Array.isArray(props.categories)

@@ -353,3 +353,3 @@ ? props.categories[axis]

*/
function getData(props) {
export function getData(props) {
return props.data

@@ -366,3 +366,3 @@ ? formatData(props.data, props)

*/
function getStringsFromAxes(props, axis) {
export function getStringsFromAxes(props, axis) {
const { tickValues, tickFormat } = props;

@@ -384,3 +384,3 @@ let tickValueArray;

*/
function getStringsFromCategories(props, axis) {
export function getStringsFromCategories(props, axis) {
if (!props.categories) {

@@ -401,3 +401,3 @@ return [];

*/
function getStringsFromData(props, axis) {
export function getStringsFromData(props, axis) {
const isArrayOrIterable =

@@ -441,3 +441,3 @@ Array.isArray(props.data) || Immutable.isIterable(props.data);

*/
function isDataComponent(component) {
export function isDataComponent(component) {
const getRole = (child) => {

@@ -467,15 +467,1 @@ return child && child.type ? child.type.role : "";

}
export default {
createStringMap,
downsample,
formatData,
formatDataFromDomain,
generateData,
getCategories,
getData,
getStringsFromAxes,
getStringsFromCategories,
getStringsFromData,
isDataComponent
};
/* eslint-disable func-style */
export default {
continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
export function continuousTransitions() {
return {
onLoad: {
duration: 2000
},
onExit: {
duration: 500
},
onEnter: {
duration: 500
}
};
}
export function continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
},
onExit: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
};
},
continuousPolarTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
},
onEnter: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
onExit: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
}
},
onEnter: {
duration: 500,
before: (datum, index, data) => {
const adjacent = (attr) => {
const adj = index === 0 ? data[index + 1] : data[index - 1];
return adj[attr];
};
return {
_x: adjacent("_x"),
_y: adjacent("_y"),
_y0: adjacent("_y0")
};
},
after: (datum) => ({
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
}
};
},
after: (datum) => ({
_x: datum._x,
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
}
};
}
discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ opacity: 0 }),
after: (datum) => datum
},
onExit: {
duration: 600,
before: () => ({ opacity: 0 })
},
onEnter: {
duration: 600,
before: () => ({ opacity: 0 }),
after: (datum) => datum
}
};
}
};
export function discreteTransitions() {
return {
onLoad: {
duration: 2000,
before: () => ({ opacity: 0 }),
after: (datum) => datum
},
onExit: {
duration: 600,
before: () => ({ opacity: 0 })
},
onEnter: {
duration: 600,
before: () => ({ opacity: 0 }),
after: (datum) => datum
}
};
}

@@ -12,6 +12,6 @@ /* eslint-disable func-style */

} from "lodash";
import Data from "./data";
import Scale from "./scale";
import Helpers from "./helpers";
import Collection from "./collection";
import * as Data from "./data";
import * as Scale from "./scale";
import * as Helpers from "./helpers";
import * as Collection from "./collection";

@@ -181,3 +181,6 @@ // Private Methods

*/
function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
export function createDomainFunction(
getDomainFromDataFunction,
formatDomainFunction
) {
getDomainFromDataFunction = isFunction(getDomainFromDataFunction)

@@ -209,3 +212,3 @@ ? getDomainFromDataFunction

*/
function formatDomain(domain, props, axis) {
export function formatDomain(domain, props, axis) {
return cleanDomain(padDomain(domain, props, axis), props, axis);

@@ -220,3 +223,3 @@ }

*/
function getDomain(props, axis) {
export function getDomain(props, axis) {
return createDomainFunction()(props, axis);

@@ -232,3 +235,3 @@ }

*/
function getDomainFromCategories(props, axis, categories) {
export function getDomainFromCategories(props, axis, categories) {
categories = categories || Data.getCategories(props, axis);

@@ -275,3 +278,3 @@ const { polar, startAngle = 0, endAngle = 360 } = props;

*/
function getDomainFromData(props, axis, dataset) {
export function getDomainFromData(props, axis, dataset) {
dataset = dataset || Data.getData(props);

@@ -306,3 +309,3 @@ const { polar, startAngle = 0, endAngle = 360 } = props;

*/
function getDomainFromMinMax(min, max) {
export function getDomainFromMinMax(min, max) {
const getSinglePointDomain = (val) => {

@@ -333,3 +336,3 @@ // d3-scale does not properly resolve very small differences.

*/
function getDomainFromProps(props, axis) {
export function getDomainFromProps(props, axis) {
const minDomain = getMinFromProps(props, axis);

@@ -354,3 +357,3 @@ const maxDomain = getMaxFromProps(props, axis);

*/
function getDomainWithZero(props, axis) {
export function getDomainWithZero(props, axis) {
const propsDomain = getDomainFromProps(props, axis);

@@ -407,3 +410,3 @@ if (propsDomain) {

*/
function getMaxFromProps(props, axis) {
export function getMaxFromProps(props, axis) {
if (isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {

@@ -423,3 +426,3 @@ return props.maxDomain[axis];

*/
function getMinFromProps(props, axis) {
export function getMinFromProps(props, axis) {
if (isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {

@@ -440,3 +443,3 @@ return props.minDomain[axis];

*/
function getSymmetricDomain(domain, values) {
export function getSymmetricDomain(domain, values) {
const processedData = sortedUniq(values.sort((a, b) => a - b));

@@ -452,3 +455,3 @@ const step = processedData[1] - processedData[0];

*/
function isDomainComponent(component) {
export function isDomainComponent(component) {
const getRole = (child) => {

@@ -479,16 +482,1 @@ return child && child.type ? child.type.role : "";

}
export default {
createDomainFunction,
formatDomain,
getDomain,
getDomainFromCategories,
getDomainFromData,
getDomainFromMinMax,
getDomainFromProps,
getDomainWithZero,
getMaxFromProps,
getMinFromProps,
getSymmetricDomain,
isDomainComponent
};

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

/* eslint-disable no-invalid-this */
/* eslint-disable func-style */
import {

@@ -15,435 +17,438 @@ assign,

export default {
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params
getEvents(props, target, eventKey, getScopedEvents) {
// Returns all events that apply to a particular target element
const getEventsByTarget = (events) => {
const getSelectedEvents = () => {
const targetEvents = events.reduce((memo, event) => {
if (event.target !== undefined) {
const matchesTarget = Array.isArray(event.target)
? includes(event.target, target)
: `${event.target}` === `${target}`;
return matchesTarget ? memo.concat(event) : memo;
}
return memo.concat(event);
}, []);
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter((obj) => {
const targetKeys = obj.eventKey;
const useKey = (key) => (key ? `${key}` === `${eventKey}` : true);
return Array.isArray(targetKeys)
? targetKeys.some((k) => useKey(k))
: useKey(targetKeys);
});
/* Returns all own and shared events that should be attached to a single target element,
* i.e. an individual bar specified by target: "data", eventKey: [index].
* Returned events are scoped to the appropriate state. Either that of the component itself
* (i.e. VictoryBar) in the case of own events, or that of the parent component
* (i.e. VictoryChart) in the case of shared events
*/
// eslint-disable-next-line max-params,no-shadow
export function getEvents(props, target, eventKey, getScopedEvents) {
// Returns all events that apply to a particular target element
const getEventsByTarget = (events) => {
const getSelectedEvents = () => {
const targetEvents = events.reduce((memo, event) => {
if (event.target !== undefined) {
const matchesTarget = Array.isArray(event.target)
? includes(event.target, target)
: `${event.target}` === `${target}`;
return matchesTarget ? memo.concat(event) : memo;
}
return targetEvents;
};
return memo.concat(event);
}, []);
const selectedEvents = getSelectedEvents();
return (
Array.isArray(selectedEvents) &&
selectedEvents.reduce((memo, event) => {
return event ? assign(memo, event.eventHandlers) : memo;
}, {})
);
};
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
const getAllEvents = () => {
if (Array.isArray(this.componentEvents)) {
return Array.isArray(props.events)
? this.componentEvents.concat(...props.events)
: this.componentEvents;
if (eventKey !== undefined && target !== "parent") {
return targetEvents.filter((obj) => {
const targetKeys = obj.eventKey;
const useKey = (key) => (key ? `${key}` === `${eventKey}` : true);
return Array.isArray(targetKeys)
? targetKeys.some((k) => useKey(k))
: useKey(targetKeys);
});
}
return props.events;
return targetEvents;
};
const allEvents = getAllEvents();
const ownEvents =
allEvents && isFunction(getScopedEvents)
? getScopedEvents(getEventsByTarget(allEvents), target)
: undefined;
if (!props.sharedEvents) {
return ownEvents;
}
const getSharedEvents = props.sharedEvents.getEvents;
const sharedEvents =
props.sharedEvents.events &&
getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return assign({}, sharedEvents, ownEvents);
},
const selectedEvents = getSelectedEvents();
return (
Array.isArray(selectedEvents) &&
selectedEvents.reduce((memo, event) => {
return event ? assign(memo, event.eventHandlers) : memo;
}, {})
);
};
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
/* Returns all events from props and defaultEvents from components. Events handlers
* specified in props will override handlers for the same event if they are also
* specified in defaultEvents of a sub-component
*/
// eslint-disable-next-line max-params
getScopedEvents(events, namespace, childType, baseProps) {
if (isEmpty(events)) {
return {};
const getAllEvents = () => {
if (Array.isArray(this.componentEvents)) {
return Array.isArray(props.events)
? this.componentEvents.concat(...props.events)
: this.componentEvents;
}
return props.events;
};
baseProps = baseProps || this.baseProps;
// returns the original base props or base state of a given target element
const getTargetProps = (identifier, type) => {
const { childName, target, key } = identifier;
const baseType = type === "props" ? baseProps : this.state || {};
const base =
childName === undefined || childName === null || !baseType[childName]
? baseType
: baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
const allEvents = getAllEvents();
const ownEvents =
allEvents && isFunction(getScopedEvents)
? getScopedEvents(getEventsByTarget(allEvents), target)
: undefined;
if (!props.sharedEvents) {
return ownEvents;
}
const getSharedEvents = props.sharedEvents.getEvents;
const sharedEvents =
props.sharedEvents.events &&
getSharedEvents(getEventsByTarget(props.sharedEvents.events), target);
return assign({}, sharedEvents, ownEvents);
}
/* Returns a modified events object where each event handler is replaced by a new
* function that calls the original handler and then calls setState with the return
* of the original event handler assigned to state property that maps to the target
* element.
*/
// eslint-disable-next-line max-params
export function getScopedEvents(events, namespace, childType, baseProps) {
if (isEmpty(events)) {
return {};
}
baseProps = baseProps || this.baseProps;
// returns the original base props or base state of a given target element
const getTargetProps = (identifier, type) => {
const { childName, target, key } = identifier;
const baseType = type === "props" ? baseProps : this.state || {};
const base =
childName === undefined || childName === null || !baseType[childName]
? baseType
: baseType[childName];
return key === "parent" ? base.parent : base[key] && base[key][target];
};
// Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
const parseEvent = (eventReturn, eventKey) => {
const childNames =
namespace === "parent"
? eventReturn.childName
: eventReturn.childName || childType;
const target = eventReturn.target || namespace;
// returns all eventKeys to modify for a targeted childName
const getKeys = (childName) => {
if (target === "parent") {
return "parent";
}
if (eventReturn.eventKey === "all") {
return baseProps[childName]
? without(keys(baseProps[childName]), "parent")
: without(keys(baseProps), "parent");
} else if (eventReturn.eventKey === undefined && eventKey === "parent") {
return baseProps[childName]
? keys(baseProps[childName])
: keys(baseProps);
}
return eventReturn.eventKey !== undefined
? eventReturn.eventKey
: eventKey;
};
// Returns the state object with the mutation caused by a given eventReturn
// applied to the appropriate property on the state object
const parseEvent = (eventReturn, eventKey) => {
const childNames =
namespace === "parent"
? eventReturn.childName
: eventReturn.childName || childType;
const target = eventReturn.target || namespace;
// returns the state object with mutated props applied for a single key
const getMutationObject = (key, childName) => {
const baseState = this.state || {};
if (!isFunction(eventReturn.mutation)) {
return baseState;
}
const mutationTargetProps = getTargetProps(
{ childName, key, target },
"props"
);
const mutationTargetState = getTargetProps(
{ childName, key, target },
"state"
);
const mutatedProps = eventReturn.mutation(
assign({}, mutationTargetProps, mutationTargetState),
baseProps
);
const childState = baseState[childName] || {};
// returns all eventKeys to modify for a targeted childName
const getKeys = (childName) => {
if (target === "parent") {
return "parent";
const filterState = (state) => {
if (state[key] && state[key][target]) {
delete state[key][target];
}
if (eventReturn.eventKey === "all") {
return baseProps[childName]
? without(keys(baseProps[childName]), "parent")
: without(keys(baseProps), "parent");
} else if (
eventReturn.eventKey === undefined &&
eventKey === "parent"
) {
return baseProps[childName]
? keys(baseProps[childName])
: keys(baseProps);
if (state[key] && !keys(state[key]).length) {
delete state[key];
}
return eventReturn.eventKey !== undefined
? eventReturn.eventKey
: eventKey;
return state;
};
// returns the state object with mutated props applied for a single key
const getMutationObject = (key, childName) => {
const baseState = this.state || {};
if (!isFunction(eventReturn.mutation)) {
return baseState;
}
const mutationTargetProps = getTargetProps(
{ childName, key, target },
"props"
);
const mutationTargetState = getTargetProps(
{ childName, key, target },
"state"
);
const mutatedProps = eventReturn.mutation(
assign({}, mutationTargetProps, mutationTargetState),
baseProps
);
const childState = baseState[childName] || {};
const filterState = (state) => {
if (state[key] && state[key][target]) {
delete state[key][target];
}
if (state[key] && !keys(state[key]).length) {
delete state[key];
}
return state;
};
const extendState = (state) => {
return target === "parent"
? assign(state, { [key]: assign(state[key], mutatedProps) })
: assign(state, {
[key]: assign(state[key], { [target]: mutatedProps })
});
};
const updateState = (state) => {
return mutatedProps ? extendState(state) : filterState(state);
};
return childName !== undefined && childName !== null
? assign(baseState, { [childName]: updateState(childState) })
: updateState(baseState);
const extendState = (state) => {
return target === "parent"
? assign(state, { [key]: assign(state[key], mutatedProps) })
: assign(state, {
[key]: assign(state[key], { [target]: mutatedProps })
});
};
// returns entire mutated state for a given childName
const getReturnByChild = (childName) => {
const mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys)
? mutationKeys.reduce((memo, key) => {
return assign(memo, getMutationObject(key, childName));
}, {})
: getMutationObject(mutationKeys, childName);
const updateState = (state) => {
return mutatedProps ? extendState(state) : filterState(state);
};
// returns an entire mutated state for all children
const allChildNames =
childNames === "all" ? without(keys(baseProps), "parent") : childNames;
return Array.isArray(allChildNames)
? allChildNames.reduce((memo, childName) => {
return assign(memo, getReturnByChild(childName));
}, {})
: getReturnByChild(allChildNames);
return childName !== undefined && childName !== null
? assign(baseState, { [childName]: updateState(childState) })
: updateState(baseState);
};
// Parses an array of event returns into a single state mutation
const parseEventReturn = (eventReturn, eventKey) => {
return Array.isArray(eventReturn)
? eventReturn.reduce((memo, props) => {
memo = assign({}, memo, parseEvent(props, eventKey));
return memo;
// returns entire mutated state for a given childName
const getReturnByChild = (childName) => {
const mutationKeys = getKeys(childName);
return Array.isArray(mutationKeys)
? mutationKeys.reduce((memo, key) => {
return assign(memo, getMutationObject(key, childName));
}, {})
: parseEvent(eventReturn, eventKey);
: getMutationObject(mutationKeys, childName);
};
const compileCallbacks = (eventReturn) => {
const getCallback = (obj) => isFunction(obj.callback) && obj.callback;
const callbacks = Array.isArray(eventReturn)
? eventReturn.map((evtObj) => getCallback(evtObj))
: [getCallback(eventReturn)];
const callbackArray = callbacks.filter((callback) => callback !== false);
return callbackArray.length
? () => callbackArray.forEach((callback) => callback())
: undefined;
};
// returns an entire mutated state for all children
const allChildNames =
childNames === "all" ? without(keys(baseProps), "parent") : childNames;
return Array.isArray(allChildNames)
? allChildNames.reduce((memo, childName) => {
return assign(memo, getReturnByChild(childName));
}, {})
: getReturnByChild(allChildNames);
};
// A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
const onEvent = (evt, childProps, eventKey, eventName) => {
const eventReturn = events[eventName](evt, childProps, eventKey, this);
if (!isEmpty(eventReturn)) {
const callbacks = compileCallbacks(eventReturn);
this.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
};
// returns a new events object with enhanced event handlers
return keys(events).reduce((memo, event) => {
memo[event] = onEvent;
return memo;
}, {});
},
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
getPartialEvents(events, eventKey, childProps) {
return events
? keys(events).reduce((memo, eventName) => {
const appliedEvent = (evt) =>
events[eventName](evt, childProps, eventKey, eventName);
memo[eventName] = appliedEvent;
// Parses an array of event returns into a single state mutation
const parseEventReturn = (eventReturn, eventKey) => {
return Array.isArray(eventReturn)
? eventReturn.reduce((memo, props) => {
memo = assign({}, memo, parseEvent(props, eventKey));
return memo;
}, {})
: {};
},
: parseEvent(eventReturn, eventKey);
};
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
getEventState(eventKey, namespace, childType) {
const state = this.state || {};
if (!childType) {
return eventKey === "parent"
? (state[eventKey] && state[eventKey][namespace]) || state[eventKey]
: state[eventKey] && state[eventKey][namespace];
const compileCallbacks = (eventReturn) => {
const getCallback = (obj) => isFunction(obj.callback) && obj.callback;
const callbacks = Array.isArray(eventReturn)
? eventReturn.map((evtObj) => getCallback(evtObj))
: [getCallback(eventReturn)];
const callbackArray = callbacks.filter((callback) => callback !== false);
return callbackArray.length
? () => callbackArray.forEach((callback) => callback())
: undefined;
};
// A function that calls a particular event handler, parses its return
// into a state mutation, and calls setState
// eslint-disable-next-line max-params
const onEvent = (evt, childProps, eventKey, eventName) => {
const eventReturn = events[eventName](evt, childProps, eventKey, this);
if (!isEmpty(eventReturn)) {
const callbacks = compileCallbacks(eventReturn);
this.setState(parseEventReturn(eventReturn, eventKey), callbacks);
}
return (
state[childType] &&
state[childType][eventKey] &&
state[childType][eventKey][namespace]
};
// returns a new events object with enhanced event handlers
return keys(events).reduce((memo, event) => {
memo[event] = onEvent;
return memo;
}, {});
}
/* Returns a partially applied event handler for a specific target element
* This allows event handlers to have access to props controlling each element
*/
export function getPartialEvents(events, eventKey, childProps) {
return events
? keys(events).reduce((memo, eventName) => {
const appliedEvent = (evt) =>
events[eventName](evt, childProps, eventKey, eventName);
memo[eventName] = appliedEvent;
return memo;
}, {})
: {};
}
/* Returns the property of the state object corresponding to event changes for
* a particular element
*/
export function getEventState(eventKey, namespace, childType) {
const state = this.state || {};
if (!childType) {
return eventKey === "parent"
? (state[eventKey] && state[eventKey][namespace]) || state[eventKey]
: state[eventKey] && state[eventKey][namespace];
}
return (
state[childType] &&
state[childType][eventKey] &&
state[childType][eventKey][namespace]
);
}
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
export function getExternalMutationsWithChildren(
mutations,
baseProps,
baseState,
childNames
) {
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce((memo, childName) => {
const childState = baseState[childName];
const mutation = this.getExternalMutations(
mutations,
baseProps[childName],
baseState[childName],
childName
);
},
memo[childName] = mutation ? mutation : childState;
return pickBy(memo, (v) => !isEmpty(v));
}, {});
}
/**
* Returns a set of all mutations for shared events
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps an object that describes all props for children of VictorySharedEvents
* @param {Object} baseState an object that describes state for children of VictorySharedEvents
* @param {Array} childNames an array of childNames
*
* @return {Object} a object describing all mutations for VictorySharedEvents
*/
// eslint-disable-next-line max-params
getExternalMutationsWithChildren(
mutations,
baseProps,
baseState,
childNames
) {
baseProps = baseProps || {};
baseState = baseState || {};
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
export function getExternalMutations(
mutations,
baseProps,
baseState,
childName
) {
baseProps = baseProps || {};
baseState = baseState || {};
return childNames.reduce((memo, childName) => {
const childState = baseState[childName];
const mutation = this.getExternalMutations(
const eventKeys = keys(baseProps);
return eventKeys.reduce((memo, eventKey) => {
const keyState = baseState[eventKey] || {};
const keyProps = baseProps[eventKey] || {};
if (eventKey === "parent") {
const identifier = { eventKey, target: "parent" };
const mutation = this.getExternalMutation(
mutations,
baseProps[childName],
baseState[childName],
childName
keyProps,
keyState,
identifier
);
memo[childName] = mutation ? mutation : childState;
return pickBy(memo, (v) => !isEmpty(v));
}, {});
},
/**
* Returns a set of all mutations for a component
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped to a childName when used by shared events)
* @param {Object} baseState a state object (scoped to a childName when used by shared events)
* @param {String} childName an optional childName
*
* @return {Object} a object describing mutations for a given component
*/
// eslint-disable-next-line max-params
getExternalMutations(mutations, baseProps, baseState, childName) {
baseProps = baseProps || {};
baseState = baseState || {};
const eventKeys = keys(baseProps);
return eventKeys.reduce((memo, eventKey) => {
const keyState = baseState[eventKey] || {};
const keyProps = baseProps[eventKey] || {};
if (eventKey === "parent") {
const identifier = { eventKey, target: "parent" };
memo[eventKey] =
mutation !== undefined ? assign({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
const targets = uniq(keys(keyProps).concat(keys(keyState)));
memo[eventKey] = targets.reduce((m, target) => {
const identifier = { eventKey, target, childName };
const mutation = this.getExternalMutation(
mutations,
keyProps,
keyState,
keyProps[target],
keyState[target],
identifier
);
memo[eventKey] =
mutation !== undefined ? assign({}, keyState, mutation) : keyState;
} else {
// use keys from both state and props so that elements not intially included in baseProps
// will be used. (i.e. labels)
const targets = uniq(keys(keyProps).concat(keys(keyState)));
memo[eventKey] = targets.reduce((m, target) => {
const identifier = { eventKey, target, childName };
const mutation = this.getExternalMutation(
mutations,
keyProps[target],
keyState[target],
identifier
);
m[target] =
mutation !== undefined
? assign({}, keyState[target], mutation)
: keyState[target];
return pickBy(m, (v) => !isEmpty(v));
}, {});
}
return pickBy(memo, (v) => !isEmpty(v));
}, {});
},
m[target] =
mutation !== undefined
? assign({}, keyState[target], mutation)
: keyState[target];
return pickBy(m, (v) => !isEmpty(v));
}, {});
}
return pickBy(memo, (v) => !isEmpty(v));
}, {});
}
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
getExternalMutation(mutations, baseProps, baseState, identifier) {
const filterMutations = (mutation, type) => {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
const stringArray = mutation[type].map((m) => `${m}`);
return includes(stringArray, identifier[type]);
} else {
return false;
}
};
mutations = Array.isArray(mutations) ? mutations : [mutations];
let scopedMutations = mutations;
if (identifier.childName) {
scopedMutations = mutations.filter((m) =>
filterMutations(m, "childName")
);
/**
* Returns a set of mutations for a particular element given scoped baseProps and baseState
*
* @param {Array} mutations an array of mutations objects
* @param {Object} baseProps a props object (scoped the element specified by the identifier)
* @param {Object} baseState a state object (scoped the element specified by the identifier)
* @param {Object} identifier { eventKey, target, childName }
*
* @return {Object | undefined} a object describing mutations for a given element, or undefined
*/
// eslint-disable-next-line max-params
export function getExternalMutation(
mutations,
baseProps,
baseState,
identifier
) {
const filterMutations = (mutation, type) => {
if (typeof mutation[type] === "string") {
return mutation[type] === "all" || mutation[type] === identifier[type];
} else if (Array.isArray(mutation[type])) {
// coerce arrays to strings before matching
const stringArray = mutation[type].map((m) => `${m}`);
return includes(stringArray, identifier[type]);
} else {
return false;
}
// find any mutation objects that match the target
const targetMutations = scopedMutations.filter((m) =>
filterMutations(m, "target")
);
if (isEmpty(targetMutations)) {
return undefined;
}
const keyMutations = targetMutations.filter((m) =>
filterMutations(m, "eventKey")
);
if (isEmpty(keyMutations)) {
return undefined;
}
return keyMutations.reduce((memo, curr) => {
const mutationFunction =
curr && isFunction(curr.mutation) ? curr.mutation : () => undefined;
const currentMutation = mutationFunction(
assign({}, baseProps, baseState)
);
return assign({}, memo, currentMutation);
}, {});
},
};
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
getComponentEvents(props, components) {
const events =
Array.isArray(components) &&
components.reduce((memo, componentName) => {
const component = props[componentName];
const defaultEvents =
component && component.type && component.type.defaultEvents;
const componentEvents = isFunction(defaultEvents)
? defaultEvents(component.props)
: defaultEvents;
memo = Array.isArray(componentEvents)
? memo.concat(...componentEvents)
: memo;
return memo;
}, []);
return events && events.length ? events : undefined;
},
mutations = Array.isArray(mutations) ? mutations : [mutations];
let scopedMutations = mutations;
if (identifier.childName) {
scopedMutations = mutations.filter((m) => filterMutations(m, "childName"));
}
// find any mutation objects that match the target
const targetMutations = scopedMutations.filter((m) =>
filterMutations(m, "target")
);
if (isEmpty(targetMutations)) {
return undefined;
}
const keyMutations = targetMutations.filter((m) =>
filterMutations(m, "eventKey")
);
if (isEmpty(keyMutations)) {
return undefined;
}
return keyMutations.reduce((memo, curr) => {
const mutationFunction =
curr && isFunction(curr.mutation) ? curr.mutation : () => undefined;
const currentMutation = mutationFunction(assign({}, baseProps, baseState));
return assign({}, memo, currentMutation);
}, {});
}
getGlobalEventNameFromKey(key) {
const match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
},
/* Returns an array of defaultEvents from sub-components of a given component.
* i.e. any static `defaultEvents` on `labelComponent` will be returned
*/
export function getComponentEvents(props, components) {
const events =
Array.isArray(components) &&
components.reduce((memo, componentName) => {
const component = props[componentName];
const defaultEvents =
component && component.type && component.type.defaultEvents;
const componentEvents = isFunction(defaultEvents)
? defaultEvents(component.props)
: defaultEvents;
memo = Array.isArray(componentEvents)
? memo.concat(...componentEvents)
: memo;
return memo;
}, []);
return events && events.length ? events : undefined;
}
getGlobalEvents: (events) =>
pickBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key)),
omitGlobalEvents: (events) =>
omitBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key)),
export function getGlobalEventNameFromKey(key) {
const match = key.match(GLOBAL_EVENT_REGEX);
return match && match[1] && match[1].toLowerCase();
}
emulateReactEvent: (event) => assign(event, { nativeEvent: event })
};
export const getGlobalEvents = (events) =>
pickBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
export const omitGlobalEvents = (events) =>
omitBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
export const emulateReactEvent = (event) =>
assign(event, { nativeEvent: event });

@@ -36,3 +36,3 @@ /* eslint-disable func-style */

*/
function omit(originalObject, ks = []) {
export function omit(originalObject, ks = []) {
// code based on babel's _objectWithoutProperties

@@ -52,3 +52,3 @@ const newObject = {};

function getPoint(datum) {
export function getPoint(datum) {
const exists = (val) => val !== undefined;

@@ -67,3 +67,3 @@ const { _x, _x1, _x0, _voronoiX, _y, _y1, _y0, _voronoiY } = datum;

function scalePoint(props, datum) {
export function scalePoint(props, datum) {
const { scale, polar, horizontal } = props;

@@ -84,3 +84,3 @@ const d = getPoint(datum);

function getPadding(props, name = "padding") {
export function getPadding(props, name = "padding") {
const padding = props[name];

@@ -97,3 +97,3 @@ const paddingVal = typeof padding === "number" ? padding : 0;

function isTooltip(component) {
export function isTooltip(component) {
const labelRole = component && component.type && component.type.role;

@@ -103,3 +103,3 @@ return labelRole === "tooltip";

function getDefaultStyles(props, role) {
export function getDefaultStyles(props, role) {
const { theme = {}, labelComponent } = props;

@@ -115,3 +115,3 @@ const defaultStyles = (theme[role] && theme[role].style) || {};

function getStyles(style, defaultStyles) {
export function getStyles(style, defaultStyles) {
const width = "100%";

@@ -133,7 +133,7 @@ const height = "100%";

function evaluateProp(prop, props) {
export function evaluateProp(prop, props) {
return isFunction(prop) ? prop(props) : prop;
}
function evaluateStyle(style, props) {
export function evaluateStyle(style, props) {
if (props.disableInlineStyles) {

@@ -151,11 +151,11 @@ return {};

function degreesToRadians(degrees) {
export function degreesToRadians(degrees) {
return typeof degrees === "number" ? degrees * (Math.PI / 180) : degrees;
}
function radiansToDegrees(radians) {
export function radiansToDegrees(radians) {
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
}
function getRadius(props) {
export function getRadius(props) {
const { left, right, top, bottom } = getPadding(props);

@@ -166,3 +166,3 @@ const { width, height } = props;

function getPolarOrigin(props) {
export function getPolarOrigin(props) {
const { width, height } = props;

@@ -179,3 +179,3 @@ const { top, bottom, left, right } = getPadding(props);

function getRange(props, axis) {
export function getRange(props, axis) {
if (props.range && props.range[axis]) {

@@ -191,3 +191,3 @@ return props.range[axis];

function createAccessor(key) {
export function createAccessor(key) {
// creates a data accessor function

@@ -205,3 +205,3 @@ // given a property key, path, array index, or null for identity.

function modifyProps(props, fallbackProps, role) {
export function modifyProps(props, fallbackProps, role) {
const theme = props.theme && props.theme[role] ? props.theme[role] : {};

@@ -220,3 +220,3 @@ const themeProps = omit(theme, ["style"]);

*/
function getCurrentAxis(axis, horizontal) {
export function getCurrentAxis(axis, horizontal) {
const otherAxis = axis === "x" ? "y" : "x";

@@ -236,3 +236,3 @@ return horizontal ? otherAxis : axis;

/* eslint-disable max-params */
function reduceChildren(
export function reduceChildren(
children,

@@ -305,3 +305,3 @@ iteratee,

*/
function isHorizontal(props) {
export function isHorizontal(props) {
if (props.horizontal !== undefined || !props.children) {

@@ -322,23 +322,1 @@ return props.horizontal;

}
export default {
omit,
getPoint,
scalePoint,
getPadding,
getDefaultStyles,
getStyles,
evaluateProp,
evaluateStyle,
degreesToRadians,
radiansToDegrees,
getRadius,
getPolarOrigin,
getRange,
createAccessor,
modifyProps,
getCurrentAxis,
reduceChildren,
isHorizontal,
isTooltip
};

@@ -1,41 +0,40 @@

export default {
IMMUTABLE_ITERABLE: "@@__IMMUTABLE_ITERABLE__@@",
IMMUTABLE_RECORD: "@@__IMMUTABLE_RECORD__@@",
IMMUTABLE_LIST: "@@__IMMUTABLE_LIST__@@",
IMMUTABLE_MAP: "@@__IMMUTABLE_MAP__@@",
/* eslint-disable func-style */
export const IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
export const IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
export const IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
export const IMMUTABLE_MAP = "@@__IMMUTABLE_MAP__@@";
isImmutable(x) {
return this.isIterable(x) || this.isRecord(x);
},
export function isIterable(x) {
return !!(x && x[IMMUTABLE_ITERABLE]);
}
isIterable(x) {
return !!(x && x[this.IMMUTABLE_ITERABLE]);
},
export function isRecord(x) {
return !!(x && x[IMMUTABLE_RECORD]);
}
isRecord(x) {
return !!(x && x[this.IMMUTABLE_RECORD]);
},
export function isImmutable(x) {
return isIterable(x) || isRecord(x);
}
isList(x) {
return !!(x && x[this.IMMUTABLE_LIST]);
},
export function isList(x) {
return !!(x && x[IMMUTABLE_LIST]);
}
isMap(x) {
return !!(x && x[this.IMMUTABLE_MAP]);
},
export function isMap(x) {
return !!(x && x[IMMUTABLE_MAP]);
}
shallowToJS(x, whitelist) {
return this.isIterable(x)
? x.reduce(
(prev, curr, key) => {
if (whitelist && whitelist[key]) {
curr = this.shallowToJS(curr);
}
prev[key] = curr;
return prev;
},
this.isList(x) ? [] : {}
)
: x;
}
};
export function shallowToJS(x, whitelist) {
return isIterable(x)
? x.reduce(
(prev, curr, key) => {
if (whitelist && whitelist[key]) {
curr = shallowToJS(curr);
}
prev[key] = curr;
return prev;
},
isList(x) ? [] : {}
)
: x;
}
/* eslint-disable func-style */
/* eslint-disable no-use-before-define */
import Helpers from "./helpers";
import * as Helpers from "./helpers";
import { defaults } from "lodash";

@@ -117,3 +117,3 @@

function getText(props, datum, index) {
export function getText(props, datum, index) {
datum = datum || {};

@@ -126,3 +126,3 @@ if (datum.label !== undefined) {

function getPolarTextAnchor(props, degrees) {
export function getPolarTextAnchor(props, degrees) {
const labelPlacement = getLabelPlacement(props);

@@ -138,3 +138,3 @@ if (

function getPolarVerticalAnchor(props, degrees) {
export function getPolarVerticalAnchor(props, degrees) {
const labelPlacement = getLabelPlacement(props);

@@ -152,3 +152,3 @@ const orientation = getPolarOrientation(degrees);

function getPolarAngle(props, baseAngle) {
export function getPolarAngle(props, baseAngle) {
const { labelPlacement, datum } = props;

@@ -173,3 +173,3 @@ if (!labelPlacement || labelPlacement === "vertical") {

function getDegrees(props, datum) {
export function getDegrees(props, datum) {
const { x } = Helpers.getPoint(datum);

@@ -179,3 +179,3 @@ return Helpers.radiansToDegrees(props.scale.x(x)) % 360;

function getProps(props, index) {
export function getProps(props, index) {
const {

@@ -233,10 +233,1 @@ scale,

}
export default {
getText,
getPolarTextAnchor,
getPolarVerticalAnchor,
getPolarAngle,
getDegrees,
getProps
};

@@ -5,10 +5,9 @@ /* global console */

// TODO: Use "warning" npm module like React is switching to.
export default {
warn(message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
// eslint-disable-next-line func-style
export function warn(message) {
if (process.env.NODE_ENV !== "production") {
if (console && console.warn) {
console.warn(message);
}
}
};
}

@@ -0,4 +1,5 @@

/* eslint-disable func-style */
/*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
import { isFunction, find, isRegExp } from "lodash";
import Log from "./log";
import * as Log from "./log";
import PropTypes from "prop-types";

@@ -73,75 +74,75 @@

export default {
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
deprecated(propType, explanation) {
return (props, propName, componentName) => {
const value = props[propName];
if (value !== null && value !== undefined) {
Log.warn(
`"${propName}" property of "${componentName}" has been deprecated ${explanation}`
);
}
return PropTypes.checkPropTypes(
{ [propName]: propType },
props,
propName,
componentName
/**
* Return a new validator based on `propType` but which logs a `console.error`
* with `explanation` if used.
* @param {Function} propType The old, deprecated propType.
* @param {String} explanation The message to provide the user of the deprecated propType.
* @returns {Function} Validator which logs usage of this propType
*/
export function deprecated(propType, explanation) {
return (props, propName, componentName) => {
const value = props[propName];
if (value !== null && value !== undefined) {
Log.warn(
`"${propName}" property of "${componentName}" has been deprecated ${explanation}`
);
};
},
}
return PropTypes.checkPropTypes(
{ [propName]: propType },
props,
propName,
componentName
);
};
}
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
allOfType(validators) {
return makeChainable((props, propName, componentName, ...rest) =>
validators.reduce(
(result, validator) =>
result || validator(props, propName, componentName, ...rest),
undefined
)
/**
* Return a new validator which returns true
* if and only if all validators passed as arguments return true.
* Like React.propTypes.oneOfType, except "all" instead of "any"
* @param {Array} validators Validation functions.
* @returns {Function} Combined validator function
*/
export function allOfType(validators) {
return makeChainable((props, propName, componentName, ...rest) =>
validators.reduce(
(result, validator) =>
result || validator(props, propName, componentName, ...rest),
undefined
)
);
}
/**
* Check that the value is a non-negative number.
*/
export const nonNegative = makeChainable((props, propName, componentName) => {
const value = props[propName];
if (typeof value !== "number" || value < 0) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a non-negative number.`
);
},
}
return undefined;
});
/**
* Check that the value is a non-negative number.
*/
nonNegative: makeChainable((props, propName, componentName) => {
const value = props[propName];
if (typeof value !== "number" || value < 0) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a non-negative number.`
);
}
return undefined;
}),
/**
* Check that the value is an integer.
*/
export const integer = makeChainable((props, propName, componentName) => {
const value = props[propName];
if (typeof value !== "number" || value % 1 !== 0) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be an integer.`
);
}
return undefined;
});
/**
* Check that the value is an integer.
*/
integer: makeChainable((props, propName, componentName) => {
/**
* Check that the value is greater than zero.
*/
export const greaterThanZero = makeChainable(
(props, propName, componentName) => {
const value = props[propName];
if (typeof value !== "number" || value % 1 !== 0) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be an integer.`
);
}
return undefined;
}),
/**
* Check that the value is greater than zero.
*/
greaterThanZero: makeChainable((props, propName, componentName) => {
const value = props[propName];
if (typeof value !== "number" || value <= 0) {

@@ -153,48 +154,48 @@ return new Error(

return undefined;
}),
}
);
/**
* Check that the value is an Array of two unique values.
*/
domain: makeChainable((props, propName, componentName) => {
const value = props[propName];
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be an array of two unique numeric values.`
/**
* Check that the value is an Array of two unique values.
*/
export const domain = makeChainable((props, propName, componentName) => {
const value = props[propName];
if (!Array.isArray(value) || value.length !== 2 || value[1] === value[0]) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be an array of two unique numeric values.`
);
}
return undefined;
});
/**
* Check that the value looks like a d3 `scale` function.
*/
export const scale = makeChainable((props, propName, componentName) => {
const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
const validScale = (scl) => {
if (isFunction(scl)) {
return (
isFunction(scl.copy) && isFunction(scl.domain) && isFunction(scl.range)
);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
return undefined;
}),
return false;
};
/**
* Check that the value looks like a d3 `scale` function.
*/
scale: makeChainable((props, propName, componentName) => {
const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
const validScale = (scl) => {
if (isFunction(scl)) {
return (
isFunction(scl.copy) &&
isFunction(scl.domain) &&
isFunction(scl.range)
);
} else if (typeof scl === "string") {
return supportedScaleStrings.indexOf(scl) !== -1;
}
return false;
};
const value = props[propName];
if (!validScale(value)) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a d3 scale.`
);
}
return undefined;
});
const value = props[propName];
if (!validScale(value)) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a d3 scale.`
);
}
return undefined;
}),
/**
* Check that an array contains items of the same type.
*/
homogeneousArray: makeChainable((props, propName, componentName) => {
/**
* Check that an array contains items of the same type.
*/
export const homogeneousArray = makeChainable(
(props, propName, componentName) => {
const values = props[propName];

@@ -228,29 +229,29 @@ if (!Array.isArray(values)) {

return undefined;
}),
}
);
/**
* Check that array prop length matches props.data.length
*/
matchDataLength: makeChainable((props, propName) => {
if (
props[propName] &&
Array.isArray(props[propName]) &&
props[propName].length !== props.data.length
) {
return new Error(`Length of data and ${propName} arrays must match.`);
}
return undefined;
}),
/**
* Check that array prop length matches props.data.length
*/
export const matchDataLength = makeChainable((props, propName) => {
if (
props[propName] &&
Array.isArray(props[propName]) &&
props[propName].length !== props.data.length
) {
return new Error(`Length of data and ${propName} arrays must match.`);
}
return undefined;
});
/**
* Check that the value is a regular expression
*/
regExp: makeChainable((props, propName, componentName) => {
if (props[propName] && !isRegExp(props[propName])) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a regular expression.`
);
}
return undefined;
})
};
/**
* Check that the value is a regular expression
*/
export const regExp = makeChainable((props, propName, componentName) => {
if (props[propName] && !isRegExp(props[propName])) {
return new Error(
`\`${propName}\` in \`${componentName}\` must be a regular expression.`
);
}
return undefined;
});
/* eslint-disable func-style */
/* eslint-disable no-use-before-define */
import { includes, isFunction, isPlainObject } from "lodash";
import Helpers from "./helpers";
import Collection from "./collection";
import * as Helpers from "./helpers";
import * as Collection from "./collection";
import * as d3Scale from "d3-scale";

@@ -77,7 +77,7 @@

function getScaleFromName(name) {
export function getScaleFromName(name) {
return validScale(name) ? d3Scale[toNewName(name)]() : d3Scale.scaleLinear();
}
function getBaseScale(props, axis) {
export function getBaseScale(props, axis) {
const scale = getScaleFromProps(props, axis);

@@ -92,7 +92,7 @@ if (scale) {

function getDefaultScale() {
export function getDefaultScale() {
return d3Scale.scaleLinear();
}
function getScaleFromProps(props, axis) {
export function getScaleFromProps(props, axis) {
if (!isScaleDefined(props, axis)) {

@@ -108,3 +108,3 @@ return undefined;

function getScaleType(props, axis) {
export function getScaleType(props, axis) {
// if the scale was not given in props, it will be set to linear or time depending on data

@@ -116,3 +116,3 @@ return (

function getType(scale) {
export function getType(scale) {
if (typeof scale === "string") {

@@ -133,10 +133,1 @@ return scale;

}
export default {
getBaseScale,
getDefaultScale,
getScaleFromProps,
getScaleType,
getType,
getScaleFromName
};
/* eslint-disable func-style */
/* eslint-disable no-use-before-define */
import Collection from "./collection";
import * as Collection from "./collection";

@@ -19,3 +19,3 @@ // Private Functions

function getParentSVG(evt) {
export function getParentSVG(evt) {
if (evt.nativeEvent && evt.nativeEvent.identifier !== undefined) {

@@ -34,3 +34,3 @@ return undefined;

function getSVGEventCoordinates(evt, svg) {
export function getSVGEventCoordinates(evt, svg) {
if (evt.nativeEvent && evt.nativeEvent.identifier !== undefined) {

@@ -56,3 +56,3 @@ // react-native override. relies on the RN.View being the _exact_ same size as its child SVG.

function getDomainCoordinates(props, domain) {
export function getDomainCoordinates(props, domain) {
const { scale, horizontal } = props;

@@ -71,3 +71,3 @@ domain = domain || { x: scale.x.domain(), y: scale.y.domain() };

// eslint-disable-next-line max-params
function getDataCoordinates(props, scale, x, y) {
export function getDataCoordinates(props, scale, x, y) {
const { polar, horizontal } = props;

@@ -92,3 +92,3 @@ if (!polar) {

function getBounds(props) {
export function getBounds(props) {
const { x1, x2, y1, y2, scale } = props;

@@ -105,9 +105,1 @@ const point1 = getDataCoordinates(props, scale, x1, y1);

}
export default {
getParentSVG,
getSVGEventCoordinates,
getDomainCoordinates,
getDataCoordinates,
getBounds
};

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

/* eslint-disable func-style */
/**

@@ -10,3 +11,3 @@ * Given an object with CSS/SVG transform definitions, return the string value

*/
const toTransformString = function (obj, ...more) {
export const toTransformString = function (obj, ...more) {
if (more.length > 0) {

@@ -33,36 +34,32 @@ return more

export default {
toTransformString,
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
getColorScale(name) {
const scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: [
"#334D5C",
"#45B29D",
"#EFC94C",
"#E27A3F",
"#DF5A49",
"#4F7DA1",
"#55DBC1",
"#EFDA97",
"#E2A37F",
"#DF948A"
],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}
};
/**
* Given the name of a color scale, getColorScale will return an array
* of 5 hex string values in that color scale. If no 'name' parameter
* is given, it will return the Victory default grayscale.
* @param {String} name The name of the color scale to return (optional).
* @returns {Array} An array of 5 hex string values composing a color scale.
*/
export function getColorScale(name) {
const scales = {
grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
qualitative: [
"#334D5C",
"#45B29D",
"#EFC94C",
"#E27A3F",
"#DF5A49",
"#4F7DA1",
"#55DBC1",
"#EFDA97",
"#E2A37F",
"#DF948A"
],
heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],
warm: ["#940031", "#C43343", "#DC5429", "#FF821D", "#FFAF55"],
cool: ["#2746B9", "#0B69D4", "#2794DB", "#31BB76", "#60E83B"],
red: ["#FCAE91", "#FB6A4A", "#DE2D26", "#A50F15", "#750B0E"],
blue: ["#002C61", "#004B8F", "#006BC9", "#3795E5", "#65B4F4"],
green: ["#354722", "#466631", "#649146", "#8AB25C", "#A9C97E"]
};
return name ? scales[name] : scales.grayscale;
}

@@ -168,3 +168,3 @@ // http://www.pearsonified.com/2012/01/characters-per-line.php

*/
const convertLengthToPixels = (length, fontSize) => {
export const convertLengthToPixels = (length, fontSize) => {
const attribute = length.match(/[a-zA-Z%]+/) && length.match(/[a-zA-Z%]+/)[0];

@@ -244,2 +244,23 @@ const value = length.match(/[0-9.,]+/);

// Stubbable implementation.
export const _approximateTextSizeInternal = {
impl: (text, style) => {
const angle = Array.isArray(style)
? style[0] && style[0].angle
: style && style.angle;
const height = _approximateTextHeightInternal(text, style);
const width = _approximateTextWidthInternal(text, style);
const widthWithRotate = angle
? _getSizeWithRotate(width, height, angle)
: width;
const heightWithRotate = angle
? _getSizeWithRotate(height, width, angle)
: height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
}
};
/**

@@ -256,23 +277,3 @@ * Predict text size by font params.

*/
const approximateTextSize = (text, style) => {
const angle = Array.isArray(style)
? style[0] && style[0].angle
: style && style.angle;
const height = _approximateTextHeightInternal(text, style);
const width = _approximateTextWidthInternal(text, style);
const widthWithRotate = angle
? _getSizeWithRotate(width, height, angle)
: width;
const heightWithRotate = angle
? _getSizeWithRotate(height, width, angle)
: height;
return {
width: widthWithRotate,
height: heightWithRotate * coefficients.heightOverlapCoef
};
};
export default {
approximateTextSize,
convertLengthToPixels
};
export const approximateTextSize = (text, style) =>
_approximateTextSizeInternal.impl(text, style);

@@ -77,3 +77,3 @@ /* eslint-disable func-style */

*/
function getInitialTransitionState(oldChildren, nextChildren) {
export function getInitialTransitionState(oldChildren, nextChildren) {
let nodesWillExit = false;

@@ -261,3 +261,3 @@ let nodesWillEnter = false;

*/
function getTransitionPropsFactory(props, state, setState) {
export function getTransitionPropsFactory(props, state, setState) {
const nodesWillExit = state && state.nodesWillExit;

@@ -407,6 +407,1 @@ const nodesWillEnter = state && state.nodesWillEnter;

}
export default {
getInitialTransitionState,
getTransitionPropsFactory
};

@@ -14,12 +14,12 @@ import {

import React from "react";
import Axis from "./axis";
import Style from "./style";
import Transitions from "./transitions";
import Data from "./data";
import Domain from "./domain";
import Events from "./events";
import Collection from "./collection";
import Helpers from "./helpers";
import Scale from "./scale";
import Log from "./log";
import * as Axis from "./axis";
import * as Style from "./style";
import * as Transitions from "./transitions";
import * as Data from "./data";
import * as Domain from "./domain";
import * as Events from "./events";
import * as Collection from "./collection";
import * as Helpers from "./helpers";
import * as Scale from "./scale";
import * as Log from "./log";

@@ -26,0 +26,0 @@ export default {

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