victory-chart 35.11.3 → 36.2.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.
@@ -6,21 +6,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  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; }
8
8
 
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- 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); } }
12
-
13
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
-
17
- 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, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
18
-
19
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
-
21
9
  import PropTypes from "prop-types";
22
10
  import React from "react";
23
- import { Background, Helpers, VictoryContainer, VictoryTheme, CommonProps, PropTypes as CustomPropTypes, Wrapper } from "victory-core";
11
+ import { Background, Helpers, VictoryContainer, VictoryTheme, CommonProps, PropTypes as CustomPropTypes, Wrapper, Hooks } from "victory-core";
24
12
  import { VictorySharedEvents } from "victory-shared-events";
25
13
  import { VictoryAxis } from "victory-axis";
26
14
  import { VictoryPolarAxis } from "victory-polar-axis";
@@ -32,85 +20,58 @@ var fallbackProps = {
32
20
  padding: 50
33
21
  };
34
22
 
35
- var VictoryChart =
36
- /*#__PURE__*/
37
- function (_React$Component) {
38
- _inherits(VictoryChart, _React$Component);
39
-
40
- function VictoryChart(props) {
41
- var _this;
42
-
43
- _classCallCheck(this, VictoryChart);
44
-
45
- _this = _possibleConstructorReturn(this, (VictoryChart.__proto__ || Object.getPrototypeOf(VictoryChart)).call(this, props));
46
- _this.state = {};
47
-
48
- if (props.animate) {
49
- _this.state = {
50
- nodesShouldLoad: false,
51
- nodesDoneLoad: false,
52
- animating: true
53
- };
54
- _this.setAnimationState = Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
55
- }
56
-
57
- return _this;
58
- }
59
-
60
- _createClass(VictoryChart, [{
61
- key: "shouldComponentUpdate",
62
- value: function shouldComponentUpdate(nextProps) {
63
- if (this.props.animate) {
64
- if (!isEqual(this.props, nextProps)) {
65
- this.setAnimationState(this.props, nextProps);
66
- return false;
67
- }
68
- }
69
-
70
- return true;
23
+ var VictoryChart = function (initialProps) {
24
+ var role = "chart";
25
+
26
+ var _Hooks$useAnimationSt = Hooks.useAnimationState(),
27
+ getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
28
+ setAnimationState = _Hooks$useAnimationSt.setAnimationState,
29
+ getProps = _Hooks$useAnimationSt.getProps;
30
+
31
+ var props = getProps(initialProps);
32
+ var modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
33
+ var eventKey = modifiedProps.eventKey,
34
+ containerComponent = modifiedProps.containerComponent,
35
+ standalone = modifiedProps.standalone,
36
+ groupComponent = modifiedProps.groupComponent,
37
+ externalEventMutations = modifiedProps.externalEventMutations,
38
+ width = modifiedProps.width,
39
+ height = modifiedProps.height,
40
+ theme = modifiedProps.theme,
41
+ polar = modifiedProps.polar,
42
+ name = modifiedProps.name;
43
+ var axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
44
+ var childComponents = React.useMemo(function () {
45
+ return getChildComponents(modifiedProps, axes);
46
+ }, [modifiedProps, axes]);
47
+ var calculatedProps = React.useMemo(function () {
48
+ return getCalculatedProps(modifiedProps, childComponents);
49
+ }, [modifiedProps, childComponents]);
50
+ var domain = calculatedProps.domain,
51
+ scale = calculatedProps.scale,
52
+ style = calculatedProps.style,
53
+ origin = calculatedProps.origin,
54
+ radius = calculatedProps.radius,
55
+ horizontal = calculatedProps.horizontal;
56
+ var newChildren = React.useMemo(function () {
57
+ var children = getChildren(props, childComponents, calculatedProps);
58
+ var mappedChildren = children.map(function (child, index) {
59
+ var childProps = _assign({
60
+ animate: getAnimationProps(props, child, index, "victory chart")
61
+ }, child.props);
62
+
63
+ return React.cloneElement(child, childProps);
64
+ });
65
+
66
+ if (props.style && props.style.background) {
67
+ var backgroundComponent = getBackgroundWithProps(props, calculatedProps);
68
+ mappedChildren.unshift(backgroundComponent);
71
69
  }
72
- }, {
73
- key: "getNewChildren",
74
- value: function getNewChildren(props, childComponents, calculatedProps) {
75
- var children = getChildren(props, childComponents, calculatedProps);
76
- var getAnimationProps = Wrapper.getAnimationProps.bind(this);
77
- var newChildren = children.map(function (child, index) {
78
- var childProps = _assign({
79
- animate: getAnimationProps(props, child, index)
80
- }, child.props);
81
70
 
82
- return React.cloneElement(child, childProps);
83
- });
84
-
85
- if (props.style && props.style.background) {
86
- var backgroundComponent = getBackgroundWithProps(props, calculatedProps);
87
- newChildren.unshift(backgroundComponent);
88
- }
89
-
90
- return newChildren;
91
- }
92
- }, {
93
- key: "renderContainer",
94
- value: function renderContainer(containerComponent, props) {
95
- var containerProps = _defaults({}, containerComponent.props, props);
96
-
97
- return React.cloneElement(containerComponent, containerProps);
98
- }
99
- }, {
100
- key: "getContainerProps",
101
- value: function getContainerProps(props, calculatedProps) {
102
- var width = props.width,
103
- height = props.height,
104
- standalone = props.standalone,
105
- theme = props.theme,
106
- polar = props.polar,
107
- name = props.name;
108
- var domain = calculatedProps.domain,
109
- scale = calculatedProps.scale,
110
- style = calculatedProps.style,
111
- origin = calculatedProps.origin,
112
- radius = calculatedProps.radius,
113
- horizontal = calculatedProps.horizontal;
71
+ return mappedChildren;
72
+ }, [getAnimationProps, childComponents, props, calculatedProps]);
73
+ var containerProps = React.useMemo(function () {
74
+ if (standalone) {
114
75
  return {
115
76
  domain: domain,
116
77
  scale: scale,
@@ -126,95 +87,79 @@ function (_React$Component) {
126
87
  origin: polar ? origin : undefined
127
88
  };
128
89
  }
129
- }, {
130
- key: "render",
131
- value: function render() {
132
- var props = this.state && this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
133
- var modifiedProps = Helpers.modifyProps(props, fallbackProps, "chart");
134
- var eventKey = modifiedProps.eventKey,
135
- containerComponent = modifiedProps.containerComponent,
136
- groupComponent = modifiedProps.groupComponent,
137
- standalone = modifiedProps.standalone,
138
- externalEventMutations = modifiedProps.externalEventMutations;
139
- var axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
140
- var childComponents = getChildComponents(modifiedProps, axes);
141
- var calculatedProps = getCalculatedProps(modifiedProps, childComponents);
142
- var newChildren = this.getNewChildren(modifiedProps, childComponents, calculatedProps);
143
- var containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
144
- var container = standalone ? this.renderContainer(containerComponent, containerProps) : groupComponent;
145
- var events = Wrapper.getAllEvents(props);
146
90
 
147
- if (!_isEmpty(events)) {
148
- return React.createElement(VictorySharedEvents, {
149
- container: container,
150
- eventKey: eventKey,
151
- events: events,
152
- externalEventMutations: externalEventMutations
153
- }, newChildren);
154
- }
91
+ return {};
92
+ }, [domain, scale, width, height, standalone, theme, style, horizontal, name, polar, radius, origin]);
93
+ var container = React.useMemo(function () {
94
+ if (standalone) {
95
+ var defaultContainerProps = _defaults({}, containerComponent.props, containerProps);
155
96
 
156
- return React.cloneElement(container, container.props, newChildren);
97
+ return React.cloneElement(containerComponent, defaultContainerProps);
157
98
  }
158
- }]);
159
-
160
- return VictoryChart;
161
- }(React.Component);
162
99
 
163
- Object.defineProperty(VictoryChart, "displayName", {
164
- configurable: true,
165
- enumerable: true,
166
- writable: true,
167
- value: "VictoryChart"
168
- });
169
- Object.defineProperty(VictoryChart, "propTypes", {
170
- configurable: true,
171
- enumerable: true,
172
- writable: true,
173
- value: _objectSpread({}, CommonProps.baseProps, {
174
- backgroundComponent: PropTypes.element,
175
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
176
- defaultAxes: PropTypes.shape({
177
- independent: PropTypes.element,
178
- dependent: PropTypes.element
179
- }),
180
- defaultPolarAxes: PropTypes.shape({
181
- independent: PropTypes.element,
182
- dependent: PropTypes.element
183
- }),
184
- endAngle: PropTypes.number,
185
- innerRadius: CustomPropTypes.nonNegative,
186
- prependDefaultAxes: PropTypes.bool,
187
- startAngle: PropTypes.number
188
- })
189
- });
190
- Object.defineProperty(VictoryChart, "defaultProps", {
191
- configurable: true,
192
- enumerable: true,
193
- writable: true,
194
- value: {
195
- backgroundComponent: React.createElement(Background, null),
196
- containerComponent: React.createElement(VictoryContainer, null),
197
- defaultAxes: {
198
- independent: React.createElement(VictoryAxis, null),
199
- dependent: React.createElement(VictoryAxis, {
200
- dependentAxis: true
201
- })
202
- },
203
- defaultPolarAxes: {
204
- independent: React.createElement(VictoryPolarAxis, null),
205
- dependent: React.createElement(VictoryPolarAxis, {
206
- dependentAxis: true
207
- })
208
- },
209
- groupComponent: React.createElement("g", null),
210
- standalone: true,
211
- theme: VictoryTheme.grayscale
100
+ return groupComponent;
101
+ }, [groupComponent, standalone, containerComponent, containerProps]);
102
+ var events = React.useMemo(function () {
103
+ return Wrapper.getAllEvents(props);
104
+ }, [props]);
105
+ var previousProps = Hooks.usePreviousProps(initialProps);
106
+ React.useEffect(function () {
107
+ // This is called before dismount to keep state in sync
108
+ return function () {
109
+ if (initialProps.animate) {
110
+ setAnimationState(previousProps, initialProps);
111
+ }
112
+ };
113
+ }, [setAnimationState, previousProps, initialProps]);
114
+
115
+ if (!_isEmpty(events)) {
116
+ return React.createElement(VictorySharedEvents, {
117
+ container: container,
118
+ eventKey: eventKey,
119
+ events: events,
120
+ externalEventMutations: externalEventMutations
121
+ }, newChildren);
212
122
  }
123
+
124
+ return React.cloneElement(container, container.props, newChildren);
125
+ };
126
+
127
+ VictoryChart.propTypes = _objectSpread({}, CommonProps.baseProps, {
128
+ backgroundComponent: PropTypes.element,
129
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
130
+ defaultAxes: PropTypes.shape({
131
+ independent: PropTypes.element,
132
+ dependent: PropTypes.element
133
+ }),
134
+ defaultPolarAxes: PropTypes.shape({
135
+ independent: PropTypes.element,
136
+ dependent: PropTypes.element
137
+ }),
138
+ endAngle: PropTypes.number,
139
+ innerRadius: CustomPropTypes.nonNegative,
140
+ prependDefaultAxes: PropTypes.bool,
141
+ startAngle: PropTypes.number
213
142
  });
214
- Object.defineProperty(VictoryChart, "expectedComponents", {
215
- configurable: true,
216
- enumerable: true,
217
- writable: true,
218
- value: ["groupComponent", "containerComponent"]
219
- });
220
- export { VictoryChart as default };
143
+ VictoryChart.defaultProps = {
144
+ backgroundComponent: React.createElement(Background, null),
145
+ containerComponent: React.createElement(VictoryContainer, null),
146
+ defaultAxes: {
147
+ independent: React.createElement(VictoryAxis, null),
148
+ dependent: React.createElement(VictoryAxis, {
149
+ dependentAxis: true
150
+ })
151
+ },
152
+ defaultPolarAxes: {
153
+ independent: React.createElement(VictoryPolarAxis, null),
154
+ dependent: React.createElement(VictoryPolarAxis, {
155
+ dependentAxis: true
156
+ })
157
+ },
158
+ groupComponent: React.createElement("g", null),
159
+ standalone: true,
160
+ theme: VictoryTheme.grayscale
161
+ };
162
+ var VictoryChartMemo = React.memo(VictoryChart, isEqual);
163
+ VictoryChartMemo.displayName = "VictoryChart";
164
+ VictoryChartMemo.expectedComponents = ["groupComponent", "containerComponent"];
165
+ export default VictoryChartMemo;
@@ -33,103 +33,70 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
33
33
 
34
34
  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; }
35
35
 
36
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
-
38
- 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); } }
39
-
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
-
42
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
-
44
- 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, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
45
-
46
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
-
48
36
  var fallbackProps = {
49
37
  width: 450,
50
38
  height: 300,
51
39
  padding: 50
52
40
  };
53
41
 
54
- var VictoryChart =
55
- /*#__PURE__*/
56
- function (_React$Component) {
57
- _inherits(VictoryChart, _React$Component);
58
-
59
- function VictoryChart(props) {
60
- var _this;
61
-
62
- _classCallCheck(this, VictoryChart);
63
-
64
- _this = _possibleConstructorReturn(this, (VictoryChart.__proto__ || Object.getPrototypeOf(VictoryChart)).call(this, props));
65
- _this.state = {};
66
-
67
- if (props.animate) {
68
- _this.state = {
69
- nodesShouldLoad: false,
70
- nodesDoneLoad: false,
71
- animating: true
72
- };
73
- _this.setAnimationState = _victoryCore.Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
42
+ var VictoryChart = function (initialProps) {
43
+ var role = "chart";
44
+
45
+ var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
46
+ getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
47
+ setAnimationState = _Hooks$useAnimationSt.setAnimationState,
48
+ getProps = _Hooks$useAnimationSt.getProps;
49
+
50
+ var props = getProps(initialProps);
51
+
52
+ var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
53
+
54
+ var eventKey = modifiedProps.eventKey,
55
+ containerComponent = modifiedProps.containerComponent,
56
+ standalone = modifiedProps.standalone,
57
+ groupComponent = modifiedProps.groupComponent,
58
+ externalEventMutations = modifiedProps.externalEventMutations,
59
+ width = modifiedProps.width,
60
+ height = modifiedProps.height,
61
+ theme = modifiedProps.theme,
62
+ polar = modifiedProps.polar,
63
+ name = modifiedProps.name;
64
+ var axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
65
+
66
+ var childComponents = _react.default.useMemo(function () {
67
+ return (0, _helperMethods.getChildComponents)(modifiedProps, axes);
68
+ }, [modifiedProps, axes]);
69
+
70
+ var calculatedProps = _react.default.useMemo(function () {
71
+ return (0, _helperMethods.getCalculatedProps)(modifiedProps, childComponents);
72
+ }, [modifiedProps, childComponents]);
73
+
74
+ var domain = calculatedProps.domain,
75
+ scale = calculatedProps.scale,
76
+ style = calculatedProps.style,
77
+ origin = calculatedProps.origin,
78
+ radius = calculatedProps.radius,
79
+ horizontal = calculatedProps.horizontal;
80
+
81
+ var newChildren = _react.default.useMemo(function () {
82
+ var children = (0, _helperMethods.getChildren)(props, childComponents, calculatedProps);
83
+ var mappedChildren = children.map(function (child, index) {
84
+ var childProps = (0, _assign2.default)({
85
+ animate: getAnimationProps(props, child, index, "victory chart")
86
+ }, child.props);
87
+ return _react.default.cloneElement(child, childProps);
88
+ });
89
+
90
+ if (props.style && props.style.background) {
91
+ var backgroundComponent = (0, _helperMethods.getBackgroundWithProps)(props, calculatedProps);
92
+ mappedChildren.unshift(backgroundComponent);
74
93
  }
75
94
 
76
- return _this;
77
- }
78
-
79
- _createClass(VictoryChart, [{
80
- key: "shouldComponentUpdate",
81
- value: function shouldComponentUpdate(nextProps) {
82
- if (this.props.animate) {
83
- if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
84
- this.setAnimationState(this.props, nextProps);
85
- return false;
86
- }
87
- }
88
-
89
- return true;
90
- }
91
- }, {
92
- key: "getNewChildren",
93
- value: function getNewChildren(props, childComponents, calculatedProps) {
94
- var children = (0, _helperMethods.getChildren)(props, childComponents, calculatedProps);
95
-
96
- var getAnimationProps = _victoryCore.Wrapper.getAnimationProps.bind(this);
97
-
98
- var newChildren = children.map(function (child, index) {
99
- var childProps = (0, _assign2.default)({
100
- animate: getAnimationProps(props, child, index)
101
- }, child.props);
102
- return _react.default.cloneElement(child, childProps);
103
- });
104
-
105
- if (props.style && props.style.background) {
106
- var backgroundComponent = (0, _helperMethods.getBackgroundWithProps)(props, calculatedProps);
107
- newChildren.unshift(backgroundComponent);
108
- }
95
+ return mappedChildren;
96
+ }, [getAnimationProps, childComponents, props, calculatedProps]);
109
97
 
110
- return newChildren;
111
- }
112
- }, {
113
- key: "renderContainer",
114
- value: function renderContainer(containerComponent, props) {
115
- var containerProps = (0, _defaults2.default)({}, containerComponent.props, props);
116
- return _react.default.cloneElement(containerComponent, containerProps);
117
- }
118
- }, {
119
- key: "getContainerProps",
120
- value: function getContainerProps(props, calculatedProps) {
121
- var width = props.width,
122
- height = props.height,
123
- standalone = props.standalone,
124
- theme = props.theme,
125
- polar = props.polar,
126
- name = props.name;
127
- var domain = calculatedProps.domain,
128
- scale = calculatedProps.scale,
129
- style = calculatedProps.style,
130
- origin = calculatedProps.origin,
131
- radius = calculatedProps.radius,
132
- horizontal = calculatedProps.horizontal;
98
+ var containerProps = _react.default.useMemo(function () {
99
+ if (standalone) {
133
100
  return {
134
101
  domain: domain,
135
102
  scale: scale,
@@ -145,98 +112,85 @@ function (_React$Component) {
145
112
  origin: polar ? origin : undefined
146
113
  };
147
114
  }
148
- }, {
149
- key: "render",
150
- value: function render() {
151
- var props = this.state && this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
152
-
153
- var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, "chart");
154
-
155
- var eventKey = modifiedProps.eventKey,
156
- containerComponent = modifiedProps.containerComponent,
157
- groupComponent = modifiedProps.groupComponent,
158
- standalone = modifiedProps.standalone,
159
- externalEventMutations = modifiedProps.externalEventMutations;
160
- var axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
161
- var childComponents = (0, _helperMethods.getChildComponents)(modifiedProps, axes);
162
- var calculatedProps = (0, _helperMethods.getCalculatedProps)(modifiedProps, childComponents);
163
- var newChildren = this.getNewChildren(modifiedProps, childComponents, calculatedProps);
164
- var containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
165
- var container = standalone ? this.renderContainer(containerComponent, containerProps) : groupComponent;
166
-
167
- var events = _victoryCore.Wrapper.getAllEvents(props);
168
-
169
- if (!(0, _isEmpty2.default)(events)) {
170
- return _react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
171
- container: container,
172
- eventKey: eventKey,
173
- events: events,
174
- externalEventMutations: externalEventMutations
175
- }, newChildren);
176
- }
177
115
 
178
- return _react.default.cloneElement(container, container.props, newChildren);
116
+ return {};
117
+ }, [domain, scale, width, height, standalone, theme, style, horizontal, name, polar, radius, origin]);
118
+
119
+ var container = _react.default.useMemo(function () {
120
+ if (standalone) {
121
+ var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps);
122
+ return _react.default.cloneElement(containerComponent, defaultContainerProps);
179
123
  }
180
- }]);
181
124
 
182
- return VictoryChart;
183
- }(_react.default.Component);
125
+ return groupComponent;
126
+ }, [groupComponent, standalone, containerComponent, containerProps]);
184
127
 
185
- exports.default = VictoryChart;
186
- Object.defineProperty(VictoryChart, "displayName", {
187
- configurable: true,
188
- enumerable: true,
189
- writable: true,
190
- value: "VictoryChart"
191
- });
192
- Object.defineProperty(VictoryChart, "propTypes", {
193
- configurable: true,
194
- enumerable: true,
195
- writable: true,
196
- value: _objectSpread({}, _victoryCore.CommonProps.baseProps, {
197
- backgroundComponent: _propTypes.default.element,
198
- children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
199
- defaultAxes: _propTypes.default.shape({
200
- independent: _propTypes.default.element,
201
- dependent: _propTypes.default.element
202
- }),
203
- defaultPolarAxes: _propTypes.default.shape({
204
- independent: _propTypes.default.element,
205
- dependent: _propTypes.default.element
206
- }),
207
- endAngle: _propTypes.default.number,
208
- innerRadius: _victoryCore.PropTypes.nonNegative,
209
- prependDefaultAxes: _propTypes.default.bool,
210
- startAngle: _propTypes.default.number
211
- })
212
- });
213
- Object.defineProperty(VictoryChart, "defaultProps", {
214
- configurable: true,
215
- enumerable: true,
216
- writable: true,
217
- value: {
218
- backgroundComponent: _react.default.createElement(_victoryCore.Background, null),
219
- containerComponent: _react.default.createElement(_victoryCore.VictoryContainer, null),
220
- defaultAxes: {
221
- independent: _react.default.createElement(_victoryAxis.VictoryAxis, null),
222
- dependent: _react.default.createElement(_victoryAxis.VictoryAxis, {
223
- dependentAxis: true
224
- })
225
- },
226
- defaultPolarAxes: {
227
- independent: _react.default.createElement(_victoryPolarAxis.VictoryPolarAxis, null),
228
- dependent: _react.default.createElement(_victoryPolarAxis.VictoryPolarAxis, {
229
- dependentAxis: true
230
- })
231
- },
232
- groupComponent: _react.default.createElement("g", null),
233
- standalone: true,
234
- theme: _victoryCore.VictoryTheme.grayscale
128
+ var events = _react.default.useMemo(function () {
129
+ return _victoryCore.Wrapper.getAllEvents(props);
130
+ }, [props]);
131
+
132
+ var previousProps = _victoryCore.Hooks.usePreviousProps(initialProps);
133
+
134
+ _react.default.useEffect(function () {
135
+ // This is called before dismount to keep state in sync
136
+ return function () {
137
+ if (initialProps.animate) {
138
+ setAnimationState(previousProps, initialProps);
139
+ }
140
+ };
141
+ }, [setAnimationState, previousProps, initialProps]);
142
+
143
+ if (!(0, _isEmpty2.default)(events)) {
144
+ return _react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
145
+ container: container,
146
+ eventKey: eventKey,
147
+ events: events,
148
+ externalEventMutations: externalEventMutations
149
+ }, newChildren);
235
150
  }
151
+
152
+ return _react.default.cloneElement(container, container.props, newChildren);
153
+ };
154
+
155
+ VictoryChart.propTypes = _objectSpread({}, _victoryCore.CommonProps.baseProps, {
156
+ backgroundComponent: _propTypes.default.element,
157
+ children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
158
+ defaultAxes: _propTypes.default.shape({
159
+ independent: _propTypes.default.element,
160
+ dependent: _propTypes.default.element
161
+ }),
162
+ defaultPolarAxes: _propTypes.default.shape({
163
+ independent: _propTypes.default.element,
164
+ dependent: _propTypes.default.element
165
+ }),
166
+ endAngle: _propTypes.default.number,
167
+ innerRadius: _victoryCore.PropTypes.nonNegative,
168
+ prependDefaultAxes: _propTypes.default.bool,
169
+ startAngle: _propTypes.default.number
236
170
  });
237
- Object.defineProperty(VictoryChart, "expectedComponents", {
238
- configurable: true,
239
- enumerable: true,
240
- writable: true,
241
- value: ["groupComponent", "containerComponent"]
242
- });
171
+ VictoryChart.defaultProps = {
172
+ backgroundComponent: _react.default.createElement(_victoryCore.Background, null),
173
+ containerComponent: _react.default.createElement(_victoryCore.VictoryContainer, null),
174
+ defaultAxes: {
175
+ independent: _react.default.createElement(_victoryAxis.VictoryAxis, null),
176
+ dependent: _react.default.createElement(_victoryAxis.VictoryAxis, {
177
+ dependentAxis: true
178
+ })
179
+ },
180
+ defaultPolarAxes: {
181
+ independent: _react.default.createElement(_victoryPolarAxis.VictoryPolarAxis, null),
182
+ dependent: _react.default.createElement(_victoryPolarAxis.VictoryPolarAxis, {
183
+ dependentAxis: true
184
+ })
185
+ },
186
+ groupComponent: _react.default.createElement("g", null),
187
+ standalone: true,
188
+ theme: _victoryCore.VictoryTheme.grayscale
189
+ };
190
+
191
+ var VictoryChartMemo = _react.default.memo(VictoryChart, _reactFastCompare.default);
192
+
193
+ VictoryChartMemo.displayName = "VictoryChart";
194
+ VictoryChartMemo.expectedComponents = ["groupComponent", "containerComponent"];
195
+ var _default = VictoryChartMemo;
196
+ exports.default = _default;