victory-core 36.9.2 → 37.0.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 (110) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/victory-core.js +4371 -5749
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-accessible-group/victory-accessible-group.js +9 -15
  5. package/es/victory-animation/util.js +28 -47
  6. package/es/victory-animation/victory-animation.js +51 -67
  7. package/es/victory-clip-container/victory-clip-container.js +153 -229
  8. package/es/victory-container/victory-container.js +157 -216
  9. package/es/victory-label/victory-label.js +246 -323
  10. package/es/victory-portal/portal-context.js +1 -2
  11. package/es/victory-portal/portal.js +30 -76
  12. package/es/victory-portal/victory-portal.js +47 -104
  13. package/es/victory-primitives/arc.js +44 -47
  14. package/es/victory-primitives/background.js +14 -17
  15. package/es/victory-primitives/border.js +20 -24
  16. package/es/victory-primitives/circle.js +13 -27
  17. package/es/victory-primitives/clip-path.js +3 -7
  18. package/es/victory-primitives/line-segment.js +20 -24
  19. package/es/victory-primitives/line.js +13 -27
  20. package/es/victory-primitives/path.js +13 -27
  21. package/es/victory-primitives/point.js +36 -40
  22. package/es/victory-primitives/rect.js +13 -27
  23. package/es/victory-primitives/text.js +15 -28
  24. package/es/victory-primitives/tspan.js +13 -26
  25. package/es/victory-primitives/whisker.js +43 -47
  26. package/es/victory-theme/grayscale.js +22 -22
  27. package/es/victory-theme/material.js +46 -46
  28. package/es/victory-theme/victory-theme.js +3 -3
  29. package/es/victory-transition/victory-transition.js +126 -206
  30. package/es/victory-util/add-events.js +263 -374
  31. package/es/victory-util/axis.js +126 -222
  32. package/es/victory-util/collection.js +13 -41
  33. package/es/victory-util/data.js +159 -214
  34. package/es/victory-util/default-transitions.js +33 -51
  35. package/es/victory-util/domain.js +122 -171
  36. package/es/victory-util/events.js +168 -258
  37. package/es/victory-util/helpers.js +153 -178
  38. package/es/victory-util/hooks/use-animation-state.js +61 -99
  39. package/es/victory-util/hooks/use-previous-props.js +2 -2
  40. package/es/victory-util/immutable.js +6 -8
  41. package/es/victory-util/label-helpers.js +128 -130
  42. package/es/victory-util/line-helpers.js +29 -41
  43. package/es/victory-util/log.js +1 -1
  44. package/es/victory-util/point-path-helpers.js +89 -49
  45. package/es/victory-util/scale.js +24 -42
  46. package/es/victory-util/selection.js +39 -40
  47. package/es/victory-util/style.js +8 -13
  48. package/es/victory-util/textsize.js +80 -154
  49. package/es/victory-util/timer-context.js +2 -2
  50. package/es/victory-util/timer.js +40 -76
  51. package/es/victory-util/transitions.js +110 -150
  52. package/es/victory-util/type-helpers.js +2 -3
  53. package/es/victory-util/user-props.js +24 -49
  54. package/es/victory-util/wrapper.js +184 -247
  55. package/lib/index.js +0 -30
  56. package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
  57. package/lib/victory-animation/util.js +28 -63
  58. package/lib/victory-animation/victory-animation.js +54 -83
  59. package/lib/victory-clip-container/victory-clip-container.js +156 -243
  60. package/lib/victory-container/victory-container.js +160 -232
  61. package/lib/victory-label/victory-label.js +248 -344
  62. package/lib/victory-portal/portal-context.js +1 -6
  63. package/lib/victory-portal/portal.js +31 -81
  64. package/lib/victory-portal/victory-portal.js +50 -116
  65. package/lib/victory-primitives/arc.js +48 -57
  66. package/lib/victory-primitives/background.js +16 -28
  67. package/lib/victory-primitives/border.js +22 -34
  68. package/lib/victory-primitives/circle.js +16 -36
  69. package/lib/victory-primitives/clip-path.js +3 -11
  70. package/lib/victory-primitives/index.js +0 -28
  71. package/lib/victory-primitives/line-segment.js +22 -34
  72. package/lib/victory-primitives/line.js +16 -36
  73. package/lib/victory-primitives/path.js +16 -36
  74. package/lib/victory-primitives/point.js +38 -52
  75. package/lib/victory-primitives/rect.js +16 -36
  76. package/lib/victory-primitives/text.js +15 -33
  77. package/lib/victory-primitives/tspan.js +13 -31
  78. package/lib/victory-primitives/whisker.js +45 -57
  79. package/lib/victory-theme/grayscale.js +23 -24
  80. package/lib/victory-theme/material.js +47 -48
  81. package/lib/victory-theme/victory-theme.js +2 -7
  82. package/lib/victory-transition/victory-transition.js +129 -224
  83. package/lib/victory-util/add-events.js +263 -380
  84. package/lib/victory-util/axis.js +128 -241
  85. package/lib/victory-util/collection.js +13 -50
  86. package/lib/victory-util/data.js +160 -239
  87. package/lib/victory-util/default-transitions.js +33 -54
  88. package/lib/victory-util/domain.js +123 -193
  89. package/lib/victory-util/events.js +167 -274
  90. package/lib/victory-util/helpers.js +156 -207
  91. package/lib/victory-util/hooks/index.js +0 -2
  92. package/lib/victory-util/hooks/use-animation-state.js +63 -113
  93. package/lib/victory-util/hooks/use-previous-props.js +2 -7
  94. package/lib/victory-util/immutable.js +6 -18
  95. package/lib/victory-util/index.js +2 -51
  96. package/lib/victory-util/label-helpers.js +130 -141
  97. package/lib/victory-util/line-helpers.js +31 -49
  98. package/lib/victory-util/log.js +1 -2
  99. package/lib/victory-util/point-path-helpers.js +91 -63
  100. package/lib/victory-util/scale.js +26 -57
  101. package/lib/victory-util/selection.js +41 -49
  102. package/lib/victory-util/style.js +8 -16
  103. package/lib/victory-util/textsize.js +80 -157
  104. package/lib/victory-util/timer-context.js +2 -8
  105. package/lib/victory-util/timer.js +40 -76
  106. package/lib/victory-util/transitions.js +110 -152
  107. package/lib/victory-util/type-helpers.js +2 -9
  108. package/lib/victory-util/user-props.js +25 -59
  109. package/lib/victory-util/wrapper.js +186 -281
  110. package/package.json +2 -2
