victory-core 36.5.3 → 36.6.0

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 (90) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/victory-core.js +5299 -4724
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +2 -1
  5. package/es/victory-animation/victory-animation.js +1 -1
  6. package/es/victory-label/victory-label.js +19 -19
  7. package/es/victory-portal/portal.js +2 -2
  8. package/es/victory-primitives/arc.js +1 -1
  9. package/es/victory-primitives/circle.d.ts +1 -0
  10. package/es/victory-primitives/line.d.ts +1 -0
  11. package/es/victory-primitives/path.d.ts +1 -0
  12. package/es/victory-primitives/rect.d.ts +1 -0
  13. package/es/victory-primitives/tspan.d.ts +1 -0
  14. package/es/victory-state/victory-provider.d.ts +1 -0
  15. package/es/victory-transition/victory-transition.js +22 -22
  16. package/es/victory-util/add-events.d.ts +5 -2
  17. package/es/victory-util/add-events.js +4 -5
  18. package/es/victory-util/axis.js +22 -20
  19. package/es/victory-util/collection.d.ts +2 -2
  20. package/es/victory-util/data.d.ts +1 -1
  21. package/es/victory-util/data.js +2 -2
  22. package/es/victory-util/domain.js +4 -4
  23. package/es/victory-util/events.js +2 -2
  24. package/es/victory-util/hooks/use-animation-state.d.ts +22 -0
  25. package/es/victory-util/hooks/use-animation-state.js +2 -2
  26. package/es/victory-util/label-helpers.js +12 -12
  27. package/es/victory-util/prop-types.js +2 -2
  28. package/es/victory-util/scale.js +1 -1
  29. package/es/victory-util/selection.d.ts +5 -1
  30. package/es/victory-util/selection.js +15 -15
  31. package/es/victory-util/style.js +12 -12
  32. package/es/victory-util/textsize.js +2 -2
  33. package/es/victory-util/transitions.js +2 -2
  34. package/es/victory-util/with-container.d.ts +1 -1
  35. package/es/victory-util/with-container.js +2 -1
  36. package/es/victory-util/wrapper.js +8 -8
  37. package/lib/index.d.ts +2 -1
  38. package/lib/victory-label/victory-label.js +19 -19
  39. package/lib/victory-portal/portal.js +2 -2
  40. package/lib/victory-primitives/circle.d.ts +1 -0
  41. package/lib/victory-primitives/line.d.ts +1 -0
  42. package/lib/victory-primitives/path.d.ts +1 -0
  43. package/lib/victory-primitives/rect.d.ts +1 -0
  44. package/lib/victory-primitives/tspan.d.ts +1 -0
  45. package/lib/victory-state/victory-provider.d.ts +1 -0
  46. package/lib/victory-transition/victory-transition.js +21 -21
  47. package/lib/victory-util/add-events.d.ts +5 -2
  48. package/lib/victory-util/add-events.js +4 -4
  49. package/lib/victory-util/axis.js +22 -20
  50. package/lib/victory-util/collection.d.ts +2 -2
  51. package/lib/victory-util/data.d.ts +1 -1
  52. package/lib/victory-util/data.js +2 -2
  53. package/lib/victory-util/domain.js +4 -4
  54. package/lib/victory-util/events.js +2 -2
  55. package/lib/victory-util/hooks/use-animation-state.d.ts +22 -0
  56. package/lib/victory-util/hooks/use-animation-state.js +2 -2
  57. package/lib/victory-util/label-helpers.js +12 -12
  58. package/lib/victory-util/prop-types.js +2 -2
  59. package/lib/victory-util/scale.js +1 -1
  60. package/lib/victory-util/selection.d.ts +5 -1
  61. package/lib/victory-util/selection.js +15 -15
  62. package/lib/victory-util/style.js +12 -12
  63. package/lib/victory-util/textsize.js +2 -2
  64. package/lib/victory-util/transitions.js +2 -2
  65. package/lib/victory-util/with-container.d.ts +1 -1
  66. package/lib/victory-util/with-container.js +5 -3
  67. package/lib/victory-util/wrapper.js +8 -8
  68. package/package.json +252 -7
  69. package/src/index.ts +2 -4
  70. package/src/victory-animation/victory-animation.tsx +1 -1
  71. package/src/victory-label/victory-label.tsx +20 -25
  72. package/src/victory-primitives/arc.tsx +1 -1
  73. package/src/victory-transition/victory-transition.tsx +24 -26
  74. package/src/victory-util/add-events.tsx +14 -9
  75. package/src/victory-util/axis.tsx +12 -13
  76. package/src/victory-util/collection.tsx +13 -4
  77. package/src/victory-util/data.ts +2 -3
  78. package/src/victory-util/domain.ts +6 -6
  79. package/src/victory-util/events.ts +1 -2
  80. package/src/victory-util/hooks/{use-animation-state.js → use-animation-state.ts} +23 -8
  81. package/src/victory-util/label-helpers.ts +8 -12
  82. package/src/victory-util/point-path-helpers.ts +1 -1
  83. package/src/victory-util/prop-types.ts +1 -2
  84. package/src/victory-util/scale.ts +1 -1
  85. package/src/victory-util/selection.ts +12 -13
  86. package/src/victory-util/style.ts +10 -11
  87. package/src/victory-util/textsize.ts +3 -3
  88. package/src/victory-util/transitions.ts +1 -2
  89. package/src/victory-util/with-container.tsx +2 -5
  90. package/src/victory-util/wrapper.tsx +8 -10
