victory-core 36.8.2 → 36.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/victory-core.js +177 -155
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/types/callbacks.d.ts +4 -4
  5. package/es/victory-animation/util.d.ts +3 -3
  6. package/es/victory-animation/util.js +5 -3
  7. package/es/victory-animation/victory-animation.js +2 -2
  8. package/es/victory-label/victory-label.d.ts +1 -1
  9. package/es/victory-label/victory-label.js +7 -11
  10. package/es/victory-primitives/arc.d.ts +1 -1
  11. package/es/victory-primitives/arc.js +2 -2
  12. package/es/victory-primitives/background.d.ts +1 -1
  13. package/es/victory-primitives/background.js +2 -2
  14. package/es/victory-primitives/border.d.ts +1 -1
  15. package/es/victory-primitives/border.js +2 -2
  16. package/es/victory-primitives/line-segment.d.ts +1 -1
  17. package/es/victory-primitives/line-segment.js +2 -2
  18. package/es/victory-primitives/point.d.ts +1 -1
  19. package/es/victory-primitives/point.js +2 -2
  20. package/es/victory-primitives/whisker.d.ts +1 -1
  21. package/es/victory-primitives/whisker.js +16 -17
  22. package/es/victory-util/add-events.js +7 -6
  23. package/es/victory-util/axis.js +2 -2
  24. package/es/victory-util/common-props.d.ts +1 -0
  25. package/es/victory-util/data.js +14 -9
  26. package/es/victory-util/domain.js +15 -15
  27. package/es/victory-util/events.d.ts +3 -3
  28. package/es/victory-util/events.js +13 -16
  29. package/es/victory-util/helpers.js +5 -5
  30. package/es/victory-util/immutable.js +4 -2
  31. package/es/victory-util/label-helpers.d.ts +1 -1
  32. package/es/victory-util/label-helpers.js +11 -12
  33. package/es/victory-util/selection.js +1 -2
  34. package/es/victory-util/timer.js +1 -2
  35. package/es/victory-util/transitions.js +37 -26
  36. package/es/victory-util/user-props.d.ts +6 -0
  37. package/es/victory-util/user-props.js +12 -1
  38. package/es/victory-util/wrapper.js +14 -14
  39. package/lib/types/callbacks.d.ts +4 -4
  40. package/lib/victory-animation/util.d.ts +3 -3
  41. package/lib/victory-animation/util.js +5 -3
  42. package/lib/victory-animation/victory-animation.js +2 -2
  43. package/lib/victory-label/victory-label.d.ts +1 -1
  44. package/lib/victory-label/victory-label.js +7 -11
  45. package/lib/victory-primitives/arc.d.ts +1 -1
  46. package/lib/victory-primitives/arc.js +2 -2
  47. package/lib/victory-primitives/background.d.ts +1 -1
  48. package/lib/victory-primitives/background.js +2 -2
  49. package/lib/victory-primitives/border.d.ts +1 -1
  50. package/lib/victory-primitives/border.js +2 -2
  51. package/lib/victory-primitives/line-segment.d.ts +1 -1
  52. package/lib/victory-primitives/line-segment.js +2 -2
  53. package/lib/victory-primitives/point.d.ts +1 -1
  54. package/lib/victory-primitives/point.js +2 -2
  55. package/lib/victory-primitives/whisker.d.ts +1 -1
  56. package/lib/victory-primitives/whisker.js +16 -17
  57. package/lib/victory-util/add-events.js +7 -6
  58. package/lib/victory-util/axis.js +2 -2
  59. package/lib/victory-util/common-props.d.ts +1 -0
  60. package/lib/victory-util/data.js +14 -9
  61. package/lib/victory-util/domain.js +15 -15
  62. package/lib/victory-util/events.d.ts +3 -3
  63. package/lib/victory-util/events.js +13 -16
  64. package/lib/victory-util/helpers.js +5 -5
  65. package/lib/victory-util/immutable.js +4 -2
  66. package/lib/victory-util/label-helpers.d.ts +1 -1
  67. package/lib/victory-util/label-helpers.js +11 -11
  68. package/lib/victory-util/selection.js +1 -2
  69. package/lib/victory-util/timer.js +1 -2
  70. package/lib/victory-util/transitions.js +32 -26
  71. package/lib/victory-util/user-props.d.ts +6 -0
  72. package/lib/victory-util/user-props.js +13 -0
  73. package/lib/victory-util/wrapper.js +16 -14
  74. package/package.json +2 -2
  75. package/src/types/callbacks.ts +8 -5
  76. package/src/victory-animation/util.ts +5 -3
  77. package/src/victory-animation/victory-animation.tsx +3 -2
  78. package/src/victory-label/victory-label.tsx +18 -17
  79. package/src/victory-primitives/arc.tsx +2 -2
  80. package/src/victory-primitives/background.tsx +2 -2
  81. package/src/victory-primitives/border.tsx +2 -2
  82. package/src/victory-primitives/line-segment.tsx +2 -2
  83. package/src/victory-primitives/point.tsx +2 -2
  84. package/src/victory-primitives/whisker.tsx +5 -5
  85. package/src/victory-util/add-events.tsx +10 -9
  86. package/src/victory-util/axis.tsx +6 -2
  87. package/src/victory-util/common-props.tsx +1 -0
  88. package/src/victory-util/data.ts +12 -8
  89. package/src/victory-util/domain.ts +15 -15
  90. package/src/victory-util/events.ts +15 -23
  91. package/src/victory-util/helpers.ts +5 -5
  92. package/src/victory-util/immutable.ts +3 -2
  93. package/src/victory-util/label-helpers.ts +6 -10
  94. package/src/victory-util/selection.ts +3 -2
  95. package/src/victory-util/timer.ts +1 -2
  96. package/src/victory-util/transitions.ts +31 -22
  97. package/src/victory-util/user-props.ts +14 -0
  98. package/src/victory-util/wrapper.tsx +17 -22
