victory-core
Advanced tools
Comparing version 36.8.2 to 36.8.3
# victory-core | ||
## 36.8.3 | ||
### Patch Changes | ||
- Fix incorrect typescript props ([#2745](https://github.com/FormidableLabs/victory/pull/2745)) | ||
* Refactor param reassignments ([#2724](https://github.com/FormidableLabs/victory/pull/2724)) | ||
- Migrate victory-shared-events to TypeScript ([#2733](https://github.com/FormidableLabs/victory/pull/2733)) | ||
* Migrate victory-tooltip to typescript ([#2725](https://github.com/FormidableLabs/victory/pull/2725)) | ||
## 36.8.2 | ||
@@ -4,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { D3Scale, Datum, ID } from "./prop-types"; | ||
import { D3Scale, Datum, ID, ScalePropType } from "./prop-types"; | ||
import { BlockProps, OrientationTypes } from "../victory-theme/types"; | ||
@@ -18,5 +18,5 @@ /** | ||
y?: number; | ||
scale?: { | ||
x?: D3Scale; | ||
y?: D3Scale; | ||
scale?: ScalePropType | D3Scale | { | ||
x?: ScalePropType | D3Scale; | ||
y?: ScalePropType | D3Scale; | ||
}; | ||
@@ -23,0 +23,0 @@ tick?: any; |
@@ -37,7 +37,7 @@ export declare const isInterpolatable: (obj: any) => boolean; | ||
* | ||
* @param {any} a - Start value. | ||
* @param {any} b - End value. | ||
* @param {any} startValue - Start value. | ||
* @param {any} endValue - End value. | ||
* @returns {Function} An interpolation function. | ||
*/ | ||
export declare const interpolateObject: (a: any, b: any) => (t: any) => {}; | ||
export declare const interpolateObject: (startValue: any, endValue: any) => (t: any) => {}; | ||
export declare const interpolateString: (a: any, b: any) => (t: number) => any; | ||
@@ -44,0 +44,0 @@ /** |
@@ -103,8 +103,8 @@ import _orderBy from "lodash/orderBy"; | ||
* | ||
* @param {any} a - Start value. | ||
* @param {any} b - End value. | ||
* @param {any} startValue - Start value. | ||
* @param {any} endValue - End value. | ||
* @returns {Function} An interpolation function. | ||
*/ | ||
export var interpolateObject = function (a, b) { | ||
export var interpolateObject = function (startValue, endValue) { | ||
var interpolateTypes = function (x, y) { | ||
@@ -134,2 +134,4 @@ if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) { | ||
var c = {}; | ||
var a = startValue; | ||
var b = endValue; | ||
var k; | ||
@@ -136,0 +138,0 @@ |
@@ -64,4 +64,4 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
*/ | ||
duration = duration !== undefined ? duration : _this.props.duration; | ||
var step = duration ? elapsed / duration : 1; | ||
var animationDuration = duration !== undefined ? duration : _this.props.duration; | ||
var step = animationDuration ? elapsed / animationDuration : 1; | ||
@@ -68,0 +68,0 @@ if (step >= 1) { |
@@ -20,3 +20,3 @@ import React from "react"; | ||
className?: string; | ||
datum?: object; | ||
datum?: Record<string, any>; | ||
data?: any[]; | ||
@@ -23,0 +23,0 @@ desc?: string; |
@@ -94,4 +94,3 @@ import _isEmpty from "lodash/isEmpty"; | ||
var getSingleStyle = function (s) { | ||
s = s ? _defaults({}, s, defaultStyles) : defaultStyles; | ||
var baseStyles = Helpers.evaluateStyle(s, props); | ||
var baseStyles = Helpers.evaluateStyle(s ? _defaults({}, s, defaultStyles) : defaultStyles, props); | ||
return _assign({}, baseStyles, { | ||
@@ -300,4 +299,3 @@ fontSize: getFontSize(baseStyles) | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i < index ? memo + width : memo; | ||
return memo; | ||
return i < index ? memo + width : memo; | ||
}, 0); | ||
@@ -307,4 +305,3 @@ | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i > index ? memo - width : memo; | ||
return memo; | ||
return i > index ? memo - width : memo; | ||
}, 0); | ||
@@ -316,4 +313,3 @@ | ||
var offsetWidth = i < index ? width : 0; | ||
memo = i === index ? memo + width / 2 : memo + offsetWidth; | ||
return memo; | ||
return i === index ? memo + width / 2 : memo + offsetWidth; | ||
}, centerOffset); | ||
@@ -520,4 +516,4 @@ } | ||
}; | ||
export var VictoryLabel = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var VictoryLabel = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
@@ -543,3 +539,3 @@ if (props.text === null || props.text === undefined) { | ||
text: line, | ||
// @ts-expect-error TODO: This looks like a bug: | ||
// TODO: This looks like a bug: | ||
textSize: TextSize.approximateTextSize(line, currentStyle), | ||
@@ -546,0 +542,0 @@ lineHeight: currentLineHeight, |
@@ -15,3 +15,3 @@ import React from "react"; | ||
export declare const Arc: { | ||
(props: ArcProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: ArcProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ closedPath: PropTypes.Requireable<boolean>; |
@@ -71,4 +71,4 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var Arc = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var Arc = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/React.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -75,0 +75,0 @@ "aria-label": props.ariaLabel, |
@@ -15,3 +15,3 @@ import React from "react"; | ||
export declare const Background: { | ||
(props: BackgroundProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: BackgroundProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ circleComponent: PropTypes.Requireable<PropTypes.ReactElementLike>; |
@@ -33,4 +33,4 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var Background = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var Background = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return props.polar ? /*#__PURE__*/React.cloneElement(props.circleComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -37,0 +37,0 @@ style: props.style, |
@@ -12,3 +12,3 @@ import React from "react"; | ||
export declare const Border: { | ||
(props: BorderProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: BorderProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -15,0 +15,0 @@ height: PropTypes.Requireable<number>; |
@@ -45,4 +45,4 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var Border = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var Border = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/React.cloneElement(props.rectComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -49,0 +49,0 @@ "aria-label": props.ariaLabel, |
@@ -13,3 +13,3 @@ import React from "react"; | ||
export declare const LineSegment: { | ||
(props: LineSegmentProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: LineSegmentProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -16,0 +16,0 @@ datum: PropTypes.Requireable<any>; |
@@ -45,4 +45,4 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var LineSegment = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var LineSegment = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/React.cloneElement(props.lineComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -49,0 +49,0 @@ "aria-label": props.ariaLabel, |
@@ -15,3 +15,3 @@ import PropTypes from "prop-types"; | ||
export declare const Point: { | ||
(props: PointProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: PointProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ datum: PropTypes.Requireable<object>; |
@@ -66,4 +66,4 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var Point = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
export var Point = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
var userProps = UserProps.getSafeUserProps(props); | ||
@@ -70,0 +70,0 @@ return /*#__PURE__*/React.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, { |
@@ -17,3 +17,3 @@ import React from "react"; | ||
export declare const Whisker: { | ||
(props: WhiskerProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: WhiskerProps): React.DetailedReactHTMLElement<{}, HTMLElement>; | ||
propTypes: { | ||
@@ -20,0 +20,0 @@ groupComponent: PropTypes.Requireable<PropTypes.ReactElementLike>; |
@@ -44,19 +44,18 @@ import _assign from "lodash/assign"; | ||
}; | ||
export var Whisker = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var _props = props, | ||
ariaLabel = _props.ariaLabel, | ||
groupComponent = _props.groupComponent, | ||
lineComponent = _props.lineComponent, | ||
events = _props.events, | ||
className = _props.className, | ||
majorWhisker = _props.majorWhisker, | ||
minorWhisker = _props.minorWhisker, | ||
transform = _props.transform, | ||
clipPath = _props.clipPath, | ||
role = _props.role, | ||
shapeRendering = _props.shapeRendering, | ||
style = _props.style, | ||
desc = _props.desc, | ||
tabIndex = _props.tabIndex; | ||
export var Whisker = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
var ariaLabel = props.ariaLabel, | ||
groupComponent = props.groupComponent, | ||
lineComponent = props.lineComponent, | ||
events = props.events, | ||
className = props.className, | ||
majorWhisker = props.majorWhisker, | ||
minorWhisker = props.minorWhisker, | ||
transform = props.transform, | ||
clipPath = props.clipPath, | ||
role = props.role, | ||
shapeRendering = props.shapeRendering, | ||
style = props.style, | ||
desc = props.desc, | ||
tabIndex = props.tabIndex; | ||
@@ -63,0 +62,0 @@ var baseProps = _objectSpread(_objectSpread({}, events), {}, { |
@@ -225,4 +225,3 @@ import _without from "lodash/without"; | ||
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) { | ||
memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo; | ||
return memo; | ||
return _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo; | ||
}, []); | ||
@@ -282,4 +281,4 @@ var compiledCallbacks = callbacks.length ? function () { | ||
value: function getBaseProps(props, getSharedEventState) { | ||
getSharedEventState = getSharedEventState || this.getSharedEventState.bind(this); | ||
var sharedParentState = getSharedEventState("parent", "parent"); | ||
var getSharedEventStateFunction = getSharedEventState || this.getSharedEventState.bind(this); | ||
var sharedParentState = getSharedEventStateFunction("parent", "parent"); | ||
var parentState = this.getEventState("parent", "parent"); | ||
@@ -383,9 +382,11 @@ | ||
var labelComponents = dataKeys.reduce(function (memo, key) { | ||
var newMemo = memo; | ||
var labelProps = _this8.getComponentProps(labelComponent, "labels", key); | ||
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) { | ||
memo = memo.concat( /*#__PURE__*/React.cloneElement(labelComponent, labelProps)); | ||
newMemo = newMemo.concat( /*#__PURE__*/React.cloneElement(labelComponent, labelProps)); | ||
} | ||
return memo; | ||
return newMemo; | ||
}, []); | ||
@@ -392,0 +393,0 @@ var dataProps = this.getComponentProps(dataComponent, "data", "all"); |
@@ -49,7 +49,7 @@ import _without from "lodash/without"; | ||
export function findAxisComponents(childComponents, predicate) { | ||
predicate = predicate || _identity; | ||
var predicateFunction = predicate || _identity; | ||
var findAxes = function (children) { | ||
return children.reduce(function (memo, child) { | ||
if (child.type && child.type.role === "axis" && predicate(child)) { | ||
if (child.type && child.type.role === "axis" && predicateFunction(child)) { | ||
return memo.concat(child); | ||
@@ -56,0 +56,0 @@ } else if (child.props && child.props.children) { |
@@ -23,2 +23,3 @@ import * as React from "react"; | ||
containerComponent?: React.ReactElement; | ||
disableInlineStyles?: boolean; | ||
domainPadding?: DomainPaddingPropType; | ||
@@ -25,0 +26,0 @@ externalEventMutations?: EventCallbackInterface<string | string[], StringOrNumberOrList>[]; |
@@ -69,8 +69,10 @@ import _omitBy from "lodash/omitBy"; | ||
var formattedSortKey = sortKey; | ||
if (sortKey === "x" || sortKey === "y") { | ||
sortKey = "_".concat(sortKey); | ||
formattedSortKey = "_".concat(sortKey); | ||
} | ||
var order = sortOrder === "ascending" ? "asc" : "desc"; | ||
return _orderBy(dataset, sortKey, order); | ||
return _orderBy(dataset, formattedSortKey, order); | ||
} // This method will remove data points that break certain scales. (log scale only) | ||
@@ -266,3 +268,6 @@ | ||
var defaultKeys = ["x", "y", "y0"]; | ||
var defaultKeys = ["x", "y", "y0"]; // TODO: We shouldn’t mutate the expectedKeys param here, | ||
// but we need to figure out why changing it causes regressions in tests. | ||
// eslint-disable-next-line no-param-reassign | ||
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys; | ||
@@ -292,9 +297,9 @@ | ||
// eslint-disable-line complexity | ||
datum = parseDatum(datum); | ||
var parsedDatum = parseDatum(datum); | ||
var fallbackValues = { | ||
x: index, | ||
y: datum | ||
y: parsedDatum | ||
}; | ||
var processedValues = expectedKeys.reduce(function (memo, type) { | ||
var processedValue = accessor[type](datum); | ||
var processedValue = accessor[type](parsedDatum); | ||
var value = processedValue !== undefined ? processedValue : fallbackValues[type]; | ||
@@ -314,3 +319,3 @@ | ||
var formattedDatum = _assign({}, processedValues, datum); | ||
var formattedDatum = _assign({}, processedValues, parsedDatum); | ||
@@ -426,4 +431,4 @@ if (!_isEmpty(formattedDatum)) { | ||
var dataStrings = sortedData.reduce(function (dataArr, datum) { | ||
datum = parseDatum(datum); | ||
dataArr.push(accessor(datum)); | ||
var parsedDatum = parseDatum(datum); | ||
dataArr.push(accessor(parsedDatum)); | ||
return dataArr; | ||
@@ -430,0 +435,0 @@ }, []).filter(function (datum) { |
@@ -167,4 +167,4 @@ import _isDate from "lodash/isDate"; | ||
export function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) { | ||
getDomainFromDataFunction = _isFunction(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData; | ||
formatDomainFunction = _isFunction(formatDomainFunction) ? formatDomainFunction : formatDomain; | ||
var getDomainFromDataFn = _isFunction(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData; | ||
var formatDomainFn = _isFunction(formatDomainFunction) ? formatDomainFunction : formatDomain; | ||
return function (props, axis) { | ||
@@ -174,8 +174,8 @@ var propsDomain = getDomainFromProps(props, axis); | ||
if (propsDomain) { | ||
return formatDomainFunction(propsDomain, props, axis); | ||
return formatDomainFn(propsDomain, props, axis); | ||
} | ||
var categories = Data.getCategories(props, axis); | ||
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFunction(props, axis); | ||
return domain ? formatDomainFunction(domain, props, axis) : undefined; | ||
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFn(props, axis); | ||
return domain ? formatDomainFn(domain, props, axis) : undefined; | ||
}; | ||
@@ -213,3 +213,3 @@ } | ||
export function getDomainFromCategories(props, axis, categories) { | ||
categories = categories || Data.getCategories(props, axis); | ||
var categoriesArray = categories || Data.getCategories(props, axis); | ||
var polar = props.polar, | ||
@@ -221,3 +221,3 @@ _props$startAngle = props.startAngle, | ||
if (!categories) { | ||
if (!categoriesArray) { | ||
return undefined; | ||
@@ -228,3 +228,3 @@ } | ||
var maxDomain = getMaxFromProps(props, axis); | ||
var stringArray = Collection.containsStrings(categories) ? Data.getStringsFromCategories(props, axis) : []; | ||
var stringArray = Collection.containsStrings(categoriesArray) ? Data.getStringsFromCategories(props, axis) : []; | ||
var stringMap = stringArray.length === 0 ? null : stringArray.reduce(function (memo, string, index) { | ||
@@ -234,5 +234,5 @@ memo[string] = index + 1; | ||
}, {}); | ||
var categoryValues = stringMap ? categories.map(function (value) { | ||
var categoryValues = stringMap ? categoriesArray.map(function (value) { | ||
return stringMap[value]; | ||
}) : categories; | ||
}) : categoriesArray; | ||
var min = minDomain !== undefined ? minDomain : Collection.getMinValue(categoryValues); | ||
@@ -252,3 +252,3 @@ var max = maxDomain !== undefined ? maxDomain : Collection.getMaxValue(categoryValues); | ||
export function getDomainFromData(props, axis, dataset) { | ||
dataset = dataset || Data.getData(props); | ||
var datasetArray = dataset || Data.getData(props); | ||
var polar = props.polar, | ||
@@ -262,10 +262,10 @@ _props$startAngle2 = props.startAngle, | ||
if (dataset.length < 1) { | ||
if (datasetArray.length < 1) { | ||
return minDomain !== undefined && maxDomain !== undefined ? getDomainFromMinMax(minDomain, maxDomain) : undefined; | ||
} | ||
var min = minDomain !== undefined ? minDomain : getExtremeFromData(dataset, axis, "min"); | ||
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(dataset, axis, "max"); | ||
var min = minDomain !== undefined ? minDomain : getExtremeFromData(datasetArray, axis, "min"); | ||
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(datasetArray, axis, "max"); | ||
var domain = getDomainFromMinMax(min, max); | ||
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(dataset, axis)) : domain; | ||
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(datasetArray, axis)) : domain; | ||
} | ||
@@ -272,0 +272,0 @@ /** |
@@ -19,3 +19,3 @@ /// <reference types="react" /> | ||
} | ||
export declare function getEvents(this: ComponentWithEvents, props: any, target: any, eventKey: any, getScopedEvents: any): any; | ||
export declare function getEvents(this: ComponentWithEvents, props: any, target?: any, eventKey?: any, getScopedEvents?: any): any; | ||
export declare function getScopedEvents(this: ComponentWithEvents, events: any, namespace: any, childType: any, baseProps: any): {}; | ||
@@ -37,3 +37,3 @@ export declare function getPartialEvents(events: ComponentEventHandlers, eventKey: ComponentEventKey, childProps: unknown): PartialEvents; | ||
*/ | ||
export declare function getExternalMutationsWithChildren(mutations: any, baseProps: any, baseState: any, childNames: any): any; | ||
export declare function getExternalMutationsWithChildren(mutations: any, baseProps: {} | undefined, baseState: {} | undefined, childNames: any): any; | ||
/** | ||
@@ -49,3 +49,3 @@ * Returns a set of all mutations for a component | ||
*/ | ||
export declare function getExternalMutations(mutations: any, baseProps: any, baseState: any, childName?: any): {}; | ||
export declare function getExternalMutations(mutations: any, baseProps?: {}, baseState?: {}, childName?: any): {}; | ||
/** | ||
@@ -52,0 +52,0 @@ * Returns a set of mutations for a particular element given scoped baseProps and baseState |
@@ -120,3 +120,3 @@ import _keys from "lodash/keys"; | ||
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element | ||
var newBaseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element | ||
@@ -128,3 +128,3 @@ var getTargetProps = function (identifier, type) { | ||
var baseType = type === "props" ? baseProps : _this2.state || {}; | ||
var baseType = type === "props" ? newBaseProps : _this2.state || {}; | ||
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName]; | ||
@@ -217,4 +217,3 @@ return key === "parent" ? base.parent : base[key] && base[key][target]; | ||
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) { | ||
memo = _assign({}, memo, parseEvent(props, eventKey)); | ||
return memo; | ||
return _assign({}, memo, parseEvent(props, eventKey)); | ||
}, {}) : parseEvent(eventReturn, eventKey); | ||
@@ -305,5 +304,6 @@ }; | ||
export function getExternalMutationsWithChildren(mutations, baseProps, baseState, childNames) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
export function getExternalMutationsWithChildren(mutations) { | ||
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var childNames = arguments.length > 3 ? arguments[3] : undefined; | ||
return childNames.reduce(function (memo, childName) { | ||
@@ -330,5 +330,6 @@ var childState = baseState[childName]; | ||
export function getExternalMutations(mutations, baseProps, baseState, childName) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
export function getExternalMutations(mutations) { | ||
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var childName = arguments.length > 3 ? arguments[3] : undefined; | ||
@@ -399,4 +400,3 @@ var eventKeys = _keys(baseProps); | ||
mutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
var scopedMutations = mutations; | ||
var scopedMutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
@@ -440,9 +440,6 @@ if (identifier.childName) { | ||
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 Array.isArray(componentEvents) ? memo.concat.apply(memo, _toConsumableArray(componentEvents)) : memo; | ||
}, []); | ||
@@ -449,0 +446,0 @@ return events && events.length ? events : undefined; |
@@ -290,2 +290,3 @@ import _keys from "lodash/keys"; | ||
return childArray.reduce(function (memo, child, index) { | ||
var newMemo = memo; | ||
var childRole = child.type && child.type.role; | ||
@@ -308,3 +309,3 @@ var childName = child.props.name || "".concat(childRole, "-").concat(names[index]); | ||
var nestedResults = traverseChildren(nestedChildren, _childNames, child); | ||
memo = combine(memo, nestedResults); | ||
newMemo = combine(newMemo, nestedResults); | ||
} else { | ||
@@ -314,7 +315,7 @@ var result = iteratee(child, childName, parent); | ||
if (result) { | ||
memo = combine(memo, result); | ||
newMemo = combine(newMemo, result); | ||
} | ||
} | ||
return memo; | ||
return newMemo; | ||
}, initialMemo); | ||
@@ -345,4 +346,3 @@ }; | ||
if (memo || childProps.horizontal || !childProps.children) { | ||
memo = memo || childProps.horizontal; | ||
return memo; | ||
return memo || childProps.horizontal; | ||
} | ||
@@ -349,0 +349,0 @@ |
@@ -22,9 +22,11 @@ export var IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@"; | ||
return isIterable(x) ? x.reduce(function (result, curr, key) { | ||
var newCurr = curr; | ||
if (whitelist && whitelist[key]) { | ||
curr = shallowToJS(curr); | ||
newCurr = shallowToJS(curr); | ||
} | ||
result[key] = curr; | ||
result[key] = newCurr; | ||
return result; | ||
}, isList(x) ? [] : {}) : x; | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare function getText(props: any, datum: any, index: any): any; | ||
export declare function getText(props: any, datum: Record<string, any> | undefined, index: any): any; | ||
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle"; | ||
@@ -3,0 +3,0 @@ export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle"; |
import _defaults from "lodash/defaults"; | ||
/* eslint-disable no-use-before-define */ | ||
import * as Helpers from "./helpers"; | ||
// Private Functions | ||
function getVerticalAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getVerticalAnchor(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var sign = datum._y >= 0 ? 1 : -1; | ||
@@ -21,4 +19,4 @@ var labelStyle = props.style && props.style.labels || {}; | ||
function getTextAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getTextAnchor(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var style = props.style, | ||
@@ -38,4 +36,4 @@ horizontal = props.horizontal; | ||
function getAngle(props, datum) { | ||
datum = datum || {}; | ||
function getAngle(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var labelStyle = props.style && props.style.labels || {}; | ||
@@ -45,4 +43,4 @@ return datum.angle === undefined ? labelStyle.angle : datum.angle; | ||
function getPadding(props, datum) { | ||
datum = datum || {}; | ||
function getPadding(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var horizontal = props.horizontal, | ||
@@ -126,4 +124,5 @@ style = props.style; | ||
export function getText(props, datum, index) { | ||
datum = datum || {}; | ||
export function getText(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var index = arguments.length > 2 ? arguments[2] : undefined; | ||
@@ -130,0 +129,0 @@ if (datum.label !== undefined) { |
@@ -52,4 +52,3 @@ import * as Collection from "./collection"; | ||
var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt; | ||
svg = svg || getParentSVG(location); | ||
var matrix = getTransformationMatrix(svg); | ||
var matrix = getTransformationMatrix(svg || getParentSVG(location)); | ||
return { | ||
@@ -56,0 +55,0 @@ x: transformTarget(location.clientX, matrix, "x"), |
@@ -60,7 +60,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
value: function subscribe(callback, duration) { | ||
duration = this.shouldAnimate ? duration : 0; | ||
var subscriptionID = this.subscribers.push({ | ||
startTime: now(), | ||
callback: callback, | ||
duration: duration | ||
duration: this.shouldAnimate ? duration : 0 | ||
}); | ||
@@ -67,0 +66,0 @@ this.activeSubscriptions++; |
@@ -139,9 +139,9 @@ import _keys from "lodash/keys"; | ||
function getChildBeforeLoad(animate, child, data, cb) { | ||
animate = _assign({}, animate, { | ||
var newAnimate = _assign({}, animate, { | ||
onEnd: cb | ||
}); | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { | ||
animate: animate, | ||
animate: newAnimate, | ||
data: data | ||
@@ -151,10 +151,10 @@ }; | ||
var before = animate.onLoad && animate.onLoad.before ? animate.onLoad.before : _identity; // If nodes need to exit, transform them with the provided onLoad.before function. | ||
var before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity; // If nodes need to exit, transform them with the provided onLoad.before function. | ||
data = data.map(function (datum, idx) { | ||
var newData = data.map(function (datum, idx) { | ||
return _assign({}, datum, before(datum, idx, data)); | ||
}); | ||
return { | ||
animate: animate, | ||
data: data, | ||
animate: newAnimate, | ||
data: newData, | ||
clipWidth: 0 | ||
@@ -166,7 +166,9 @@ }; | ||
function getChildOnLoad(animate, data, cb) { | ||
animate = _assign({}, animate, { | ||
var newAnimate = _assign({}, animate, { | ||
onEnd: cb | ||
}); | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
var newData = data; | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { | ||
@@ -180,8 +182,8 @@ animate: animate, | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
return _assign({}, datum, after(datum, idx, data)); | ||
}); | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -195,4 +197,7 @@ } // eslint-disable-next-line max-params, max-len | ||
var onExit = animate && animate.onExit; | ||
animate = _assign({}, animate, onExit); | ||
var newAnimate = _assign({}, animate, onExit); | ||
var newData = data; | ||
if (exitingNodes) { | ||
@@ -204,3 +209,3 @@ // After the exit transition occurs, trigger the animations for | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
var key = (datum.key || idx).toString(); | ||
@@ -212,4 +217,4 @@ return exitingNodes[key] ? _assign({}, datum, before(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -220,6 +225,9 @@ } // eslint-disable-next-line max-params,max-len | ||
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) { | ||
var newAnimate = animate; | ||
var newData = data; | ||
if (enteringNodes) { | ||
// Perform a normal animation here, except - when it finishes - trigger | ||
// the transition for entering nodes. | ||
animate = _assign({}, animate, { | ||
newAnimate = _assign({}, animate, { | ||
onEnd: cb | ||
@@ -231,3 +239,3 @@ }); | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
var key = (datum.key || idx).toString(); | ||
@@ -239,4 +247,4 @@ return enteringNodes[key] ? _assign({}, datum, before(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -250,4 +258,7 @@ } // eslint-disable-next-line max-params, max-len | ||
var onEnter = animate && animate.onEnter; | ||
animate = _assign({}, animate, onEnter); | ||
var newAnimate = _assign({}, animate, onEnter); | ||
var newData = data; | ||
if (enteringNodes) { | ||
@@ -257,5 +268,5 @@ // Old nodes have been transitioned to their new values, and the | ||
// the `onEnter.after` transformation on each node. | ||
animate.onEnd = cb; | ||
var after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity; | ||
data = data.map(function (datum, idx) { | ||
newAnimate.onEnd = cb; | ||
var after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity; | ||
newData = data.map(function (datum, idx) { | ||
var key = getDatumKey(datum, idx); | ||
@@ -267,4 +278,4 @@ return enteringNodes[key] ? _assign({}, datum, after(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -271,0 +282,0 @@ } |
import * as React from "react"; | ||
declare type SafeAttribute = string; | ||
/** | ||
* Asserts that value is not null or undefined, throwing an error if it is. | ||
* @param value The value to assert | ||
* @param message The error message to throw | ||
*/ | ||
export declare function assert<T>(value: T, message?: string): asserts value is NonNullable<T>; | ||
/** | ||
* getSafeUserProps - function that takes in a props object and removes any | ||
@@ -5,0 +11,0 @@ * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST |
@@ -76,2 +76,14 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
/** | ||
* Asserts that value is not null or undefined, throwing an error if it is. | ||
* @param value The value to assert | ||
* @param message The error message to throw | ||
*/ | ||
export function assert(value, message) { | ||
if (value === undefined || value === null) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* getSafeUserProps - function that takes in a props object and removes any | ||
@@ -85,3 +97,2 @@ * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST | ||
export var getSafeUserProps = function (props) { | ||
@@ -88,0 +99,0 @@ var propsToFilter = _objectSpread({}, props); |
@@ -117,2 +117,3 @@ import _isPlainObject from "lodash/isPlainObject"; | ||
var childData; | ||
var childElement = child; | ||
@@ -122,4 +123,4 @@ if (!Data.isDataComponent(child)) { | ||
} else if (child.type && _isFunction(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child; | ||
childData = child.type.getData(childProps); | ||
childElement = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child; | ||
childData = childElement.type.getData(childProps); | ||
} else { | ||
@@ -155,4 +156,3 @@ childData = Data.getData(childProps); | ||
childComponents = childComponents || React.Children.toArray(props.children); | ||
return getDataFromChildren(props, childComponents); | ||
return getDataFromChildren(props, childComponents || React.Children.toArray(props.children)); | ||
} | ||
@@ -164,5 +164,5 @@ export function getWidth(props, groupLength, seriesLength) { | ||
var extent = Math.abs(range[1] - range[0]); | ||
seriesLength = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1; | ||
groupLength = groupLength || datasets.length; | ||
var bars = groupLength * seriesLength; | ||
var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1; | ||
var groupLengthValue = groupLength || datasets.length; | ||
var bars = groupLengthValue * seriesLengthValue; | ||
var barRatio = 0.5; | ||
@@ -259,5 +259,5 @@ return Math.round(barRatio * extent / bars); | ||
export function getDomain(props, axis, childComponents) { | ||
childComponents = childComponents || React.Children.toArray(props.children); | ||
var children = childComponents || React.Children.toArray(props.children); | ||
var propsDomain = Domain.getDomainFromProps(props, axis); | ||
var domainPadding = getDefaultDomainPadding(props, axis, childComponents); | ||
var domainPadding = getDefaultDomainPadding(props, axis, children); | ||
var domain; | ||
@@ -272,3 +272,3 @@ | ||
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : []; | ||
var childDomain = getDomainFromChildren(props, axis, childComponents); | ||
var childDomain = getDomainFromChildren(props, axis, children); | ||
var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain))); | ||
@@ -435,6 +435,6 @@ var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain))); | ||
export function getStringsFromChildren(props, childComponents) { | ||
childComponents = childComponents || React.Children.toArray(props.children); | ||
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", childComponents); | ||
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents); | ||
var dataStrings = getStringsFromData(childComponents); | ||
var children = childComponents || React.Children.toArray(props.children); | ||
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children); | ||
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children); | ||
var dataStrings = getStringsFromData(children); | ||
return { | ||
@@ -441,0 +441,0 @@ x: _uniq(_flatten([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))), |
@@ -1,2 +0,2 @@ | ||
import { D3Scale, Datum, ID } from "./prop-types"; | ||
import { D3Scale, Datum, ID, ScalePropType } from "./prop-types"; | ||
import { BlockProps, OrientationTypes } from "../victory-theme/types"; | ||
@@ -18,5 +18,5 @@ /** | ||
y?: number; | ||
scale?: { | ||
x?: D3Scale; | ||
y?: D3Scale; | ||
scale?: ScalePropType | D3Scale | { | ||
x?: ScalePropType | D3Scale; | ||
y?: ScalePropType | D3Scale; | ||
}; | ||
@@ -23,0 +23,0 @@ tick?: any; |
@@ -37,7 +37,7 @@ export declare const isInterpolatable: (obj: any) => boolean; | ||
* | ||
* @param {any} a - Start value. | ||
* @param {any} b - End value. | ||
* @param {any} startValue - Start value. | ||
* @param {any} endValue - End value. | ||
* @returns {Function} An interpolation function. | ||
*/ | ||
export declare const interpolateObject: (a: any, b: any) => (t: any) => {}; | ||
export declare const interpolateObject: (startValue: any, endValue: any) => (t: any) => {}; | ||
export declare const interpolateString: (a: any, b: any) => (t: number) => any; | ||
@@ -44,0 +44,0 @@ /** |
@@ -121,4 +121,4 @@ "use strict"; | ||
* | ||
* @param {any} a - Start value. | ||
* @param {any} b - End value. | ||
* @param {any} startValue - Start value. | ||
* @param {any} endValue - End value. | ||
* @returns {Function} An interpolation function. | ||
@@ -130,3 +130,3 @@ */ | ||
var interpolateObject = function (a, b) { | ||
var interpolateObject = function (startValue, endValue) { | ||
var interpolateTypes = function (x, y) { | ||
@@ -156,2 +156,4 @@ if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) { | ||
var c = {}; | ||
var a = startValue; | ||
var b = endValue; | ||
var k; | ||
@@ -158,0 +160,0 @@ |
@@ -82,4 +82,4 @@ "use strict"; | ||
*/ | ||
duration = duration !== undefined ? duration : _this.props.duration; | ||
var step = duration ? elapsed / duration : 1; | ||
var animationDuration = duration !== undefined ? duration : _this.props.duration; | ||
var step = animationDuration ? elapsed / animationDuration : 1; | ||
@@ -86,0 +86,0 @@ if (step >= 1) { |
@@ -20,3 +20,3 @@ import React from "react"; | ||
className?: string; | ||
datum?: object; | ||
datum?: Record<string, any>; | ||
data?: any[]; | ||
@@ -23,0 +23,0 @@ desc?: string; |
@@ -122,4 +122,3 @@ "use strict"; | ||
var getSingleStyle = function (s) { | ||
s = s ? (0, _defaults2.default)({}, s, defaultStyles) : defaultStyles; | ||
var baseStyles = Helpers.evaluateStyle(s, props); | ||
var baseStyles = Helpers.evaluateStyle(s ? (0, _defaults2.default)({}, s, defaultStyles) : defaultStyles, props); | ||
return (0, _assign2.default)({}, baseStyles, { | ||
@@ -328,4 +327,3 @@ fontSize: getFontSize(baseStyles) | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i < index ? memo + width : memo; | ||
return memo; | ||
return i < index ? memo + width : memo; | ||
}, 0); | ||
@@ -335,4 +333,3 @@ | ||
return widths.reduce(function (memo, width, i) { | ||
memo = i > index ? memo - width : memo; | ||
return memo; | ||
return i > index ? memo - width : memo; | ||
}, 0); | ||
@@ -344,4 +341,3 @@ | ||
var offsetWidth = i < index ? width : 0; | ||
memo = i === index ? memo + width / 2 : memo + offsetWidth; | ||
return memo; | ||
return i === index ? memo + width / 2 : memo + offsetWidth; | ||
}, centerOffset); | ||
@@ -549,4 +545,4 @@ } | ||
var VictoryLabel = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var VictoryLabel = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
@@ -572,3 +568,3 @@ if (props.text === null || props.text === undefined) { | ||
text: line, | ||
// @ts-expect-error TODO: This looks like a bug: | ||
// TODO: This looks like a bug: | ||
textSize: TextSize.approximateTextSize(line, currentStyle), | ||
@@ -575,0 +571,0 @@ lineHeight: currentLineHeight, |
@@ -15,3 +15,3 @@ import React from "react"; | ||
export declare const Arc: { | ||
(props: ArcProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: ArcProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ closedPath: PropTypes.Requireable<boolean>; |
@@ -88,4 +88,4 @@ "use strict"; | ||
var Arc = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var Arc = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -92,0 +92,0 @@ "aria-label": props.ariaLabel, |
@@ -15,3 +15,3 @@ import React from "react"; | ||
export declare const Background: { | ||
(props: BackgroundProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: BackgroundProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ circleComponent: PropTypes.Requireable<PropTypes.ReactElementLike>; |
@@ -52,4 +52,4 @@ "use strict"; | ||
var Background = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var Background = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return props.polar ? /*#__PURE__*/_react.default.cloneElement(props.circleComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -56,0 +56,0 @@ style: props.style, |
@@ -12,3 +12,3 @@ import React from "react"; | ||
export declare const Border: { | ||
(props: BorderProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: BorderProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -15,0 +15,0 @@ height: PropTypes.Requireable<number>; |
@@ -63,4 +63,4 @@ "use strict"; | ||
var Border = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var Border = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/_react.default.cloneElement(props.rectComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -67,0 +67,0 @@ "aria-label": props.ariaLabel, |
@@ -13,3 +13,3 @@ import React from "react"; | ||
export declare const LineSegment: { | ||
(props: LineSegmentProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: LineSegmentProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -16,0 +16,0 @@ datum: PropTypes.Requireable<any>; |
@@ -63,4 +63,4 @@ "use strict"; | ||
var LineSegment = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var LineSegment = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
return /*#__PURE__*/_react.default.cloneElement(props.lineComponent, _objectSpread(_objectSpread({}, props.events), {}, { | ||
@@ -67,0 +67,0 @@ "aria-label": props.ariaLabel, |
@@ -15,3 +15,3 @@ import PropTypes from "prop-types"; | ||
export declare const Point: { | ||
(props: PointProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: PointProps): React.DetailedReactHTMLElement<any, HTMLElement>; | ||
propTypes: { | ||
@@ -18,0 +18,0 @@ datum: PropTypes.Requireable<object>; |
@@ -86,4 +86,4 @@ "use strict"; | ||
var Point = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var Point = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
var userProps = UserProps.getSafeUserProps(props); | ||
@@ -90,0 +90,0 @@ return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, { |
@@ -17,3 +17,3 @@ import React from "react"; | ||
export declare const Whisker: { | ||
(props: WhiskerProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
(initialProps: WhiskerProps): React.DetailedReactHTMLElement<{}, HTMLElement>; | ||
propTypes: { | ||
@@ -20,0 +20,0 @@ groupComponent: PropTypes.Requireable<PropTypes.ReactElementLike>; |
@@ -62,19 +62,18 @@ "use strict"; | ||
var Whisker = function (props) { | ||
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props)); | ||
var _props = props, | ||
ariaLabel = _props.ariaLabel, | ||
groupComponent = _props.groupComponent, | ||
lineComponent = _props.lineComponent, | ||
events = _props.events, | ||
className = _props.className, | ||
majorWhisker = _props.majorWhisker, | ||
minorWhisker = _props.minorWhisker, | ||
transform = _props.transform, | ||
clipPath = _props.clipPath, | ||
role = _props.role, | ||
shapeRendering = _props.shapeRendering, | ||
style = _props.style, | ||
desc = _props.desc, | ||
tabIndex = _props.tabIndex; | ||
var Whisker = function (initialProps) { | ||
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps)); | ||
var ariaLabel = props.ariaLabel, | ||
groupComponent = props.groupComponent, | ||
lineComponent = props.lineComponent, | ||
events = props.events, | ||
className = props.className, | ||
majorWhisker = props.majorWhisker, | ||
minorWhisker = props.minorWhisker, | ||
transform = props.transform, | ||
clipPath = props.clipPath, | ||
role = props.role, | ||
shapeRendering = props.shapeRendering, | ||
style = props.style, | ||
desc = props.desc, | ||
tabIndex = props.tabIndex; | ||
@@ -81,0 +80,0 @@ var baseProps = _objectSpread(_objectSpread({}, events), {}, { |
@@ -243,4 +243,3 @@ "use strict"; | ||
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) { | ||
memo = (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo; | ||
return memo; | ||
return (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo; | ||
}, []); | ||
@@ -298,4 +297,4 @@ var compiledCallbacks = callbacks.length ? function () { | ||
value: function getBaseProps(props, getSharedEventState) { | ||
getSharedEventState = getSharedEventState || this.getSharedEventState.bind(this); | ||
var sharedParentState = getSharedEventState("parent", "parent"); | ||
var getSharedEventStateFunction = getSharedEventState || this.getSharedEventState.bind(this); | ||
var sharedParentState = getSharedEventStateFunction("parent", "parent"); | ||
var parentState = this.getEventState("parent", "parent"); | ||
@@ -390,9 +389,11 @@ var baseParentProps = (0, _defaults2.default)({}, parentState, sharedParentState); | ||
var labelComponents = dataKeys.reduce(function (memo, key) { | ||
var newMemo = memo; | ||
var labelProps = _this8.getComponentProps(labelComponent, "labels", key); | ||
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) { | ||
memo = memo.concat( /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps)); | ||
newMemo = newMemo.concat( /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps)); | ||
} | ||
return memo; | ||
return newMemo; | ||
}, []); | ||
@@ -399,0 +400,0 @@ var dataProps = this.getComponentProps(dataComponent, "data", "all"); |
@@ -89,7 +89,7 @@ "use strict"; | ||
function findAxisComponents(childComponents, predicate) { | ||
predicate = predicate || _identity2.default; | ||
var predicateFunction = predicate || _identity2.default; | ||
var findAxes = function (children) { | ||
return children.reduce(function (memo, child) { | ||
if (child.type && child.type.role === "axis" && predicate(child)) { | ||
if (child.type && child.type.role === "axis" && predicateFunction(child)) { | ||
return memo.concat(child); | ||
@@ -96,0 +96,0 @@ } else if (child.props && child.props.children) { |
@@ -23,2 +23,3 @@ import * as React from "react"; | ||
containerComponent?: React.ReactElement; | ||
disableInlineStyles?: boolean; | ||
domainPadding?: DomainPaddingPropType; | ||
@@ -25,0 +26,0 @@ externalEventMutations?: EventCallbackInterface<string | string[], StringOrNumberOrList>[]; |
@@ -106,8 +106,10 @@ "use strict"; | ||
var formattedSortKey = sortKey; | ||
if (sortKey === "x" || sortKey === "y") { | ||
sortKey = "_".concat(sortKey); | ||
formattedSortKey = "_".concat(sortKey); | ||
} | ||
var order = sortOrder === "ascending" ? "asc" : "desc"; | ||
return (0, _orderBy2.default)(dataset, sortKey, order); | ||
return (0, _orderBy2.default)(dataset, formattedSortKey, order); | ||
} // This method will remove data points that break certain scales. (log scale only) | ||
@@ -304,3 +306,6 @@ | ||
var defaultKeys = ["x", "y", "y0"]; | ||
var defaultKeys = ["x", "y", "y0"]; // TODO: We shouldn’t mutate the expectedKeys param here, | ||
// but we need to figure out why changing it causes regressions in tests. | ||
// eslint-disable-next-line no-param-reassign | ||
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys; | ||
@@ -330,9 +335,9 @@ | ||
// eslint-disable-line complexity | ||
datum = parseDatum(datum); | ||
var parsedDatum = parseDatum(datum); | ||
var fallbackValues = { | ||
x: index, | ||
y: datum | ||
y: parsedDatum | ||
}; | ||
var processedValues = expectedKeys.reduce(function (memo, type) { | ||
var processedValue = accessor[type](datum); | ||
var processedValue = accessor[type](parsedDatum); | ||
var value = processedValue !== undefined ? processedValue : fallbackValues[type]; | ||
@@ -351,3 +356,3 @@ | ||
}, {}); | ||
var formattedDatum = (0, _assign2.default)({}, processedValues, datum); | ||
var formattedDatum = (0, _assign2.default)({}, processedValues, parsedDatum); | ||
@@ -469,4 +474,4 @@ if (!(0, _isEmpty2.default)(formattedDatum)) { | ||
var dataStrings = sortedData.reduce(function (dataArr, datum) { | ||
datum = parseDatum(datum); | ||
dataArr.push(accessor(datum)); | ||
var parsedDatum = parseDatum(datum); | ||
dataArr.push(accessor(parsedDatum)); | ||
return dataArr; | ||
@@ -473,0 +478,0 @@ }, []).filter(function (datum) { |
@@ -198,4 +198,4 @@ "use strict"; | ||
function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) { | ||
getDomainFromDataFunction = (0, _isFunction2.default)(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData; | ||
formatDomainFunction = (0, _isFunction2.default)(formatDomainFunction) ? formatDomainFunction : formatDomain; | ||
var getDomainFromDataFn = (0, _isFunction2.default)(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData; | ||
var formatDomainFn = (0, _isFunction2.default)(formatDomainFunction) ? formatDomainFunction : formatDomain; | ||
return function (props, axis) { | ||
@@ -205,8 +205,8 @@ var propsDomain = getDomainFromProps(props, axis); | ||
if (propsDomain) { | ||
return formatDomainFunction(propsDomain, props, axis); | ||
return formatDomainFn(propsDomain, props, axis); | ||
} | ||
var categories = Data.getCategories(props, axis); | ||
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFunction(props, axis); | ||
return domain ? formatDomainFunction(domain, props, axis) : undefined; | ||
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFn(props, axis); | ||
return domain ? formatDomainFn(domain, props, axis) : undefined; | ||
}; | ||
@@ -247,3 +247,3 @@ } | ||
function getDomainFromCategories(props, axis, categories) { | ||
categories = categories || Data.getCategories(props, axis); | ||
var categoriesArray = categories || Data.getCategories(props, axis); | ||
var polar = props.polar, | ||
@@ -255,3 +255,3 @@ _props$startAngle = props.startAngle, | ||
if (!categories) { | ||
if (!categoriesArray) { | ||
return undefined; | ||
@@ -262,3 +262,3 @@ } | ||
var maxDomain = getMaxFromProps(props, axis); | ||
var stringArray = Collection.containsStrings(categories) ? Data.getStringsFromCategories(props, axis) : []; | ||
var stringArray = Collection.containsStrings(categoriesArray) ? Data.getStringsFromCategories(props, axis) : []; | ||
var stringMap = stringArray.length === 0 ? null : stringArray.reduce(function (memo, string, index) { | ||
@@ -268,5 +268,5 @@ memo[string] = index + 1; | ||
}, {}); | ||
var categoryValues = stringMap ? categories.map(function (value) { | ||
var categoryValues = stringMap ? categoriesArray.map(function (value) { | ||
return stringMap[value]; | ||
}) : categories; | ||
}) : categoriesArray; | ||
var min = minDomain !== undefined ? minDomain : Collection.getMinValue(categoryValues); | ||
@@ -287,3 +287,3 @@ var max = maxDomain !== undefined ? maxDomain : Collection.getMaxValue(categoryValues); | ||
function getDomainFromData(props, axis, dataset) { | ||
dataset = dataset || Data.getData(props); | ||
var datasetArray = dataset || Data.getData(props); | ||
var polar = props.polar, | ||
@@ -297,10 +297,10 @@ _props$startAngle2 = props.startAngle, | ||
if (dataset.length < 1) { | ||
if (datasetArray.length < 1) { | ||
return minDomain !== undefined && maxDomain !== undefined ? getDomainFromMinMax(minDomain, maxDomain) : undefined; | ||
} | ||
var min = minDomain !== undefined ? minDomain : getExtremeFromData(dataset, axis, "min"); | ||
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(dataset, axis, "max"); | ||
var min = minDomain !== undefined ? minDomain : getExtremeFromData(datasetArray, axis, "min"); | ||
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(datasetArray, axis, "max"); | ||
var domain = getDomainFromMinMax(min, max); | ||
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(dataset, axis)) : domain; | ||
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(datasetArray, axis)) : domain; | ||
} | ||
@@ -307,0 +307,0 @@ /** |
@@ -19,3 +19,3 @@ /// <reference types="react" /> | ||
} | ||
export declare function getEvents(this: ComponentWithEvents, props: any, target: any, eventKey: any, getScopedEvents: any): any; | ||
export declare function getEvents(this: ComponentWithEvents, props: any, target?: any, eventKey?: any, getScopedEvents?: any): any; | ||
export declare function getScopedEvents(this: ComponentWithEvents, events: any, namespace: any, childType: any, baseProps: any): {}; | ||
@@ -37,3 +37,3 @@ export declare function getPartialEvents(events: ComponentEventHandlers, eventKey: ComponentEventKey, childProps: unknown): PartialEvents; | ||
*/ | ||
export declare function getExternalMutationsWithChildren(mutations: any, baseProps: any, baseState: any, childNames: any): any; | ||
export declare function getExternalMutationsWithChildren(mutations: any, baseProps: {} | undefined, baseState: {} | undefined, childNames: any): any; | ||
/** | ||
@@ -49,3 +49,3 @@ * Returns a set of all mutations for a component | ||
*/ | ||
export declare function getExternalMutations(mutations: any, baseProps: any, baseState: any, childName?: any): {}; | ||
export declare function getExternalMutations(mutations: any, baseProps?: {}, baseState?: {}, childName?: any): {}; | ||
/** | ||
@@ -52,0 +52,0 @@ * Returns a set of mutations for a particular element given scoped baseProps and baseState |
@@ -149,3 +149,3 @@ "use strict"; | ||
baseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element | ||
var newBaseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element | ||
@@ -157,3 +157,3 @@ var getTargetProps = function (identifier, type) { | ||
var baseType = type === "props" ? baseProps : _this2.state || {}; | ||
var baseType = type === "props" ? newBaseProps : _this2.state || {}; | ||
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName]; | ||
@@ -246,4 +246,3 @@ return key === "parent" ? base.parent : base[key] && base[key][target]; | ||
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) { | ||
memo = (0, _assign6.default)({}, memo, parseEvent(props, eventKey)); | ||
return memo; | ||
return (0, _assign6.default)({}, memo, parseEvent(props, eventKey)); | ||
}, {}) : parseEvent(eventReturn, eventKey); | ||
@@ -336,5 +335,6 @@ }; | ||
function getExternalMutationsWithChildren(mutations, baseProps, baseState, childNames) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
function getExternalMutationsWithChildren(mutations) { | ||
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var childNames = arguments.length > 3 ? arguments[3] : undefined; | ||
return childNames.reduce(function (memo, childName) { | ||
@@ -362,5 +362,6 @@ var childState = baseState[childName]; | ||
function getExternalMutations(mutations, baseProps, baseState, childName) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
function getExternalMutations(mutations) { | ||
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var childName = arguments.length > 3 ? arguments[3] : undefined; | ||
var eventKeys = (0, _keys2.default)(baseProps); | ||
@@ -429,4 +430,3 @@ return eventKeys.reduce(function (memo, eventKey) { | ||
mutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
var scopedMutations = mutations; | ||
var scopedMutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
@@ -471,9 +471,6 @@ if (identifier.childName) { | ||
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 Array.isArray(componentEvents) ? memo.concat.apply(memo, _toConsumableArray(componentEvents)) : memo; | ||
}, []); | ||
@@ -480,0 +477,0 @@ return events && events.length ? events : undefined; |
@@ -341,2 +341,3 @@ "use strict"; | ||
return childArray.reduce(function (memo, child, index) { | ||
var newMemo = memo; | ||
var childRole = child.type && child.type.role; | ||
@@ -357,3 +358,3 @@ var childName = child.props.name || "".concat(childRole, "-").concat(names[index]); | ||
var nestedResults = traverseChildren(nestedChildren, _childNames, child); | ||
memo = combine(memo, nestedResults); | ||
newMemo = combine(newMemo, nestedResults); | ||
} else { | ||
@@ -363,7 +364,7 @@ var result = iteratee(child, childName, parent); | ||
if (result) { | ||
memo = combine(memo, result); | ||
newMemo = combine(newMemo, result); | ||
} | ||
} | ||
return memo; | ||
return newMemo; | ||
}, initialMemo); | ||
@@ -395,4 +396,3 @@ }; | ||
if (memo || childProps.horizontal || !childProps.children) { | ||
memo = memo || childProps.horizontal; | ||
return memo; | ||
return memo || childProps.horizontal; | ||
} | ||
@@ -399,0 +399,0 @@ |
@@ -44,9 +44,11 @@ "use strict"; | ||
return isIterable(x) ? x.reduce(function (result, curr, key) { | ||
var newCurr = curr; | ||
if (whitelist && whitelist[key]) { | ||
curr = shallowToJS(curr); | ||
newCurr = shallowToJS(curr); | ||
} | ||
result[key] = curr; | ||
result[key] = newCurr; | ||
return result; | ||
}, isList(x) ? [] : {}) : x; | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare function getText(props: any, datum: any, index: any): any; | ||
export declare function getText(props: any, datum: Record<string, any> | undefined, index: any): any; | ||
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle"; | ||
@@ -3,0 +3,0 @@ export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle"; |
@@ -23,6 +23,5 @@ "use strict"; | ||
/* eslint-disable no-use-before-define */ | ||
// Private Functions | ||
function getVerticalAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getVerticalAnchor(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var sign = datum._y >= 0 ? 1 : -1; | ||
@@ -40,4 +39,4 @@ var labelStyle = props.style && props.style.labels || {}; | ||
function getTextAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getTextAnchor(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var style = props.style, | ||
@@ -57,4 +56,4 @@ horizontal = props.horizontal; | ||
function getAngle(props, datum) { | ||
datum = datum || {}; | ||
function getAngle(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var labelStyle = props.style && props.style.labels || {}; | ||
@@ -64,4 +63,4 @@ return datum.angle === undefined ? labelStyle.angle : datum.angle; | ||
function getPadding(props, datum) { | ||
datum = datum || {}; | ||
function getPadding(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var horizontal = props.horizontal, | ||
@@ -145,4 +144,5 @@ style = props.style; | ||
function getText(props, datum, index) { | ||
datum = datum || {}; | ||
function getText(props) { | ||
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var index = arguments.length > 2 ? arguments[2] : undefined; | ||
@@ -149,0 +149,0 @@ if (datum.label !== undefined) { |
@@ -68,4 +68,3 @@ "use strict"; | ||
var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt; | ||
svg = svg || getParentSVG(location); | ||
var matrix = getTransformationMatrix(svg); | ||
var matrix = getTransformationMatrix(svg || getParentSVG(location)); | ||
return { | ||
@@ -72,0 +71,0 @@ x: transformTarget(location.clientX, matrix, "x"), |
@@ -67,7 +67,6 @@ "use strict"; | ||
value: function subscribe(callback, duration) { | ||
duration = this.shouldAnimate ? duration : 0; | ||
var subscriptionID = this.subscribers.push({ | ||
startTime: (0, _d3Timer.now)(), | ||
callback: callback, | ||
duration: duration | ||
duration: this.shouldAnimate ? duration : 0 | ||
}); | ||
@@ -74,0 +73,0 @@ this.activeSubscriptions++; |
@@ -151,9 +151,9 @@ "use strict"; | ||
function getChildBeforeLoad(animate, child, data, cb) { | ||
animate = (0, _assign2.default)({}, animate, { | ||
var newAnimate = (0, _assign2.default)({}, animate, { | ||
onEnd: cb | ||
}); | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { | ||
animate: animate, | ||
animate: newAnimate, | ||
data: data | ||
@@ -163,10 +163,10 @@ }; | ||
var before = animate.onLoad && animate.onLoad.before ? animate.onLoad.before : _identity2.default; // If nodes need to exit, transform them with the provided onLoad.before function. | ||
var before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity2.default; // If nodes need to exit, transform them with the provided onLoad.before function. | ||
data = data.map(function (datum, idx) { | ||
var newData = data.map(function (datum, idx) { | ||
return (0, _assign2.default)({}, datum, before(datum, idx, data)); | ||
}); | ||
return { | ||
animate: animate, | ||
data: data, | ||
animate: newAnimate, | ||
data: newData, | ||
clipWidth: 0 | ||
@@ -178,7 +178,8 @@ }; | ||
function getChildOnLoad(animate, data, cb) { | ||
animate = (0, _assign2.default)({}, animate, { | ||
var newAnimate = (0, _assign2.default)({}, animate, { | ||
onEnd: cb | ||
}); | ||
var newData = data; | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { | ||
@@ -192,8 +193,8 @@ animate: animate, | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
return (0, _assign2.default)({}, datum, after(datum, idx, data)); | ||
}); | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -207,3 +208,4 @@ } // eslint-disable-next-line max-params, max-len | ||
var onExit = animate && animate.onExit; | ||
animate = (0, _assign2.default)({}, animate, onExit); | ||
var newAnimate = (0, _assign2.default)({}, animate, onExit); | ||
var newData = data; | ||
@@ -216,3 +218,3 @@ if (exitingNodes) { | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
var key = (datum.key || idx).toString(); | ||
@@ -224,4 +226,4 @@ return exitingNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -232,6 +234,9 @@ } // eslint-disable-next-line max-params,max-len | ||
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) { | ||
var newAnimate = animate; | ||
var newData = data; | ||
if (enteringNodes) { | ||
// Perform a normal animation here, except - when it finishes - trigger | ||
// the transition for entering nodes. | ||
animate = (0, _assign2.default)({}, animate, { | ||
newAnimate = (0, _assign2.default)({}, animate, { | ||
onEnd: cb | ||
@@ -243,3 +248,3 @@ }); | ||
data = data.map(function (datum, idx) { | ||
newData = data.map(function (datum, idx) { | ||
var key = (datum.key || idx).toString(); | ||
@@ -251,4 +256,4 @@ return enteringNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -262,3 +267,4 @@ } // eslint-disable-next-line max-params, max-len | ||
var onEnter = animate && animate.onEnter; | ||
animate = (0, _assign2.default)({}, animate, onEnter); | ||
var newAnimate = (0, _assign2.default)({}, animate, onEnter); | ||
var newData = data; | ||
@@ -269,5 +275,5 @@ if (enteringNodes) { | ||
// the `onEnter.after` transformation on each node. | ||
animate.onEnd = cb; | ||
var after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity2.default; | ||
data = data.map(function (datum, idx) { | ||
newAnimate.onEnd = cb; | ||
var after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity2.default; | ||
newData = data.map(function (datum, idx) { | ||
var key = getDatumKey(datum, idx); | ||
@@ -279,4 +285,4 @@ return enteringNodes[key] ? (0, _assign2.default)({}, datum, after(datum, idx, data)) : datum; | ||
return { | ||
animate: animate, | ||
data: data | ||
animate: newAnimate, | ||
data: newData | ||
}; | ||
@@ -283,0 +289,0 @@ } |
import * as React from "react"; | ||
declare type SafeAttribute = string; | ||
/** | ||
* Asserts that value is not null or undefined, throwing an error if it is. | ||
* @param value The value to assert | ||
* @param message The error message to throw | ||
*/ | ||
export declare function assert<T>(value: T, message?: string): asserts value is NonNullable<T>; | ||
/** | ||
* getSafeUserProps - function that takes in a props object and removes any | ||
@@ -5,0 +11,0 @@ * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.assert = assert; | ||
exports.withSafeUserProps = exports.getSafeUserProps = void 0; | ||
@@ -89,2 +90,14 @@ | ||
/** | ||
* Asserts that value is not null or undefined, throwing an error if it is. | ||
* @param value The value to assert | ||
* @param message The error message to throw | ||
*/ | ||
function assert(value, message) { | ||
if (value === undefined || value === null) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* getSafeUserProps - function that takes in a props object and removes any | ||
@@ -91,0 +104,0 @@ * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST |
@@ -164,2 +164,3 @@ "use strict"; | ||
var childData; | ||
var childElement = child; | ||
@@ -169,4 +170,4 @@ if (!Data.isDataComponent(child)) { | ||
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child; | ||
childData = child.type.getData(childProps); | ||
childElement = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child; | ||
childData = childElement.type.getData(childProps); | ||
} else { | ||
@@ -203,4 +204,3 @@ childData = Data.getData(childProps); | ||
childComponents = childComponents || _react.default.Children.toArray(props.children); | ||
return getDataFromChildren(props, childComponents); | ||
return getDataFromChildren(props, childComponents || _react.default.Children.toArray(props.children)); | ||
} | ||
@@ -213,5 +213,5 @@ | ||
var extent = Math.abs(range[1] - range[0]); | ||
seriesLength = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1; | ||
groupLength = groupLength || datasets.length; | ||
var bars = groupLength * seriesLength; | ||
var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1; | ||
var groupLengthValue = groupLength || datasets.length; | ||
var bars = groupLengthValue * seriesLengthValue; | ||
var barRatio = 0.5; | ||
@@ -311,5 +311,6 @@ return Math.round(barRatio * extent / bars); | ||
function getDomain(props, axis, childComponents) { | ||
childComponents = childComponents || _react.default.Children.toArray(props.children); | ||
var children = childComponents || _react.default.Children.toArray(props.children); | ||
var propsDomain = Domain.getDomainFromProps(props, axis); | ||
var domainPadding = getDefaultDomainPadding(props, axis, childComponents); | ||
var domainPadding = getDefaultDomainPadding(props, axis, children); | ||
var domain; | ||
@@ -324,3 +325,3 @@ | ||
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : []; | ||
var childDomain = getDomainFromChildren(props, axis, childComponents); | ||
var childDomain = getDomainFromChildren(props, axis, children); | ||
var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain))); | ||
@@ -491,6 +492,7 @@ var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain))); | ||
function getStringsFromChildren(props, childComponents) { | ||
childComponents = childComponents || _react.default.Children.toArray(props.children); | ||
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", childComponents); | ||
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents); | ||
var dataStrings = getStringsFromData(childComponents); | ||
var children = childComponents || _react.default.Children.toArray(props.children); | ||
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children); | ||
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children); | ||
var dataStrings = getStringsFromData(children); | ||
return { | ||
@@ -497,0 +499,0 @@ x: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))), |
{ | ||
"name": "victory-core", | ||
"version": "36.8.2", | ||
"version": "36.8.3", | ||
"description": "Victory Core", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"react-fast-compare": "^3.2.0", | ||
"victory-vendor": "^36.8.2" | ||
"victory-vendor": "^36.8.3" | ||
}, | ||
@@ -29,0 +29,0 @@ "peerDependencies": { |
@@ -1,2 +0,2 @@ | ||
import { D3Scale, Datum, ID } from "./prop-types"; | ||
import { D3Scale, Datum, ID, ScalePropType } from "./prop-types"; | ||
import { BlockProps, OrientationTypes } from "../victory-theme/types"; | ||
@@ -19,6 +19,9 @@ | ||
y?: number; | ||
scale?: { | ||
x?: D3Scale; | ||
y?: D3Scale; | ||
}; | ||
scale?: | ||
| ScalePropType | ||
| D3Scale | ||
| { | ||
x?: ScalePropType | D3Scale; | ||
y?: ScalePropType | D3Scale; | ||
}; | ||
tick?: any; | ||
@@ -25,0 +28,0 @@ ticks?: any; |
@@ -100,7 +100,7 @@ import { interpolate } from "victory-vendor/d3-interpolate"; | ||
* | ||
* @param {any} a - Start value. | ||
* @param {any} b - End value. | ||
* @param {any} startValue - Start value. | ||
* @param {any} endValue - End value. | ||
* @returns {Function} An interpolation function. | ||
*/ | ||
export const interpolateObject = function (a, b) { | ||
export const interpolateObject = function (startValue, endValue) { | ||
const interpolateTypes = (x, y) => { | ||
@@ -130,2 +130,4 @@ if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) { | ||
const c = {}; | ||
let a = startValue; | ||
let b = endValue; | ||
let k; | ||
@@ -132,0 +134,0 @@ |
@@ -61,7 +61,8 @@ /* eslint-disable no-use-before-define */ | ||
// Ensures previous VictoryLine api for sortKey prop stays consistent | ||
let formattedSortKey = sortKey; | ||
if (sortKey === "x" || sortKey === "y") { | ||
sortKey = `_${sortKey}`; | ||
formattedSortKey = `_${sortKey}`; | ||
} | ||
const order = sortOrder === "ascending" ? "asc" : "desc"; | ||
return orderBy(dataset, sortKey, order); | ||
return orderBy(dataset, formattedSortKey, order); | ||
} | ||
@@ -243,2 +244,5 @@ | ||
const defaultKeys = ["x", "y", "y0"]; | ||
// TODO: We shouldn’t mutate the expectedKeys param here, | ||
// but we need to figure out why changing it causes regressions in tests. | ||
// eslint-disable-next-line no-param-reassign | ||
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys; | ||
@@ -286,6 +290,6 @@ | ||
// eslint-disable-line complexity | ||
datum = parseDatum(datum); | ||
const fallbackValues = { x: index, y: datum }; | ||
const parsedDatum = parseDatum(datum); | ||
const fallbackValues = { x: index, y: parsedDatum }; | ||
const processedValues = expectedKeys!.reduce((memo, type) => { | ||
const processedValue = accessor[type](datum); | ||
const processedValue = accessor[type](parsedDatum); | ||
const value = | ||
@@ -306,3 +310,3 @@ processedValue !== undefined | ||
const formattedDatum = assign({}, processedValues, datum); | ||
const formattedDatum = assign({}, processedValues, parsedDatum); | ||
if (!isEmpty(formattedDatum)) { | ||
@@ -415,4 +419,4 @@ dataArr.push(formattedDatum); | ||
.reduce((dataArr, datum) => { | ||
datum = parseDatum(datum); | ||
dataArr.push(accessor(datum)); | ||
const parsedDatum = parseDatum(datum); | ||
dataArr.push(accessor(parsedDatum)); | ||
return dataArr; | ||
@@ -419,0 +423,0 @@ }, []) |
@@ -186,6 +186,6 @@ /* eslint-disable no-use-before-define */ | ||
) { | ||
getDomainFromDataFunction = isFunction(getDomainFromDataFunction) | ||
const getDomainFromDataFn = isFunction(getDomainFromDataFunction) | ||
? getDomainFromDataFunction | ||
: getDomainFromData; | ||
formatDomainFunction = isFunction(formatDomainFunction) | ||
const formatDomainFn = isFunction(formatDomainFunction) | ||
? formatDomainFunction | ||
@@ -196,3 +196,3 @@ : formatDomain; | ||
if (propsDomain) { | ||
return formatDomainFunction(propsDomain, props, axis); | ||
return formatDomainFn(propsDomain, props, axis); | ||
} | ||
@@ -202,4 +202,4 @@ const categories = Data.getCategories(props, axis); | ||
? getDomainFromCategories(props, axis, categories) | ||
: getDomainFromDataFunction(props, axis); | ||
return domain ? formatDomainFunction(domain, props, axis) : undefined; | ||
: getDomainFromDataFn(props, axis); | ||
return domain ? formatDomainFn(domain, props, axis) : undefined; | ||
}; | ||
@@ -237,5 +237,5 @@ } | ||
export function getDomainFromCategories(props, axis, categories?) { | ||
categories = categories || Data.getCategories(props, axis); | ||
const categoriesArray = categories || Data.getCategories(props, axis); | ||
const { polar, startAngle = 0, endAngle = 360 } = props; | ||
if (!categories) { | ||
if (!categoriesArray) { | ||
return undefined; | ||
@@ -245,3 +245,3 @@ } | ||
const maxDomain = getMaxFromProps(props, axis); | ||
const stringArray = Collection.containsStrings(categories) | ||
const stringArray = Collection.containsStrings(categoriesArray) | ||
? Data.getStringsFromCategories(props, axis) | ||
@@ -257,4 +257,4 @@ : []; | ||
const categoryValues = stringMap | ||
? categories.map((value) => stringMap[value]) | ||
: categories; | ||
? categoriesArray.map((value) => stringMap[value]) | ||
: categoriesArray; | ||
const min = | ||
@@ -282,7 +282,7 @@ minDomain !== undefined | ||
export function getDomainFromData(props, axis, dataset) { | ||
dataset = dataset || Data.getData(props); | ||
const datasetArray = dataset || Data.getData(props); | ||
const { polar, startAngle = 0, endAngle = 360 } = props; | ||
const minDomain = getMinFromProps(props, axis); | ||
const maxDomain = getMaxFromProps(props, axis); | ||
if (dataset.length < 1) { | ||
if (datasetArray.length < 1) { | ||
return minDomain !== undefined && maxDomain !== undefined | ||
@@ -295,10 +295,10 @@ ? getDomainFromMinMax(minDomain, maxDomain) | ||
? minDomain | ||
: getExtremeFromData(dataset, axis, "min"); | ||
: getExtremeFromData(datasetArray, axis, "min"); | ||
const max = | ||
maxDomain !== undefined | ||
? maxDomain | ||
: getExtremeFromData(dataset, axis, "max"); | ||
: getExtremeFromData(datasetArray, axis, "max"); | ||
const domain = getDomainFromMinMax(min, max); | ||
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 | ||
? getSymmetricDomain(domain, getFlatData(dataset, axis)) | ||
? getSymmetricDomain(domain, getFlatData(datasetArray, axis)) | ||
: domain; | ||
@@ -305,0 +305,0 @@ } |
@@ -51,6 +51,6 @@ /* eslint-disable no-use-before-define */ | ||
props, | ||
target, | ||
eventKey, | ||
target?, | ||
eventKey?, | ||
// eslint-disable-next-line no-shadow | ||
getScopedEvents, | ||
getScopedEvents?, | ||
) { | ||
@@ -141,3 +141,3 @@ // Returns all events that apply to a particular target element | ||
// eslint-disable-next-line no-invalid-this | ||
baseProps = baseProps || this.baseProps; | ||
const newBaseProps = baseProps || this.baseProps; | ||
// returns the original base props or base state of a given target element | ||
@@ -147,3 +147,3 @@ const getTargetProps = (identifier, type) => { | ||
// eslint-disable-next-line no-invalid-this | ||
const baseType = type === "props" ? baseProps : this.state || {}; | ||
const baseType = type === "props" ? newBaseProps : this.state || {}; | ||
const base = | ||
@@ -255,6 +255,6 @@ childName === undefined || childName === null || !baseType[childName] | ||
return Array.isArray(eventReturn) | ||
? eventReturn.reduce((memo, props) => { | ||
memo = assign({}, memo, parseEvent(props, eventKey)); | ||
return memo; | ||
}, {}) | ||
? eventReturn.reduce( | ||
(memo, props) => assign({}, memo, parseEvent(props, eventKey)), | ||
{}, | ||
) | ||
: parseEvent(eventReturn, eventKey); | ||
@@ -354,9 +354,6 @@ }; | ||
mutations, | ||
baseProps, | ||
baseState, | ||
baseProps = {}, | ||
baseState = {}, | ||
childNames, | ||
) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
return childNames.reduce((memo, childName) => { | ||
@@ -388,9 +385,6 @@ const childState = baseState[childName]; | ||
mutations, | ||
baseProps, | ||
baseState, | ||
baseProps = {}, | ||
baseState = {}, | ||
childName?, | ||
) { | ||
baseProps = baseProps || {}; | ||
baseState = baseState || {}; | ||
const eventKeys = keys(baseProps); | ||
@@ -461,4 +455,3 @@ return eventKeys.reduce((memo, eventKey) => { | ||
mutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
let scopedMutations = mutations; | ||
let scopedMutations = Array.isArray(mutations) ? mutations : [mutations]; | ||
if (identifier.childName) { | ||
@@ -501,6 +494,5 @@ scopedMutations = mutations.filter((m) => filterMutations(m, "childName")); | ||
: defaultEvents; | ||
memo = Array.isArray(componentEvents) | ||
return Array.isArray(componentEvents) | ||
? memo.concat(...componentEvents) | ||
: memo; | ||
return memo; | ||
}, [] as ComponentEvent[]); | ||
@@ -507,0 +499,0 @@ return events && events.length ? events : undefined; |
@@ -261,2 +261,3 @@ /* eslint-disable no-use-before-define */ | ||
return childArray.reduce((memo, child, index) => { | ||
let newMemo = memo; | ||
const childRole = child.type && child.type.role; | ||
@@ -295,10 +296,10 @@ const childName = child.props.name || `${childRole}-${names[index]}`; | ||
); | ||
memo = combine(memo, nestedResults); | ||
newMemo = combine(newMemo, nestedResults); | ||
} else { | ||
const result = iteratee(child, childName, parent); | ||
if (result) { | ||
memo = combine(memo, result); | ||
newMemo = combine(newMemo, result); | ||
} | ||
} | ||
return memo; | ||
return newMemo; | ||
}, initialMemo); | ||
@@ -325,4 +326,3 @@ }; | ||
if (memo || childProps.horizontal || !childProps.children) { | ||
memo = memo || childProps.horizontal; | ||
return memo; | ||
return memo || childProps.horizontal; | ||
} | ||
@@ -329,0 +329,0 @@ return traverseChildren(React.Children.toArray(childProps.children)); |
@@ -34,6 +34,7 @@ import type { Iterable, Record, List, Map } from "./immutable-types"; | ||
(result: any, curr: any, key: any) => { | ||
let newCurr = curr; | ||
if (whitelist && whitelist[key]) { | ||
curr = shallowToJS(curr); | ||
newCurr = shallowToJS(curr); | ||
} | ||
result[key] = curr; | ||
result[key] = newCurr; | ||
return result; | ||
@@ -40,0 +41,0 @@ }, |
/* eslint-disable no-use-before-define */ | ||
import { VictoryLabelProps } from "../victory-label/victory-label"; | ||
import * as Helpers from "./helpers"; | ||
@@ -7,4 +8,3 @@ import { defaults } from "lodash"; | ||
function getVerticalAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getVerticalAnchor(props, datum: VictoryLabelProps["datum"] = {}) { | ||
const sign = datum._y >= 0 ? 1 : -1; | ||
@@ -20,4 +20,3 @@ const labelStyle = (props.style && props.style.labels) || {}; | ||
function getTextAnchor(props, datum) { | ||
datum = datum || {}; | ||
function getTextAnchor(props, datum: VictoryLabelProps["datum"] = {}) { | ||
const { style, horizontal } = props; | ||
@@ -34,4 +33,3 @@ const sign = datum._y >= 0 ? 1 : -1; | ||
function getAngle(props, datum) { | ||
datum = datum || {}; | ||
function getAngle(props, datum: VictoryLabelProps["datum"] = {}) { | ||
const labelStyle = (props.style && props.style.labels) || {}; | ||
@@ -41,4 +39,3 @@ return datum.angle === undefined ? labelStyle.angle : datum.angle; | ||
function getPadding(props, datum) { | ||
datum = datum || {}; | ||
function getPadding(props, datum: VictoryLabelProps["datum"] = {}) { | ||
const { horizontal, style } = props; | ||
@@ -116,4 +113,3 @@ const labelStyle = style.labels || {}; | ||
export function getText(props, datum, index) { | ||
datum = datum || {}; | ||
export function getText(props, datum: VictoryLabelProps["datum"] = {}, index) { | ||
if (datum.label !== undefined) { | ||
@@ -120,0 +116,0 @@ return datum.label; |
@@ -76,4 +76,5 @@ import React from "react"; | ||
: (evt as React.MouseEvent); | ||
svg = svg || getParentSVG(location); | ||
const matrix = getTransformationMatrix(svg as SVGGraphicsElement); | ||
const matrix = getTransformationMatrix( | ||
(svg as SVGGraphicsElement) || getParentSVG(location), | ||
); | ||
return { | ||
@@ -80,0 +81,0 @@ x: transformTarget(location.clientX, matrix, "x"), |
@@ -50,7 +50,6 @@ import { timer, now, Timer as D3Timer } from "victory-vendor/d3-timer"; | ||
subscribe(callback: TimerCallback, duration: number) { | ||
duration = this.shouldAnimate ? duration : 0; | ||
const subscriptionID = this.subscribers.push({ | ||
startTime: now(), | ||
callback, | ||
duration, | ||
duration: this.shouldAnimate ? duration : 0, | ||
}); | ||
@@ -57,0 +56,0 @@ this.activeSubscriptions++; |
@@ -140,14 +140,17 @@ import { assign, defaults, identity, keys } from "lodash"; | ||
function getChildBeforeLoad(animate, child, data, cb): TransitionProps { | ||
animate = assign({}, animate, { onEnd: cb }); | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
return { animate, data }; | ||
const newAnimate = assign({}, animate, { onEnd: cb }); | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { animate: newAnimate, data }; | ||
} | ||
const before = | ||
animate.onLoad && animate.onLoad.before ? animate.onLoad.before : identity; | ||
newAnimate.onLoad && newAnimate.onLoad.before | ||
? newAnimate.onLoad.before | ||
: identity; | ||
// If nodes need to exit, transform them with the provided onLoad.before function. | ||
data = data.map((datum, idx) => { | ||
const newData = data.map((datum, idx) => { | ||
return assign({}, datum, before(datum, idx, data)); | ||
}); | ||
return { animate, data, clipWidth: 0 }; | ||
return { animate: newAnimate, data: newData, clipWidth: 0 }; | ||
} | ||
@@ -157,4 +160,6 @@ | ||
function getChildOnLoad(animate, data, cb): TransitionProps { | ||
animate = assign({}, animate, { onEnd: cb }); | ||
if (animate && animate.onLoad && !animate.onLoad.duration) { | ||
const newAnimate = assign({}, animate, { onEnd: cb }); | ||
let newData = data; | ||
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) { | ||
return { animate, data }; | ||
@@ -165,7 +170,7 @@ } | ||
// If nodes need to exit, transform them with the provided onLoad.after function. | ||
data = data.map((datum, idx) => { | ||
newData = data.map((datum, idx) => { | ||
return assign({}, datum, after(datum, idx, data)); | ||
}); | ||
return { animate, data }; | ||
return { animate: newAnimate, data: newData }; | ||
} | ||
@@ -184,3 +189,4 @@ | ||
const onExit = animate && animate.onExit; | ||
animate = assign({}, animate, onExit); | ||
const newAnimate = assign({}, animate, onExit); | ||
let newData = data; | ||
@@ -196,3 +202,3 @@ if (exitingNodes) { | ||
// If nodes need to exit, transform them with the provided onExit.before function. | ||
data = data.map((datum, idx) => { | ||
newData = data.map((datum, idx) => { | ||
const key = (datum.key || idx).toString(); | ||
@@ -205,3 +211,3 @@ return exitingNodes[key] | ||
return { animate, data }; | ||
return { animate: newAnimate, data: newData }; | ||
} | ||
@@ -217,6 +223,8 @@ | ||
): TransitionProps { | ||
let newAnimate = animate; | ||
let newData = data; | ||
if (enteringNodes) { | ||
// Perform a normal animation here, except - when it finishes - trigger | ||
// the transition for entering nodes. | ||
animate = assign({}, animate, { onEnd: cb }); | ||
newAnimate = assign({}, animate, { onEnd: cb }); | ||
const before = | ||
@@ -229,3 +237,3 @@ animate.onEnter && animate.onEnter.before | ||
// so perform the `onEnter.before` transformation on each node. | ||
data = data.map((datum, idx) => { | ||
newData = data.map((datum, idx) => { | ||
const key = (datum.key || idx).toString(); | ||
@@ -238,3 +246,3 @@ return enteringNodes[key] | ||
return { animate, data }; | ||
return { animate: newAnimate, data: newData }; | ||
} | ||
@@ -252,3 +260,4 @@ | ||
const onEnter = animate && animate.onEnter; | ||
animate = assign({}, animate, onEnter); | ||
const newAnimate = assign({}, animate, onEnter); | ||
let newData = data; | ||
@@ -259,8 +268,8 @@ if (enteringNodes) { | ||
// the `onEnter.after` transformation on each node. | ||
animate.onEnd = cb; | ||
newAnimate.onEnd = cb; | ||
const after = | ||
animate.onEnter && animate.onEnter.after | ||
? animate.onEnter.after | ||
newAnimate.onEnter && newAnimate.onEnter.after | ||
? newAnimate.onEnter.after | ||
: identity; | ||
data = data.map((datum, idx) => { | ||
newData = data.map((datum, idx) => { | ||
const key = getDatumKey(datum, idx); | ||
@@ -272,3 +281,3 @@ return enteringNodes[key] | ||
} | ||
return { animate, data }; | ||
return { animate: newAnimate, data: newData }; | ||
} | ||
@@ -275,0 +284,0 @@ |
@@ -59,2 +59,16 @@ import * as React from "react"; | ||
/** | ||
* Asserts that value is not null or undefined, throwing an error if it is. | ||
* @param value The value to assert | ||
* @param message The error message to throw | ||
*/ | ||
export function assert<T>( | ||
value: T, | ||
message?: string, | ||
): asserts value is NonNullable<T> { | ||
if (value === undefined || value === null) { | ||
throw new Error(message); | ||
} | ||
} | ||
/** | ||
* getSafeUserProps - function that takes in a props object and removes any | ||
@@ -61,0 +75,0 @@ * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3141980
61704
Updatedvictory-vendor@^36.8.3