@@ -1,54 +1,54 @@
1
1
  // *
2
2
  // * Colors
3
3
  // *
4
- var yellow200 = "#FFF59D";
5
- var deepOrange600 = "#F4511E";
6
- var lime300 = "#DCE775";
7
- var lightGreen500 = "#8BC34A";
8
- var teal700 = "#00796B";
9
- var cyan900 = "#006064";
10
- var colors = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
11
- var blueGrey50 = "#ECEFF1";
12
- var blueGrey300 = "#90A4AE";
13
- var blueGrey700 = "#455A64";
14
- var grey900 = "#212121"; // *
4
+ const yellow200 = "#FFF59D";
5
+ const deepOrange600 = "#F4511E";
6
+ const lime300 = "#DCE775";
7
+ const lightGreen500 = "#8BC34A";
8
+ const teal700 = "#00796B";
9
+ const cyan900 = "#006064";
10
+ const colors = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
11
+ const blueGrey50 = "#ECEFF1";
12
+ const blueGrey300 = "#90A4AE";
13
+ const blueGrey700 = "#455A64";
14
+ const grey900 = "#212121";
15
+ // *
15
16
  // * Typography
16
17
  // *
17
-
18
- var sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif";
19
- var letterSpacing = "normal";
20
- var fontSize = 12; // *
18
+ const sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif";
19
+ const letterSpacing = "normal";
20
+ const fontSize = 12;
21
+ // *
21
22
  // * Layout
22
23
  // *
23
-
24
- var padding = 8;
25
- var baseProps = {
24
+ const padding = 8;
25
+ const baseProps = {
26
26
  width: 350,
27
27
  height: 350,
28
28
  padding: 50
29
- }; // *
29
+ };
30
+ // *
30
31
  // * Labels
31
32
  // *