@@ -148,36 +148,37 @@ function getInitialChildProps(animate, data) {
148
148
 
149
149
 
150
150
  function getChildBeforeLoad(animate, child, data, cb) {
151
- animate = (0, _assign2.default)({}, animate, {
151
+ var newAnimate = (0, _assign2.default)({}, animate, {
152
152
  onEnd: cb
153
153
  });
154
154
 
155
- if (animate && animate.onLoad && !animate.onLoad.duration) {
155
+ if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
156
156
  return {
157
- animate: animate,
157
+ animate: newAnimate,
158
158
  data: data
159
159
  };
160
160
  }
161
161
 
162
- 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.
162
+ 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.
163
163
 
164
- data = data.map(function (datum, idx) {
164
+ var newData = data.map(function (datum, idx) {
165
165
  return (0, _assign2.default)({}, datum, before(datum, idx, data));
166
166
  });
167
167
  return {
168
- animate: animate,
169
- data: data,
168
+ animate: newAnimate,
169
+ data: newData,
170
170
  clipWidth: 0
171
171
  };
172
172
  } // eslint-disable-next-line max-params
173
173
 
174
174
 
175
175
  function getChildOnLoad(animate, data, cb) {
176
- animate = (0, _assign2.default)({}, animate, {
176
+ var newAnimate = (0, _assign2.default)({}, animate, {
177
177
  onEnd: cb
178
178
  });
179
+ var newData = data;
179
180
 
180
- if (animate && animate.onLoad && !animate.onLoad.duration) {
181
+ if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
181
182
  return {
182
183
  animate: animate,
183
184
  data: data
@@ -186,12 +187,12 @@ function getChildOnLoad(animate, data, cb) {
186
187
 
187
188
  var after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity2.default; // If nodes need to exit, transform them with the provided onLoad.after function.
188
189
 
189
- data = data.map(function (datum, idx) {
190
+ newData = data.map(function (datum, idx) {
190
191
  return (0, _assign2.default)({}, datum, after(datum, idx, data));
191
192
  });
192
193
  return {
193
- animate: animate,
194
- data: data
194
+ animate: newAnimate,
195
+ data: newData
195
196
  };
196
197
  } // eslint-disable-next-line max-params, max-len
197
198
 
@@ -200,7 +201,8 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
200
201
  // Whether or not _this_ child has exiting nodes, we want the exit-
201
202
  // transition for all children to have the same duration, delay, etc.
202
203
  var onExit = animate && animate.onExit;
203
- animate = (0, _assign2.default)({}, animate, onExit);
204
+ var newAnimate = (0, _assign2.default)({}, animate, onExit);
205
+ var newData = data;
204
206
 
205
207
  if (exitingNodes) {
206
208
  // After the exit transition occurs, trigger the animations for
@@ -208,39 +210,42 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
208
210
  animate.onEnd = cb;
209
211
  var before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity2.default; // If nodes need to exit, transform them with the provided onExit.before function.
210
212
 
211
- data = data.map(function (datum, idx) {
213
+ newData = data.map(function (datum, idx) {
212
214
  var key = (datum.key || idx).toString();
213
215
  return exitingNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum;
214
216
  });
215
217
  }
216
218
 
217
219
  return {
218
- animate: animate,
219
- data: data
220
+ animate: newAnimate,
221
+ data: newData
220
222
  };
221
223
  } // eslint-disable-next-line max-params,max-len
222
224
 
223
225
 
224
226
  function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
227
+ var newAnimate = animate;
228
+ var newData = data;
229
+
225
230
  if (enteringNodes) {
226
231
  // Perform a normal animation here, except - when it finishes - trigger
227
232
  // the transition for entering nodes.
228
- animate = (0, _assign2.default)({}, animate, {
233
+ newAnimate = (0, _assign2.default)({}, animate, {
229
234
  onEnd: cb
230
235
  });
231
236
  var before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity2.default; // We want the entering nodes to be included in the transition target
232
237
  // domain. However, we may not want these nodes to be displayed initially,
233
238
  // so perform the `onEnter.before` transformation on each node.
234
239
 
235
- data = data.map(function (datum, idx) {
240
+ newData = data.map(function (datum, idx) {
236
241
  var key = (datum.key || idx).toString();
237
242
  return enteringNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum;
238
243
  });
239
244
  }
240
245
 
241
246
  return {
242
- animate: animate,
243
- data: data
247
+ animate: newAnimate,
248
+ data: newData
244
249
  };
245
250
  } // eslint-disable-next-line max-params, max-len
246
251
 
@@ -249,23 +254,24 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
249
254
  // Whether or not _this_ child has entering nodes, we want the entering-
250
255
  // transition for all children to have the same duration, delay, etc.
251
256
  var onEnter = animate && animate.onEnter;
252
- animate = (0, _assign2.default)({}, animate, onEnter);
257
+ var newAnimate = (0, _assign2.default)({}, animate, onEnter);
258
+ var newData = data;
253
259
 
254
260
  if (enteringNodes) {
255
261
  // Old nodes have been transitioned to their new values, and the
256
262
  // domain should encompass the nodes that will now enter. So perform
257
263
  // the `onEnter.after` transformation on each node.
258
- animate.onEnd = cb;
259
- var after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity2.default;
260
- data = data.map(function (datum, idx) {
264
+ newAnimate.onEnd = cb;
265
+ var after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity2.default;
266
+ newData = data.map(function (datum, idx) {
261
267
  var key = getDatumKey(datum, idx);
262
268
  return enteringNodes[key] ? (0, _assign2.default)({}, datum, after(datum, idx, data)) : datum;
263
269
  });
264
270
  }
265
271
 
266
272
  return {
267
- animate: animate,
268
- data: data
273
+ animate: newAnimate,
274
+ data: newData
269
275
  };
270
276
  }
271
277
  /**
@@ -1,5 +1,11 @@
1
1
  import * as React from "react";
2
2
  declare type SafeAttribute = string;
3
+ /**
4
+ * Asserts that value is not null or undefined, throwing an error if it is.
5
+ * @param value The value to assert
6
+ * @param message The error message to throw
7
+ */
8
+ export declare function assert<T>(value: T, message?: string): asserts value is NonNullable<T>;
3
9
  /**
4
10
  * getSafeUserProps - function that takes in a props object and removes any
5
11
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.assert = assert;
6
7
  exports.withSafeUserProps = exports.getSafeUserProps = void 0;
7
8
 
8
9
  var React = _interopRequireWildcard(require("react"));
@@ -84,6 +85,18 @@ var testIfSafeProp = function (key) {
84
85
  if (doesPropStartWith(key) || isExactMatch(key)) return true;
85
86
  return false;
86
87
  };
88
+ /**
89
+ * Asserts that value is not null or undefined, throwing an error if it is.
90
+ * @param value The value to assert
91
+ * @param message The error message to throw
92
+ */
93
+
94
+
95
+ function assert(value, message) {
96
+ if (value === undefined || value === null) {
97
+ throw new Error(message);
98
+ }
99
+ }
87
100
  /**
88
101
  * getSafeUserProps - function that takes in a props object and removes any
89
102
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -161,12 +161,13 @@ function getDataFromChildren(props, childComponents) {
161
161
  var iteratee = function (child, childName, parent) {
162
162
  var childProps = (0, _assign2.default)({}, child.props, parentProps);
163
163
  var childData;
164
+ var childElement = child;
164
165
 
165
166
  if (!Data.isDataComponent(child)) {
166
167
  return null;
167
168
  } else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
168
- child = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child;
169
- childData = child.type.getData(childProps);
169
+ childElement = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child;
170
+ childData = childElement.type.getData(childProps);
170
171
  } else {
171
172
  childData = Data.getData(childProps);
172
173
  }
@@ -198,8 +199,7 @@ function getData(props, childComponents) {
198
199
  return Data.getData(props);
199
200
  }
200
201
 
201
- childComponents = childComponents || _react.default.Children.toArray(props.children);
202
- return getDataFromChildren(props, childComponents);
202
+ return getDataFromChildren(props, childComponents || _react.default.Children.toArray(props.children));
203
203
  }
204
204
 
205
205
  function getWidth(props, groupLength, seriesLength) {
@@ -207,9 +207,9 @@ function getWidth(props, groupLength, seriesLength) {
207
207
  horizontal = props.horizontal;
208
208
  var range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
209
209
  var extent = Math.abs(range[1] - range[0]);
210
- seriesLength = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
211
- groupLength = groupLength || datasets.length;
212
- var bars = groupLength * seriesLength;
210
+ var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
211
+ var groupLengthValue = groupLength || datasets.length;
212
+ var bars = groupLengthValue * seriesLengthValue;
213
213
  var barRatio = 0.5;
214
214
  return Math.round(barRatio * extent / bars);
215
215
  }
@@ -304,9 +304,10 @@ function getDomainFromChildren(props, axis, childComponents) {
304
304
  }
305
305
 
306
306
  function getDomain(props, axis, childComponents) {
307
- childComponents = childComponents || _react.default.Children.toArray(props.children);
307
+ var children = childComponents || _react.default.Children.toArray(props.children);
308
+
308
309
  var propsDomain = Domain.getDomainFromProps(props, axis);
309
- var domainPadding = getDefaultDomainPadding(props, axis, childComponents);
310
+ var domainPadding = getDefaultDomainPadding(props, axis, children);
310
311
  var domain;
311
312
 
312
313
  if (propsDomain) {
@@ -316,7 +317,7 @@ function getDomain(props, axis, childComponents) {
316
317
  var maxDomain = Domain.getMaxFromProps(props, axis);
317
318
  var dataset = (props.data || props.y) && Data.getData(props);
318
319
  var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
319
- var childDomain = getDomainFromChildren(props, axis, childComponents);
320
+ var childDomain = getDomainFromChildren(props, axis, children);
320
321
  var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
321
322
  var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
322
323
  domain = Domain.getDomainFromMinMax(min, max);
@@ -482,10 +483,11 @@ function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
482
483
  }
483
484
 
484
485
  function getStringsFromChildren(props, childComponents) {
485
- childComponents = childComponents || _react.default.Children.toArray(props.children);
486
- var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", childComponents);
487
- var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
488
- var dataStrings = getStringsFromData(childComponents);
486
+ var children = childComponents || _react.default.Children.toArray(props.children);
487
+
488
+ var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
489
+ var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
490
+ var dataStrings = getStringsFromData(children);
489
491
  return {
490
492
  x: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))),
491
493
  y: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y))))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-core",
3
- "version": "36.8.2",
3
+ "version": "36.8.3",
4
4
  "description": "Victory Core",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -23,7 +23,7 @@
23
23
  "lodash": "^4.17.21",
24
24
  "prop-types": "^15.8.1",
25
25
  "react-fast-compare": "^3.2.0",
26
- "victory-vendor": "^36.8.2"
26
+ "victory-vendor": "^36.8.3"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": ">=16.6.0"
@@ -1,4 +1,4 @@
1
- import { D3Scale, Datum, ID } from "./prop-types";
1
+ import { D3Scale, Datum, ID, ScalePropType } from "./prop-types";
2
2
  import { BlockProps, OrientationTypes } from "../victory-theme/types";
3
3
 
4
4
  /**
@@ -16,10 +16,13 @@ export interface CallbackArgs {
16
16
  index?: ID;
17
17
  x?: number;
18
18
  y?: number;
19
- scale?: {
20
- x?: D3Scale;
21
- y?: D3Scale;
22
- };
19
+ scale?:
20
+ | ScalePropType
21
+ | D3Scale
22
+ | {
23
+ x?: ScalePropType | D3Scale;
24
+ y?: ScalePropType | D3Scale;
25
+ };
23
26
  tick?: any;
24
27
  ticks?: any;
25
28
  text?: any;
@@ -97,11 +97,11 @@ export const interpolateFunction = function (a, b) {
97
97
  * differs in that it uses our custom interpolators when interpolating the value of each property in
98
98
  * an object. This allows the correct interpolation of nested objects, including styles
99
99
  *
100
- * @param {any} a - Start value.
101
- * @param {any} b - End value.
100
+ * @param {any} startValue - Start value.
101
+ * @param {any} endValue - End value.
102
102
  * @returns {Function} An interpolation function.
103
103
  */
104
- export const interpolateObject = function (a, b) {
104
+ export const interpolateObject = function (startValue, endValue) {
105
105
  const interpolateTypes = (x, y) => {
106
106
  if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) {
107
107
  return interpolateImmediate(x, y);
@@ -126,6 +126,8 @@ export const interpolateObject = function (a, b) {
126
126
 
127
127
  const i = {};
128
128
  const c = {};
129
+ let a = startValue;
130
+ let b = endValue;
129
131
  let k;
130
132
 
131
133
  if (a === null || typeof a !== "object") {
@@ -259,8 +259,9 @@ export class VictoryAnimation extends React.Component<
259
259
  step can generate imprecise values, sometimes greater than 1
260
260
  if this happens set the state to 1 and return, cancelling the timer
261
261
  */
262
- duration = duration !== undefined ? duration : this.props.duration;
263
- const step = duration ? elapsed / duration : 1;
262
+ const animationDuration =
263
+ duration !== undefined ? duration : this.props.duration;
264
+ const step = animationDuration ? elapsed / animationDuration : 1;
264
265
  if (step >= 1) {
265
266
  this.setState({
266
267
  data: this.interpolator!(1),
@@ -38,7 +38,7 @@ export interface VictoryLabelProps {
38
38
  capHeight?: StringOrNumberOrCallback;
39
39
  children?: StringOrNumberOrCallback;
40
40
  className?: string;
41
- datum?: object;
41
+ datum?: Record<string, any>;
42
42
  data?: any[];
43
43
  desc?: string;
44
44
  direction?: string;
@@ -121,8 +121,10 @@ const getStyles = (style, props) => {
121
121
  };
122
122
  }
123
123
  const getSingleStyle = (s) => {
124
- s = s ? defaults({}, s, defaultStyles) : defaultStyles;
125
- const baseStyles = Helpers.evaluateStyle(s, props);
124
+ const baseStyles = Helpers.evaluateStyle(
125
+ s ? defaults({}, s, defaultStyles) : defaultStyles,
126
+ props,
127
+ );
126
128
  return assign({}, baseStyles, { fontSize: getFontSize(baseStyles) });
127
129
  };
128
130
 
@@ -320,21 +322,20 @@ const getInlineXOffset = (calculatedProps, textElements, index) => {
320
322
  const centerOffset = -totalWidth / 2;
321
323
  switch (textAnchor) {
322
324
  case "start":
323
- return widths.reduce((memo, width, i) => {
324
- memo = i < index ? memo + width : memo;
325
- return memo;
326
- }, 0);
325
+ return widths.reduce(
326
+ (memo, width, i) => (i < index ? memo + width : memo),
327
+ 0,
328
+ );
327
329
  case "end":
328
- return widths.reduce((memo, width, i) => {
329
- memo = i > index ? memo - width : memo;
330
- return memo;
331
- }, 0);
330
+ return widths.reduce(
331
+ (memo, width, i) => (i > index ? memo - width : memo),
332
+ 0,
333
+ );
332
334
  default:
333
335
  // middle
334
336
  return widths.reduce((memo, width, i) => {
335
337
  const offsetWidth = i < index ? width : 0;
336
- memo = i === index ? memo + width / 2 : memo + offsetWidth;
337
- return memo;
338
+ return i === index ? memo + width / 2 : memo + offsetWidth;
338
339
  }, centerOffset);
339
340
  }
340
341
  };
@@ -584,8 +585,8 @@ const defaultProps = {
584
585
  export const VictoryLabel: {
585
586
  role: string;
586
587
  defaultStyles: typeof defaultStyles;
587
- } & React.FC<VictoryLabelProps> = (props) => {
588
- props = evaluateProps({ ...defaultProps, ...props });
588
+ } & React.FC<VictoryLabelProps> = (initialProps) => {
589
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
589
590
 
590
591
  if (props.text === null || props.text === undefined) {
591
592
  return null;
@@ -596,7 +597,7 @@ export const VictoryLabel: {
596
597
  calculatedProps;
597
598
 
598
599
  const tspanValues = (text as string[]).map((line, i) => {
599
- const currentStyle = getSingleValue(style!, i);
600
+ const currentStyle = getSingleValue(style, i);
600
601
  const capHeightPx = TextSize.convertLengthToPixels(
601
602
  `${capHeight}em`,
602
603
  currentStyle.fontSize as number,
@@ -607,7 +608,7 @@ export const VictoryLabel: {
607
608
  fontSize: currentStyle.fontSize || defaultStyles.fontSize,
608
609
  capHeight: capHeightPx,
609
610
  text: line,
610
- // @ts-expect-error TODO: This looks like a bug:
611
+ // TODO: This looks like a bug:
611
612
  textSize: TextSize.approximateTextSize(line, currentStyle),
612
613
  lineHeight: currentLineHeight,
613
614
  backgroundPadding: getSingleValue(backgroundPadding, i),
@@ -68,8 +68,8 @@ const defaultProps = {
68
68
  shapeRendering: "auto",
69
69
  };
70
70
 
71
- export const Arc = (props: ArcProps) => {
72
- props = evaluateProps({ ...defaultProps, ...props });
71
+ export const Arc = (initialProps: ArcProps) => {
72
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
73
73
 
74
74
  return React.cloneElement(props.pathComponent!, {
75
75
  ...props.events,
@@ -37,8 +37,8 @@ const defaultProps = {
37
37
  shapeRendering: "auto",
38
38
  };
39
39
 
40
- export const Background = (props: BackgroundProps) => {
41
- props = evaluateProps({ ...defaultProps, ...props });
40
+ export const Background = (initialProps: BackgroundProps) => {
41
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
42
42
 
43
43
  return props.polar
44
44
  ? React.cloneElement(props.circleComponent!, {
@@ -43,8 +43,8 @@ const defaultProps = {
43
43
  shapeRendering: "auto",
44
44
  };
45
45
 
46
- export const Border = (props: BorderProps) => {
47
- props = evaluateProps({ ...defaultProps, ...props });
46
+ export const Border = (initialProps: BorderProps) => {
47
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
48
48
 
49
49
  return React.cloneElement(props.rectComponent!, {
50
50
  ...props.events,
@@ -44,8 +44,8 @@ const defaultProps = {
44
44
  shapeRendering: "auto",
45
45
  };
46
46
 
47
- export const LineSegment = (props: LineSegmentProps) => {
48
- props = evaluateProps({ ...defaultProps, ...props });
47
+ export const LineSegment = (initialProps: LineSegmentProps) => {
48
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
49
49
 
50
50
  return React.cloneElement(props.lineComponent!, {
51
51
  ...props.events,
@@ -72,8 +72,8 @@ const defaultProps = {
72
72
  shapeRendering: "auto",
73
73
  };
74
74
 
75
- export const Point = (props: PointProps) => {
76
- props = evaluateProps({ ...defaultProps, ...props });
75
+ export const Point = (initialProps: PointProps) => {
76
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
77
77
  const userProps = UserProps.getSafeUserProps(props);
78
78
 
79
79
  return React.cloneElement(props.pathComponent!, {
@@ -47,8 +47,8 @@ const defaultProps = {
47
47
  shapeRendering: "auto",
48
48
  };
49
49
 
50
- export const Whisker = (props: WhiskerProps) => {
51
- props = evaluateProps({ ...defaultProps, ...props });
50
+ export const Whisker = (initialProps: WhiskerProps) => {
51
+ const props = evaluateProps({ ...defaultProps, ...initialProps });
52
52
  const {
53
53
  ariaLabel,
54
54
  groupComponent,
@@ -77,9 +77,9 @@ export const Whisker = (props: WhiskerProps) => {
77
77
  shapeRendering,
78
78
  };
79
79
 
80
- return React.cloneElement(groupComponent!, {}, [
80
+ return React.cloneElement(groupComponent, {}, [
81
81
  React.cloneElement(
82
- lineComponent!,
82
+ lineComponent,
83
83
  assign(
84
84
  { key: "major-whisker", "aria-label": ariaLabel },
85
85
  baseProps,
@@ -87,7 +87,7 @@ export const Whisker = (props: WhiskerProps) => {
87
87
  ),
88
88
  ),
89
89
  React.cloneElement(
90
- lineComponent!,
90
+ lineComponent,
91
91
  assign(
92
92
  { key: "minor-whisker", "aria-label": ariaLabel },
93
93
  baseProps,
@@ -270,12 +270,10 @@ export function addEvents<
270
270
  applyExternalMutations(props, externalMutations) {
271
271
  if (!isEmpty(externalMutations)) {
272
272
  const callbacks = props.externalEventMutations.reduce(
273
- (memo, mutation) => {
274
- memo = isFunction(mutation.callback)
273
+ (memo, mutation) =>
274
+ isFunction(mutation.callback)
275
275
  ? memo.concat(mutation.callback)
276
- : memo;
277
- return memo;
278
- },
276
+ : memo,
279
277
  [] as Array<() => void>,
280
278
  );
281
279
  const compiledCallbacks = callbacks.length
@@ -327,9 +325,9 @@ export function addEvents<
327
325
  }
328
326
 
329
327
  getBaseProps(props, getSharedEventState): this["baseProps"] {
330
- getSharedEventState =
328
+ const getSharedEventStateFunction =
331
329
  getSharedEventState || this.getSharedEventState.bind(this);
332
- const sharedParentState = getSharedEventState("parent", "parent");
330
+ const sharedParentState = getSharedEventStateFunction("parent", "parent");
333
331
  const parentState = this.getEventState("parent", "parent");
334
332
  const baseParentProps = defaults({}, parentState, sharedParentState);
335
333
  const parentPropsList = baseParentProps.parentControlledProps;
@@ -437,6 +435,7 @@ export function addEvents<
437
435
  const { dataComponent, labelComponent, groupComponent } = props;
438
436
  const dataKeys = without(this.dataKeys, "all");
439
437
  const labelComponents = dataKeys.reduce((memo, key) => {
438
+ let newMemo = memo;
440
439
  const labelProps = this.getComponentProps(
441
440
  labelComponent,
442
441
  "labels",
@@ -447,9 +446,11 @@ export function addEvents<
447
446
  labelProps.text !== undefined &&
448
447
  labelProps.text !== null
449
448
  ) {
450
- memo = memo.concat(React.cloneElement(labelComponent!, labelProps));
449
+ newMemo = newMemo.concat(
450
+ React.cloneElement(labelComponent!, labelProps),
451
+ );
451
452
  }
452
- return memo;
453
+ return newMemo;
453
454
  }, [] as React.ReactElement[]);
454
455
 
455
456
  const dataProps = this.getComponentProps(dataComponent, "data", "all");
@@ -36,10 +36,14 @@ export function getAxis(props) {
36
36
  * @returns {Array} all axis components that pass the given predicate or []
37
37
  */
38
38
  export function findAxisComponents(childComponents, predicate?) {
39
- predicate = predicate || identity;
39
+ const predicateFunction = predicate || identity;
40
40
  const findAxes = (children) => {
41
41
  return children.reduce((memo, child) => {
42
- if (child.type && child.type.role === "axis" && predicate(child)) {
42
+ if (
43
+ child.type &&
44
+ child.type.role === "axis" &&
45
+ predicateFunction(child)
46
+ ) {
43
47
  return memo.concat(child);
44
48
  } else if (child.props && child.props.children) {
45
49
  return memo.concat(
@@ -95,6 +95,7 @@ export interface VictoryCommonThemeProps {
95
95
  animate?: boolean | AnimatePropTypeInterface;
96
96
  colorScale?: ColorScalePropType;
97
97
  containerComponent?: React.ReactElement;
98
+ disableInlineStyles?: boolean;
98
99
  domainPadding?: DomainPaddingPropType;
99
100
  externalEventMutations?: EventCallbackInterface<
100
101
  string | string[],
@@ -58,11 +58,12 @@ function sortData(dataset, sortKey, sortOrder = "ascending") {
58
58
  }
59
59
 
60
60
  // Ensures previous VictoryLine api for sortKey prop stays consistent
61
+ let formattedSortKey = sortKey;
61
62
  if (sortKey === "x" || sortKey === "y") {
62
- sortKey = `_${sortKey}`;
63
+ formattedSortKey = `_${sortKey}`;
63
64
  }
64
65
  const order = sortOrder === "ascending" ? "asc" : "desc";
65
- return orderBy(dataset, sortKey, order);
66
+ return orderBy(dataset, formattedSortKey, order);
66
67
  }
67
68
 
68
69
  // This method will remove data points that break certain scales. (log scale only)
@@ -239,6 +240,9 @@ export function formatData(
239
240
  }
240
241
 
241
242
  const defaultKeys = ["x", "y", "y0"];
243
+ // TODO: We shouldn’t mutate the expectedKeys param here,
244
+ // but we need to figure out why changing it causes regressions in tests.
245
+ // eslint-disable-next-line no-param-reassign
242
246
  expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys;
243
247
 
244
248
  const createAccessor = (name) => {
@@ -281,10 +285,10 @@ export function formatData(
281
285
  ? dataset
282
286
  : dataset.reduce((dataArr, datum, index) => {
283
287
  // eslint-disable-line complexity
284
- datum = parseDatum(datum);
285
- const fallbackValues = { x: index, y: datum };
288
+ const parsedDatum = parseDatum(datum);
289
+ const fallbackValues = { x: index, y: parsedDatum };
286
290
  const processedValues = expectedKeys!.reduce((memo, type) => {
287
- const processedValue = accessor[type](datum);
291
+ const processedValue = accessor[type](parsedDatum);
288
292
  const value =
289
293
  processedValue !== undefined
290
294
  ? processedValue
@@ -300,7 +304,7 @@ export function formatData(
300
304
  return memo;
301
305
  }, {});
302
306
 
303
- const formattedDatum = assign({}, processedValues, datum);
307
+ const formattedDatum = assign({}, processedValues, parsedDatum);
304
308
  if (!isEmpty(formattedDatum)) {
305
309
  dataArr.push(formattedDatum);
306
310
  }
@@ -408,8 +412,8 @@ export function getStringsFromData(props, axis) {
408
412
  const sortedData = sortData(data, props.sortKey, props.sortOrder);
409
413
  const dataStrings = sortedData
410
414
  .reduce((dataArr, datum) => {
411
- datum = parseDatum(datum);
412
- dataArr.push(accessor(datum));
415
+ const parsedDatum = parseDatum(datum);
416
+ dataArr.push(accessor(parsedDatum));
413
417
  return dataArr;
414
418
  }, [])
415
419
  .filter((datum) => typeof datum === "string");