@@ -15,7 +15,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
15
15
 
16
16
  // Based on measuring specific character widths
17
17
  // as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
18
- //prettier-ignore
18
+ // prettier-ignore
19
19
  var fonts = {
20
20
  "American Typewriter": {
21
21
  widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.4203125, 0.3296875, 0.6, 0.6375, 0.8015625, 0.8203125, 0.1875, 0.45625, 0.45625, 0.6375, 0.5, 0.2734375, 0.309375, 0.2734375, 0.4390625, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.2734375, 0.2734375, 0.5, 0.5, 0.5, 0.6, 0.6921875, 0.7640625, 0.6921875, 0.6375, 0.728125, 0.6734375, 0.6203125, 0.7109375, 0.784375, 0.3828125, 0.6421875, 0.7859375, 0.6375, 0.9484375, 0.7640625, 0.65625, 0.6375, 0.65625, 0.7296875, 0.6203125, 0.6375, 0.7109375, 0.740625, 0.940625, 0.784375, 0.7578125, 0.6203125, 0.4375, 0.5, 0.4375, 0.5, 0.5, 0.4921875, 0.5734375, 0.5890625, 0.5109375, 0.6, 0.528125, 0.43125, 0.5578125, 0.6375, 0.3109375, 0.40625, 0.6234375, 0.309375, 0.928125, 0.6375, 0.546875, 0.6, 0.58125, 0.4921875, 0.4921875, 0.4, 0.6203125, 0.625, 0.825, 0.6375, 0.640625, 0.528125, 0.5, 0.5, 0.5, 0.6671875],
@@ -121,7 +121,7 @@ var fonts = {
121
121
  widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875],
122
122
  avg: 0.6171875000000003
123
123
  }
124
- }; //https://developer.mozilla.org/en/docs/Web/CSS/length
124
+ }; // https://developer.mozilla.org/en/docs/Web/CSS/length
125
125
  // Absolute sizes in pixels for obsolete measurement units.
126
126
 
127
127
  var absoluteMeasurementUnitsToPixels = {
@@ -345,9 +345,9 @@ export function getTransitionPropsFactory(props, state, setState) {
345
345
  if (defaultTransitions) {
346
346
  var animationDuration = animate[type] && animate[type].duration;
347
347
  return animationDuration !== undefined ? animationDuration : defaultTransitions[type] && defaultTransitions[type].duration;
348
- } else {
349
- return {};
350
348
  }
349
+
350
+ return {};
351
351
  }; // eslint-disable-next-line max-statements, complexity, max-len
352
352
 
353
353
 
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { VictoryProviderProps } from "victory-core";
2
+ import { VictoryProviderProps } from "../victory-state";
3
3
  import { VictoryCommonProps } from "./common-props";
4
4
  export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: (props: Props) => React.ReactElement, initialProviderProps?: Partial<VictoryProviderProps>): (props: Props) => JSX.Element;
5
5
  //# sourceMappingURL=with-container.d.ts.map