32
-
33
- var baseLabelStyles = {
33
+ const baseLabelStyles = {
34
34
  fontFamily: sansSerif,
35
- fontSize: fontSize,
36
- letterSpacing: letterSpacing,
37
- padding: padding,
35
+ fontSize,
36
+ letterSpacing,
37
+ padding,
38
38
  fill: blueGrey700,
39
39
  stroke: "transparent",
40
40
  strokeWidth: 0
41
41
  };
42
- var centeredLabelStyles = Object.assign({
42
+ const centeredLabelStyles = Object.assign({
43
43
  textAnchor: "middle"
44
- }, baseLabelStyles); // *
44
+ }, baseLabelStyles);
45
+ // *
45
46
  // * Strokes
46
47
  // *
47
-
48
- var strokeDasharray = "10, 5";
49
- var strokeLinecap = "round";
50
- var strokeLinejoin = "round";
51
- export var material = {
48
+ const strokeDasharray = "10, 5";
49
+ const strokeLinecap = "round";
50
+ const strokeLinejoin = "round";
51
+ export const material = {
52
52
  area: Object.assign({
53
53
  style: {
54
54
  data: {
@@ -63,19 +63,19 @@ export var material = {
63
63
  fill: "transparent",
64
64
  stroke: blueGrey300,
65
65
  strokeWidth: 2,
66
- strokeLinecap: strokeLinecap,
67
- strokeLinejoin: strokeLinejoin
66
+ strokeLinecap,
67
+ strokeLinejoin
68
68
  },
69
69
  axisLabel: Object.assign({}, centeredLabelStyles, {
70
- padding: padding,
70
+ padding,
71
71
  stroke: "transparent"
72
72
  }),
73
73
  grid: {
74
74
  fill: "none",
75
75
  stroke: blueGrey50,
76
- strokeDasharray: strokeDasharray,
77
- strokeLinecap: strokeLinecap,
78
- strokeLinejoin: strokeLinejoin,
76
+ strokeDasharray,
77
+ strokeLinecap,
78
+ strokeLinejoin,
79
79
  pointerEvents: "painted"
80
80
  },
81
81
  ticks: {
@@ -83,8 +83,8 @@ export var material = {
83
83
  size: 5,
84
84
  stroke: blueGrey300,
85
85
  strokeWidth: 1,
86
- strokeLinecap: strokeLinecap,
87
- strokeLinejoin: strokeLinejoin
86
+ strokeLinecap,
87
+ strokeLinejoin
88
88
  },
89
89
  tickLabels: Object.assign({}, baseLabelStyles, {
90
90
  fill: blueGrey700
@@ -104,7 +104,7 @@ export var material = {
104
104
  style: {
105
105
  data: {
106
106
  fill: blueGrey700,
107
- padding: padding,
107
+ padding,
108
108
  strokeWidth: 0
109
109
  },
110
110
  labels: baseLabelStyles
@@ -113,7 +113,7 @@ export var material = {
113
113
  boxplot: Object.assign({
114
114
  style: {
115
115
  max: {
116
- padding: padding,
116
+ padding,
117
117
  stroke: blueGrey700,
118
118
  strokeWidth: 1
119
119
  },
@@ -121,7 +121,7 @@ export var material = {
121
121
  padding: 3
122
122
  }),
123
123
  median: {
124
- padding: padding,
124
+ padding,
125
125
  stroke: blueGrey700,
126
126
  strokeWidth: 1
127
127
  },
@@ -129,7 +129,7 @@ export var material = {
129
129
  padding: 3
130
130
  }),
131
131
  min: {
132
- padding: padding,
132
+ padding,
133
133
  stroke: blueGrey700,
134
134
  strokeWidth: 1
135
135
  },
@@ -137,14 +137,14 @@ export var material = {
137
137
  padding: 3
138
138
  }),
139
139
  q1: {
140
- padding: padding,
140
+ padding,
141
141
  fill: blueGrey700
142
142
  },
143
143
  q1Labels: Object.assign({}, baseLabelStyles, {
144
144
  padding: 3
145
145
  }),
146
146
  q3: {
147
- padding: padding,
147
+ padding,
148
148
  fill: blueGrey700
149
149
  },
150
150
  q3Labels: Object.assign({}, baseLabelStyles, {
@@ -223,7 +223,7 @@ export var material = {
223
223
  colorScale: colors,
224
224
  style: {
225
225
  data: {
226
- padding: padding,
226
+ padding,
227
227
  stroke: blueGrey50,
228
228
  strokeWidth: 1
229
229
  },
@@ -1,7 +1,7 @@
1
1
  import { grayscale } from "./grayscale";
2
2
  import { material } from "./material";
3
3
  export * from "./types";
4
- export var VictoryTheme = {
5
- grayscale: grayscale,
6
- material: material
4
+ export const VictoryTheme = {
5
+ grayscale,
6
+ material
7
7
  };
@@ -1,28 +1,6 @@
1
1
  import _pick from "lodash/pick";
2
2
  import _defaults from "lodash/defaults";
3
-
4
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
-
6
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
-
8
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9
-
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
-
12
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
13
-
14
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
-
16
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
-
18
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
19
-
20
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
-
22
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
23
-
24
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
-
26
4
  import React from "react";
27
5
  import { VictoryAnimation } from "../victory-animation/victory-animation";
28
6
  import * as Collection from "../victory-util/collection";
@@ -30,201 +8,143 @@ import * as Helpers from "../victory-util/helpers";
30
8
  import TimerContext from "../victory-util/timer-context";
31
9
  import * as Transitions from "../victory-util/transitions";
32
10
  import isEqual from "react-fast-compare";
33
- export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
34
- _inherits(VictoryTransition, _React$Component);
35
-
36
- var _super = _createSuper(VictoryTransition);
37
-
38
- function VictoryTransition(props, context) {
39
- var _this;
40
-
41
- _classCallCheck(this, VictoryTransition);
42
-
43
- _this = _super.call(this, props, context);
44
- _this.continuous = void 0;
45
- _this.timer = void 0;
46
- _this.transitionProps = void 0;
47
- _this.state = {
11
+ export class VictoryTransition extends React.Component {
12
+ static displayName = "VictoryTransition";
13
+ static contextType = TimerContext;
14
+ constructor(props, context) {
15
+ super(props, context);
16
+ this.state = {
48
17
  nodesShouldLoad: false,
49
18
  nodesDoneLoad: false
50
19
  };
51
- var child = _this.props.children;
52
- var polar = child.props.polar;
53
- _this.continuous = !polar && child.type && child.type.continuous === true;
54
- _this.timer = _this.context.transitionTimer;
55
- return _this;
20
+ const child = this.props.children;
21
+ const polar = child.props.polar;
22
+ this.continuous = !polar && child.type && child.type.continuous === true;
23
+ this.timer = this.context.transitionTimer;
56
24
  }
57
-
58
- _createClass(VictoryTransition, [{
59
- key: "componentDidMount",
60
- value: function componentDidMount() {
61
- this.setState({
62
- nodesShouldLoad: true
63
- }); // eslint-disable-line react/no-did-mount-set-state
64
- }
65
- }, {
66
- key: "shouldComponentUpdate",
67
- value: function shouldComponentUpdate(nextProps) {
68
- var _this2 = this;
69
-
70
- if (!isEqual(this.props, nextProps)) {
71
- this.timer.bypassAnimation();
72
- this.setState(this.getTransitionState(this.props, nextProps), function () {
73
- return _this2.timer.resumeAnimation();
74
- });
75
- }
76
-
77
- return true;
78
- }
79
- }, {
80
- key: "componentWillUnmount",
81
- value: function componentWillUnmount() {
82
- this.timer.stop();
25
+ componentDidMount() {
26
+ this.setState({
27
+ nodesShouldLoad: true
28
+ }); // eslint-disable-line react/no-did-mount-set-state
29
+ }
30
+ shouldComponentUpdate(nextProps) {
31
+ if (!isEqual(this.props, nextProps)) {
32
+ this.timer.bypassAnimation();
33
+ this.setState(this.getTransitionState(this.props, nextProps), () => this.timer.resumeAnimation());
83
34
  }
84
- }, {
85
- key: "getTransitionState",
86
- value: function getTransitionState(props, nextProps) {
87
- var animate = props.animate;
88
-
89
- if (!animate) {
90
- return {};
91
- } else if (animate.parentState) {
92
- var state = animate.parentState;
93
- var oldProps = state.nodesWillExit ? props : null;
94
- return {
95
- oldProps: oldProps,
96
- nextProps: nextProps
97
- };
98
- }
99
-
100
- var oldChildren = React.Children.toArray(props.children);
101
- var nextChildren = React.Children.toArray(nextProps.children);
102
-
103
- var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
104
- nodesWillExit = _Transitions$getIniti.nodesWillExit,
105
- nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
106
- childrenTransitions = _Transitions$getIniti.childrenTransitions,
107
- nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
108
-
35
+ return true;
36
+ }
37
+ componentWillUnmount() {
38
+ this.timer.stop();
39
+ }
40
+ getTransitionState(props, nextProps) {
41
+ const {
42
+ animate
43
+ } = props;
44
+ if (!animate) {
45
+ return {};
46
+ } else if (animate.parentState) {
47
+ const state = animate.parentState;
48
+ const oldProps = state.nodesWillExit ? props : null;
109
49
  return {
110
- nodesWillExit: nodesWillExit,
111
- nodesWillEnter: nodesWillEnter,
112
- childrenTransitions: childrenTransitions,
113
- nodesShouldEnter: nodesShouldEnter,
114
- oldProps: nodesWillExit ? props : null,
115
- nextProps: nextProps
50
+ oldProps,
51
+ nextProps
116
52
  };
117
53
  }
118
- }, {
119
- key: "getDomainFromChildren",
120
- value: function getDomainFromChildren(props, axis) {
121
- var getChildDomains = function (children) {
122
- return children.reduce(function (memo, child) {
123
- if (child.type && Helpers.isFunction(child.type.getDomain)) {
124
- var childDomain = child.props && child.type.getDomain(child.props, axis);
125
- return childDomain ? memo.concat(childDomain) : memo;
126
- } else if (child.props && child.props.children) {
127
- return memo.concat(getChildDomains(React.Children.toArray(child.props.children)));
128
- }
129
-
130
- return memo;
131
- }, []);
132
- };
133
-
134
- var child = React.Children.toArray(props.children)[0];
135
- var childProps = child.props || {};
136
- var domain = Array.isArray(childProps.domain) ? childProps.domain : childProps.domain && childProps.domain[axis];
137
-
138
- if (!childProps.children && domain) {
139
- return domain;
140
- }
141
-
142
- var childDomains = getChildDomains([child]);
143
- return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
144
- }
145
- }, {
146
- key: "pickProps",
147
- value: function pickProps() {
148
- if (!this.state) {
149
- return this.props;
150
- }
151
-
152
- return this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
54
+ const oldChildren = React.Children.toArray(props.children);
55
+ const nextChildren = React.Children.toArray(nextProps.children);
56
+ const {
57
+ nodesWillExit,
58
+ nodesWillEnter,
59
+ childrenTransitions,
60
+ nodesShouldEnter
61
+ } = Transitions.getInitialTransitionState(oldChildren, nextChildren);
62
+ return {
63
+ nodesWillExit,
64
+ nodesWillEnter,
65
+ childrenTransitions,
66
+ nodesShouldEnter,
67
+ oldProps: nodesWillExit ? props : null,
68
+ nextProps
69
+ };
70
+ }
71
+ getDomainFromChildren(props, axis) {
72
+ const getChildDomains = children => {
73
+ return children.reduce((memo, child) => {
74
+ if (child.type && Helpers.isFunction(child.type.getDomain)) {
75
+ const childDomain = child.props && child.type.getDomain(child.props, axis);
76
+ return childDomain ? memo.concat(childDomain) : memo;
77
+ } else if (child.props && child.props.children) {
78
+ return memo.concat(getChildDomains(React.Children.toArray(child.props.children)));
79
+ }
80
+ return memo;
81
+ }, []);
82
+ };
83
+ const child = React.Children.toArray(props.children)[0];
84
+ const childProps = child.props || {};
85
+ const domain = Array.isArray(childProps.domain) ? childProps.domain : childProps.domain && childProps.domain[axis];
86
+ if (!childProps.children && domain) {
87
+ return domain;
153
88
  }
154
- }, {
155
- key: "pickDomainProps",
156
- value: function pickDomainProps(props) {
157
- var _props$animate;
158
-
159
- var parentState = (_props$animate = props.animate) === null || _props$animate === void 0 ? void 0 : _props$animate.parentState;
160
-
161
- if (parentState && parentState.nodesWillExit) {
162
- return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
163
- }
164
-
165
- return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
89
+ const childDomains = getChildDomains([child]);
90
+ return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
91
+ }
92
+ pickProps() {
93
+ if (!this.state) {
94
+ return this.props;
166
95
  }
167
- }, {
168
- key: "getClipWidth",
169
- value: function getClipWidth(props, child) {
170
- var getDefaultClipWidth = function () {
171
- var range = Helpers.getRange(child.props, "x");
172
- return range ? Math.abs(range[1] - range[0]) : props.width;
173
- };
174
-
175
- var clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
176
- return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
96
+ return this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
97
+ }
98
+ pickDomainProps(props) {
99
+ const parentState = props.animate?.parentState;
100
+ if (parentState && parentState.nodesWillExit) {
101
+ return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
177
102
  }
178
- }, {
179
- key: "render",
180
- value: function render() {
181
- var _this$props$animate,
182
- _this3 = this;
183
-
184
- var props = this.pickProps();
185
- var getTransitionProps = (_this$props$animate = this.props.animate) !== null && _this$props$animate !== void 0 && _this$props$animate.getTransitions ? this.props.animate.getTransitions : Transitions.getTransitionPropsFactory(props, this.state, function (newState) {
186
- return _this3.setState(newState);
187
- });
188
- var child = React.Children.toArray(props.children)[0];
189
- var transitionProps = getTransitionProps(child);
190
- this.transitionProps = transitionProps;
191
- var domain = {
192
- x: this.getDomainFromChildren(this.pickDomainProps(props), "x"),
193
- y: this.getDomainFromChildren(props, "y")
194
- };
195
- var clipWidth = this.getClipWidth(props, child);
196
-
197
- var combinedProps = _defaults({
198
- domain: domain,
199
- clipWidth: clipWidth
200
- }, transitionProps, child.props);
201
-
202
- var animationWhitelist = props.animationWhitelist || [];
203
- var whitelist = animationWhitelist.concat(["clipWidth"]);
204
- var propsToAnimate = whitelist.length ? _pick(combinedProps, whitelist) : combinedProps;
205
- return /*#__PURE__*/React.createElement(VictoryAnimation, _extends({}, combinedProps.animate, {
206
- data: propsToAnimate
207
- }), function (newProps) {
208
- if (child.props.groupComponent) {
209
- var groupComponent = _this3.continuous ? /*#__PURE__*/React.cloneElement(child.props.groupComponent, {
210
- clipWidth: newProps.clipWidth || 0
211
- }) : child.props.groupComponent;
212
- return /*#__PURE__*/React.cloneElement(child, _defaults({
213
- animate: null,
214
- animating: true,
215
- groupComponent: groupComponent
216
- }, newProps, combinedProps));
217
- }
218
-
103
+ return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
104
+ }
105
+ getClipWidth(props, child) {
106
+ const getDefaultClipWidth = () => {
107
+ const range = Helpers.getRange(child.props, "x");
108
+ return range ? Math.abs(range[1] - range[0]) : props.width;
109
+ };
110
+ const clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
111
+ return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
112
+ }
113
+ render() {
114
+ const props = this.pickProps();
115
+ const getTransitionProps = this.props.animate?.getTransitions ? this.props.animate.getTransitions : Transitions.getTransitionPropsFactory(props, this.state, newState => this.setState(newState));
116
+ const child = React.Children.toArray(props.children)[0];
117
+ const transitionProps = getTransitionProps(child);
118
+ this.transitionProps = transitionProps;
119
+ const domain = {
120
+ x: this.getDomainFromChildren(this.pickDomainProps(props), "x"),
121
+ y: this.getDomainFromChildren(props, "y")
122
+ };
123
+ const clipWidth = this.getClipWidth(props, child);
124
+ const combinedProps = _defaults({
125
+ domain,
126
+ clipWidth
127
+ }, transitionProps, child.props);
128
+ const animationWhitelist = props.animationWhitelist || [];
129
+ const whitelist = animationWhitelist.concat(["clipWidth"]);
130
+ const propsToAnimate = whitelist.length ? _pick(combinedProps, whitelist) : combinedProps;
131
+ return /*#__PURE__*/React.createElement(VictoryAnimation, _extends({}, combinedProps.animate, {
132
+ data: propsToAnimate
133
+ }), newProps => {
134
+ if (child.props.groupComponent) {
135
+ const groupComponent = this.continuous ? /*#__PURE__*/React.cloneElement(child.props.groupComponent, {
136
+ clipWidth: newProps.clipWidth || 0
137
+ }) : child.props.groupComponent;
219
138
  return /*#__PURE__*/React.cloneElement(child, _defaults({
220
139
  animate: null,
221
- animating: true
140
+ animating: true,
141
+ groupComponent
222
142
  }, newProps, combinedProps));
223
- });
224
- }
225
- }]);
226
-
227
- return VictoryTransition;
228
- }(React.Component);
229
- VictoryTransition.displayName = "VictoryTransition";
230
- VictoryTransition.contextType = TimerContext;
143
+ }
144
+ return /*#__PURE__*/React.cloneElement(child, _defaults({
145
+ animate: null,
146
+ animating: true
147
+ }, newProps, combinedProps));
148
+ });
149
+ }
150
+ }