@@ -5,7 +5,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import React from "react";
8
- import { VictoryProvider, VictoryContainer } from "victory-core";
8
+ import { VictoryProvider } from "../victory-state";
9
+ import { VictoryContainer } from "../victory-container/victory-container";
9
10
  var defaultProviderProps = {
10
11
  width: 450,
11
12
  height: 300,
@@ -241,9 +241,9 @@ export function getDomainFromChildren(props, axis, childComponents) {
241
241
  return null;
242
242
  } else if (child.type && _isFunction(child.type.getDomain)) {
243
243
  return child.props && child.type.getDomain(sharedProps, axis);
244
- } else {
245
- return Domain.getDomain(sharedProps, axis);
246
244
  }
245
+
246
+ return Domain.getDomain(sharedProps, axis);
247
247
  };
248
248
 
249
249
  var childDomains = Helpers.reduceChildren(children, iteratee, props);
@@ -366,13 +366,13 @@ export function getStringsFromCategories(childComponents, axis) {
366
366
 
367
367
  if (!Domain.isDomainComponent(child) || !childProps.categories) {
368
368
  return null;
369
- } else {
370
- var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
371
- var categoryStrings = categories && categories.filter(function (val) {
372
- return typeof val === "string";
373
- });
374
- return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
375
369
  }
370
+
371
+ var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
372
+ var categoryStrings = categories && categories.filter(function (val) {
373
+ return typeof val === "string";
374
+ });
375
+ return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
376
376
  };
377
377
 
378
378
  return Helpers.reduceChildren(childComponents.slice(0), iteratee);
package/lib/index.d.ts CHANGED
@@ -12,7 +12,8 @@ export * from "./victory-portal/portal";
12
12
  export * from "./victory-portal/portal-context";
13
13
  export * from "./victory-portal/victory-portal";
14
14
  export * from "./victory-primitives";
15
- export { Border as Box, type BorderProps as BoxProps, } from "./victory-primitives";
15
+ export { Border as Box } from "./victory-primitives";
16
+ export type { BorderProps as BoxProps } from "./victory-primitives";
16
17
  export * from "./victory-util";
17
18
  export * from "./victory-state";
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -85,14 +85,14 @@ var getFontSize = function (style) {
85
85
  } else if (baseSize === undefined || baseSize === null) {
86
86
  return defaultStyles.fontSize;
87
87
  } else if (typeof baseSize === "string") {
88
- var fontSize = +baseSize.replace("px", "");
88
+ var fontSize = Number(baseSize.replace("px", ""));
89
89
 
90
90
  if (!isNaN(fontSize)) {
91
91
  return fontSize;
92
- } else {
93
- Log.warn("fontSize should be expressed as a number of pixels");
94
- return defaultStyles.fontSize;
95
92
  }
93
+
94
+ Log.warn("fontSize should be expressed as a number of pixels");
95
+ return defaultStyles.fontSize;
96
96
  }
97
97
 
98
98
  return defaultStyles.fontSize;
@@ -149,12 +149,12 @@ var getBackgroundPadding = function (props) {
149
149
  padding: padding
150
150
  });
151
151
  });
152
- } else {
153
- var padding = Helpers.evaluateProp(props.backgroundPadding, props);
154
- return Helpers.getPadding({
155
- padding: padding
156
- });
157
152
  }
153
+
154
+ var padding = Helpers.evaluateProp(props.backgroundPadding, props);
155
+ return Helpers.getPadding({
156
+ padding: padding
157
+ });
158
158
  };
159
159
 
160
160
  var getLineHeight = function (props) {
@@ -162,9 +162,9 @@ var getLineHeight = function (props) {
162
162
 
163
163
  if (Array.isArray(lineHeight)) {
164
164
  return (0, _isEmpty2.default)(lineHeight) ? [1] : lineHeight;
165
- } else {
166
- return lineHeight;
167
165
  }
166
+
167
+ return lineHeight;
168
168
  };
169
169
 
170
170
  var getContent = function (text, props) {
@@ -207,13 +207,13 @@ var getDy = function (props, verticalAnchor, lineHeight) {
207
207
  return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0];
208
208
  } else if (length === 1) {
209
209
  return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
210
- } else {
211
- var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
212
- return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
213
- }, 0);
214
-
215
- return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
216
210
  }
211
+
212
+ var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
213
+ return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
214
+ }, 0);
215
+
216
+ return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
217
217
  };
218
218
 
219
219
  var getTransform = function (props, x, y) {
@@ -417,9 +417,9 @@ var getTSpanDy = function (tspanValues, calculatedProps, i) {
417
417
  return calculateSpanDy(tspanValues, i, calculatedProps);
418
418
  } else if (inline) {
419
419
  return i === 0 ? current.backgroundPadding.top : undefined;
420
- } else {
421
- return current.backgroundPadding.top;
422
420
  }
421
+
422
+ return current.backgroundPadding.top;
423
423
  };
424
424
 
425
425
  var evaluateProps = function (props) {
@@ -39,8 +39,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
39
39
 
40
40
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
41
41
 
42
- var Portal = /*#__PURE__*/function (_React$Component) {
43
- _inherits(Portal, _React$Component);
42
+ var Portal = /*#__PURE__*/function (_ref) {
43
+ _inherits(Portal, _ref);
44
44
 
45
45
  var _super = _createSuper(Portal);
46
46
 
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Circle: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=circle.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Line: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=line.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Path: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=path.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryPrimitiveShapeProps } from "./types";
2
3
  export declare const Rect: (props: VictoryPrimitiveShapeProps) => JSX.Element;
3
4
  //# sourceMappingURL=rect.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VictoryCommonPrimitiveProps } from "../victory-util/common-props";
2
3
  export declare const TSpan: (props: VictoryCommonPrimitiveProps) => JSX.Element;
3
4
  //# sourceMappingURL=tspan.d.ts.map
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { D3ScaleFn, DomainTuple, ForAxes } from "../types/prop-types";
2
3
  import { FormattedDatum } from "./helpers/get-data";
3
4
  import { VictoryCalculatedStateProps, VictoryProviderProps } from "./types";
@@ -85,7 +85,7 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
85
85
  value: function componentDidMount() {
86
86
  this.setState({
87
87
  nodesShouldLoad: true
88
- }); //eslint-disable-line react/no-did-mount-set-state
88
+ }); // eslint-disable-line react/no-did-mount-set-state
89
89
  }
90
90
  }, {
91
91
  key: "shouldComponentUpdate",
@@ -120,26 +120,26 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
120
120
  oldProps: oldProps,
121
121
  nextProps: nextProps
122
122
  };
123
- } else {
124
- var oldChildren = _react.default.Children.toArray(props.children);
123
+ }
125
124
 
126
- var nextChildren = _react.default.Children.toArray(nextProps.children);
125
+ var oldChildren = _react.default.Children.toArray(props.children);
127
126
 
128
- var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
129
- nodesWillExit = _Transitions$getIniti.nodesWillExit,
130
- nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
131
- childrenTransitions = _Transitions$getIniti.childrenTransitions,
132
- nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
127
+ var nextChildren = _react.default.Children.toArray(nextProps.children);
133
128
 
134
- return {
135
- nodesWillExit: nodesWillExit,
136
- nodesWillEnter: nodesWillEnter,
137
- childrenTransitions: childrenTransitions,
138
- nodesShouldEnter: nodesShouldEnter,
139
- oldProps: nodesWillExit ? props : null,
140
- nextProps: nextProps
141
- };
142
- }
129
+ var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
130
+ nodesWillExit = _Transitions$getIniti.nodesWillExit,
131
+ nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
132
+ childrenTransitions = _Transitions$getIniti.childrenTransitions,
133
+ nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
134
+
135
+ return {
136
+ nodesWillExit: nodesWillExit,
137
+ nodesWillEnter: nodesWillEnter,
138
+ childrenTransitions: childrenTransitions,
139
+ nodesShouldEnter: nodesShouldEnter,
140
+ oldProps: nodesWillExit ? props : null,
141
+ nextProps: nextProps
142
+ };
143
143
  }
144
144
  }, {
145
145
  key: "getDomainFromChildren",
@@ -164,10 +164,10 @@ var VictoryTransition = /*#__PURE__*/function (_React$Component) {
164
164
 
165
165
  if (!childProps.children && domain) {
166
166
  return domain;
167
- } else {
168
- var childDomains = getChildDomains([child]);
169
- return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
170
167
  }
168
+
169
+ var childDomains = getChildDomains([child]);
170
+ return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
171
171
  }
172
172
  }, {
173
173
  key: "pickProps",
@@ -6,7 +6,7 @@ import { VictoryLabelableProps } from "../types/prop-types";
6
6
  export declare type MixinOptions = {
7
7
  components?: Array<{
8
8
  name: string;
9
- index?: string;
9
+ index?: string | number;
10
10
  }>;
11
11
  };
12
12
  export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatableProps, VictoryLabelableProps {
@@ -21,11 +21,14 @@ export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatabl
21
21
  * class MyComponent extends React.Component<MyProps> { ... }
22
22
  */
23
23
  export interface EventsMixinClass<TProps> {
24
- renderContainer(component: React.ReactElement, children: React.ReactElement[]): React.ReactElement;
24
+ renderContainer(component: React.ReactElement, children: React.ReactElement | React.ReactElement[]): React.ReactElement;
25
25
  cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
26
26
  getEventState: typeof Events.getEventState;
27
+ renderData(props: TProps): any;
27
28
  renderContinuousData(props: TProps): any;
28
29
  animateComponent(props: TProps, defaultAnimationWhitelist: any): any;
30
+ getComponentProps(component: React.ReactElement, type: string, index: number): TProps;
31
+ dataKeys: string[];
29
32
  }
30
33
  /**
31
34
  * These fields are calculated by the Mixin
@@ -227,11 +227,11 @@ function addEvents(WrappedComponent) {
227
227
  if (!props.standalone && component.name === "parent") {
228
228
  // don't check for changes on parent props for non-standalone components
229
229
  return undefined;
230
- } else {
231
- return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
232
- return getState(key, component.name);
233
- }).filter(Boolean);
234
230
  }
231
+
232
+ return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
233
+ return getState(key, component.name);
234
+ }).filter(Boolean);
235
235
  }).filter(Boolean);
236
236
  return stateChanges;
237
237
  }
@@ -206,20 +206,20 @@ function getDefaultTickFormat(props) {
206
206
  return stringTicks(props) ? function (x, index) {
207
207
  return tickValues[index];
208
208
  } : fallbackFormat;
209
- } else {
210
- var invertedStringMap = stringMap && (0, _invert2.default)(stringMap);
211
- var tickValueArray = (0, _orderBy2.default)((0, _values2.default)(stringMap), function (n) {
212
- return n;
213
- });
214
- var dataNames = tickValueArray.map(function (tick) {
215
- return invertedStringMap[tick];
216
- }); // string ticks should have one tick of padding at the beginning
217
-
218
- var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
219
- return function (x) {
220
- return dataTicks[x];
221
- };
222
209
  }
210
+
211
+ var invertedStringMap = stringMap && (0, _invert2.default)(stringMap);
212
+ var tickValueArray = (0, _orderBy2.default)((0, _values2.default)(stringMap), function (n) {
213
+ return n;
214
+ });
215
+ var dataNames = tickValueArray.map(function (tick) {
216
+ return invertedStringMap[tick];
217
+ }); // string ticks should have one tick of padding at the beginning
218
+
219
+ var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
220
+ return function (x) {
221
+ return dataTicks[x];
222
+ };
223
223
  }
224
224
 
225
225
  function getStringTicks(props) {
@@ -284,7 +284,9 @@ function getTickArray(props) {
284
284
  }
285
285
  });
286
286
  return newTickArray;
287
- } else return undefined;
287
+ }
288
+
289
+ return undefined;
288
290
  };
289
291
 
290
292
  return Array.isArray(tickArray) && tickArray.length ? buildTickArray(tickArray) : undefined;
@@ -325,11 +327,11 @@ function getTickFormat(props, scale) {
325
327
  };
326
328
 
327
329
  return stringMap ? applyStringTicks : tickFormat;
328
- } else {
329
- return function (x) {
330
- return x;
331
- };
332
330
  }
331
+
332
+ return function (x) {
333
+ return x;
334
+ };
333
335
  }
334
336
 
335
337
  function downsampleTicks(ticks, tickCount) {
@@ -376,7 +378,7 @@ function getTicks(props, scale) {
376
378
  * @param {String} axis: either x or y
377
379
  * @returns {Array} returns a domain from tickValues
378
380
  */
379
- //eslint-disable-next-line max-statements
381
+ // eslint-disable-next-line max-statements
380
382
 
381
383
 
382
384
  function getDomainFromData(props, axis) {
@@ -398,7 +400,7 @@ function getDomainFromData(props, axis) {
398
400
  var maxDomain = Domain.getMaxFromProps(props, axis);
399
401
  var tickStrings = stringTicks(props);
400
402
  var ticks = tickValues.map(function (value) {
401
- return +value;
403
+ return Number(value);
402
404
  });
403
405
  var defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
404
406
  var defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
@@ -1,8 +1,8 @@
1
1
  export declare function containsStrings<T>(collection: Array<T>): boolean;
2
2
  export declare function containsDates(collection: Array<number | Date>): boolean;
3
3
  export declare function containsNumbers(collection: any): boolean;
4
- export declare function containsOnlyStrings(collection: any): any;
5
- export declare function isArrayOfArrays(collection: any): any;
4
+ export declare function containsOnlyStrings(collection: Array<string> | unknown): collection is Array<string>;
5
+ export declare function isArrayOfArrays<T>(collection: Array<T> | Array<Array<T>> | unknown): collection is Array<Array<T>>;
6
6
  export declare function removeUndefined(arr: any): any;
7
7
  export declare function getMaxValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
8
8
  export declare function getMinValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
@@ -1,4 +1,4 @@
1
- export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline: any): any;
1
+ export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline?: any): any;
2
2
  /**
3
3
  * Returns an object mapping string data to numeric data
4
4
  * @param {Object} props: the props object
@@ -178,9 +178,9 @@ function addEventKeys(props, data) {
178
178
  return eventKey !== undefined ? (0, _assign2.default)({
179
179
  eventKey: eventKey
180
180
  }, datum) : datum;
181
- } else {
182
- return datum;
183
181
  }
182
+
183
+ return datum;
184
184
  });
185
185
  } // Exported Functions
186
186
  // This method will remove data points that fall outside of the desired domain (non-continuous charts only)
@@ -112,7 +112,7 @@ function getExtremeFromData(dataset, axis) {
112
112
  return getExtreme([memo, current]);
113
113
  }, initialValue);
114
114
  return containsDate ? new Date(result) : result;
115
- } //eslint-disable-next-line max-statements
115
+ } // eslint-disable-next-line max-statements
116
116
 
117
117
 
118
118
  function padDomain(domain, props, axis) {
@@ -310,12 +310,12 @@ function getDomainFromMinMax(min, max) {
310
310
  var verySmallNumber = // eslint-disable-next-line no-magic-numbers
311
311
  val === 0 ? 2 * Math.pow(10, -10) : Math.pow(10, -10);
312
312
  var verySmallDate = 1;
313
- var minVal = val instanceof Date ? new Date(+val - verySmallDate) : +val - verySmallNumber;
314
- var maxVal = val instanceof Date ? new Date(+val + verySmallDate) : +val + verySmallNumber;
313
+ var minVal = val instanceof Date ? new Date(Number(val) - verySmallDate) : Number(val) - verySmallNumber;
314
+ var maxVal = val instanceof Date ? new Date(Number(val) + verySmallDate) : Number(val) + verySmallNumber;
315
315
  return val === 0 ? [0, maxVal] : [minVal, maxVal];
316
316
  };
317
317
 
318
- return +min === +max ? getSinglePointDomain(max) : [min, max];
318
+ return Number(min) === Number(max) ? getSinglePointDomain(max) : [min, max];
319
319
  }
320
320
  /**
321
321
  * Returns a the domain for a given axis if domain is given in props
@@ -416,9 +416,9 @@ function getExternalMutation(mutations, baseProps, baseState, identifier) {
416
416
  return "".concat(m);
417
417
  });
418
418
  return (0, _includes2.default)(stringArray, identifier[type]);
419
- } else {
420
- return false;
421
419
  }
420
+
421
+ return false;
422
422
  };
423
423
 
424
424
  mutations = Array.isArray(mutations) ? mutations : [mutations];
@@ -0,0 +1,22 @@
1
+ declare type AnyObject = Record<string, any>;
2
+ export declare type AnimationState = {
3
+ nodesShouldLoad?: boolean;
4
+ nodesDoneLoad?: boolean;
5
+ animating?: boolean;
6
+ childrenTransitions?: any[];
7
+ nodesWillExit?: boolean;
8
+ nodesWillEnter?: boolean;
9
+ nodesShouldEnter?: boolean;
10
+ oldProps?: AnyObject;
11
+ nextProps?: AnyObject;
12
+ continuous?: boolean;
13
+ };
14
+ export declare const useAnimationState: (initialState?: AnimationState) => {
15
+ state: AnimationState;
16
+ setState: (newState: AnimationState) => void;
17
+ getAnimationProps: (props: AnyObject | undefined, child: any, index: any) => any;
18
+ setAnimationState: (props: AnyObject | undefined, nextProps: any) => void;
19
+ getProps: (initialProps: AnyObject) => AnyObject;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=use-animation-state.d.ts.map
@@ -96,7 +96,7 @@ var useAnimationState = function () {
96
96
 
97
97
 
98
98
  var setAnimationState = _react.default.useCallback(function (props, nextProps) {
99
- if (!props || !props.animate) {
99
+ if (!(props !== null && props !== void 0 && props.animate)) {
100
100
  return;
101
101
  }
102
102
 
@@ -136,7 +136,7 @@ var useAnimationState = function () {
136
136
  nodesWillEnter: nodesWillEnter,
137
137
  nodesShouldEnter: nodesShouldEnter,
138
138
  childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
139
- oldProps: _nodesWillExit ? props : null,
139
+ oldProps: _nodesWillExit ? props : undefined,
140
140
  nextProps: nextProps,
141
141
  continuous: continuous
142
142
  });
@@ -31,9 +31,9 @@ function getVerticalAnchor(props, datum) {
31
31
  return datum.verticalAnchor || labelStyle.verticalAnchor;
32
32
  } else if (!props.horizontal) {
33
33
  return sign >= 0 ? "end" : "start";
34
- } else {
35
- return "middle";
36
34
  }
35
+
36
+ return "middle";
37
37
  }
38
38
 
39
39
  function getTextAnchor(props, datum) {
@@ -47,9 +47,9 @@ function getTextAnchor(props, datum) {
47
47
  return datum.verticalAnchor || labelStyle.verticalAnchor;
48
48
  } else if (!horizontal) {
49
49
  return "middle";
50
- } else {
51
- return sign >= 0 ? "start" : "end";
52
50
  }
51
+
52
+ return sign >= 0 ? "start" : "end";
53
53
  }
54
54
 
55
55
  function getAngle(props, datum) {
@@ -95,13 +95,13 @@ function getPosition(props, datum) {
95
95
  x: x,
96
96
  y: y
97
97
  };
98
- } else {
99
- var polarPadding = getPolarPadding(props, datum);
100
- return {
101
- x: x + polarPadding.x,
102
- y: y + polarPadding.y
103
- };
104
98
  }
99
+
100
+ var polarPadding = getPolarPadding(props, datum);
101
+ return {
102
+ x: x + polarPadding.x,
103
+ y: y + polarPadding.y
104
+ };
105
105
  }
106
106
 
107
107
  function getPolarPadding(props, datum) {
@@ -132,9 +132,9 @@ function getPolarOrientation(degrees) {
132
132
  return "top"; // eslint-disable-next-line no-magic-numbers
133
133
  } else if (degrees > 135 && degrees < 225) {
134
134
  return "left";
135
- } else {
136
- return "bottom";
137
135
  }
136
+
137
+ return "bottom";
138
138
  } // Exported Functions
139
139
 
140
140
 
@@ -79,9 +79,9 @@ var getConstructor = function (value) {
79
79
  return undefinedConstructor;
80
80
  } else if (value === null) {
81
81
  return nullConstructor;
82
- } else {
83
- return value.constructor;
84
82
  }
83
+
84
+ return value.constructor;
85
85
  };
86
86
  /**
87
87
  * Get the name of the constructor used to create `value`, using
@@ -55,7 +55,7 @@ function isScaleDefined(props, axis) {
55
55
  if (!props.scale) {
56
56
  return false;
57
57
  } else if (props.scale.x || props.scale.y) {
58
- return props.scale[axis] ? true : false;
58
+ return !!props.scale[axis];
59
59
  }
60
60
 
61
61
  return true;
@@ -3,7 +3,10 @@ import { VictoryCommonProps } from "./index";
3
3
  import type { DomainPropType, ScaleXYPropType } from "../types/prop-types";
4
4
  export declare function getParentSVG(evt: Pick<React.SyntheticEvent, "target"> & Partial<Pick<React.SyntheticEvent, "nativeEvent">>): SVGElement;
5
5
  export declare function getSVGEventCoordinates(evt: React.SyntheticEvent, svg?: SVGElement): SVGCoordinateType;
6
- export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType): DomainPropType;
6
+ export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType): {
7
+ x: number[];
8
+ y: number[];
9
+ };
7
10
  export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
8
11
  export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
9
12
  export declare type SVGCoordinateType = {
@@ -20,6 +23,7 @@ declare type ComputedCommonProps = {
20
23
  x2: number;
21
24
  y1: number;
22
25
  y2: number;
26
+ horizontal?: boolean;
23
27
  };
24
28
  export {};
25
29
  //# sourceMappingURL=selection.d.ts.map