victory-core 36.3.0 → 36.4.1

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 (102) hide show
  1. package/dist/victory-core.js +14792 -14613
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.js +2 -0
  4. package/es/victory-accessible-group/victory-accessible-group.js +38 -40
  5. package/es/victory-animation/util.js +1 -1
  6. package/es/victory-animation/victory-animation.js +46 -48
  7. package/es/victory-clip-container/victory-clip-container.js +74 -75
  8. package/es/victory-container/victory-container.js +86 -94
  9. package/es/victory-label/victory-label.js +32 -25
  10. package/es/victory-portal/portal-context.js +1 -1
  11. package/es/victory-portal/portal.js +28 -26
  12. package/es/victory-portal/victory-portal.js +31 -41
  13. package/es/victory-primitives/arc.js +6 -4
  14. package/es/victory-primitives/background.js +8 -6
  15. package/es/victory-primitives/border.js +6 -4
  16. package/es/victory-primitives/circle.js +8 -4
  17. package/es/victory-primitives/clip-path.js +1 -1
  18. package/es/victory-primitives/line-segment.js +6 -4
  19. package/es/victory-primitives/line.js +8 -4
  20. package/es/victory-primitives/path.js +7 -3
  21. package/es/victory-primitives/point.js +6 -4
  22. package/es/victory-primitives/rect.js +8 -4
  23. package/es/victory-primitives/text.js +7 -3
  24. package/es/victory-primitives/tspan.js +1 -1
  25. package/es/victory-primitives/whisker.js +9 -7
  26. package/es/victory-transition/victory-transition.js +30 -32
  27. package/es/victory-util/add-events.js +324 -315
  28. package/es/victory-util/axis.js +12 -5
  29. package/es/victory-util/collection.js +8 -4
  30. package/es/victory-util/common-props.js +2 -2
  31. package/es/victory-util/data.js +9 -5
  32. package/es/victory-util/domain.js +8 -4
  33. package/es/victory-util/events.js +8 -4
  34. package/es/victory-util/helpers.js +1 -1
  35. package/es/victory-util/hooks/use-animation-state.js +11 -5
  36. package/es/victory-util/line-helpers.js +1 -1
  37. package/es/victory-util/scale.js +19 -19
  38. package/es/victory-util/textsize.js +11 -7
  39. package/es/victory-util/timer-context.js +1 -1
  40. package/es/victory-util/timer.js +3 -5
  41. package/es/victory-util/user-props.js +123 -0
  42. package/es/victory-util/wrapper.js +18 -12
  43. package/lib/index.js +72 -58
  44. package/lib/victory-accessible-group/victory-accessible-group.js +38 -40
  45. package/lib/victory-animation/util.js +2 -2
  46. package/lib/victory-animation/victory-animation.js +49 -49
  47. package/lib/victory-clip-container/victory-clip-container.js +78 -76
  48. package/lib/victory-container/victory-container.js +90 -95
  49. package/lib/victory-label/victory-label.js +38 -27
  50. package/lib/victory-portal/portal-context.js +1 -1
  51. package/lib/victory-portal/portal.js +31 -27
  52. package/lib/victory-portal/victory-portal.js +34 -42
  53. package/lib/victory-primitives/arc.js +9 -5
  54. package/lib/victory-primitives/background.js +11 -7
  55. package/lib/victory-primitives/border.js +9 -5
  56. package/lib/victory-primitives/circle.js +8 -4
  57. package/lib/victory-primitives/clip-path.js +1 -1
  58. package/lib/victory-primitives/line-segment.js +9 -5
  59. package/lib/victory-primitives/line.js +8 -4
  60. package/lib/victory-primitives/path.js +7 -3
  61. package/lib/victory-primitives/point.js +9 -5
  62. package/lib/victory-primitives/rect.js +8 -4
  63. package/lib/victory-primitives/text.js +7 -3
  64. package/lib/victory-primitives/tspan.js +1 -1
  65. package/lib/victory-primitives/whisker.js +12 -8
  66. package/lib/victory-transition/victory-transition.js +33 -33
  67. package/lib/victory-util/add-events.js +322 -311
  68. package/lib/victory-util/axis.js +20 -11
  69. package/lib/victory-util/collection.js +11 -7
  70. package/lib/victory-util/common-props.js +6 -4
  71. package/lib/victory-util/data.js +13 -7
  72. package/lib/victory-util/default-transitions.js +1 -1
  73. package/lib/victory-util/domain.js +11 -5
  74. package/lib/victory-util/events.js +17 -11
  75. package/lib/victory-util/helpers.js +14 -14
  76. package/lib/victory-util/hooks/index.js +4 -4
  77. package/lib/victory-util/hooks/use-animation-state.js +14 -6
  78. package/lib/victory-util/immutable.js +3 -3
  79. package/lib/victory-util/label-helpers.js +6 -4
  80. package/lib/victory-util/line-helpers.js +4 -2
  81. package/lib/victory-util/prop-types.js +5 -3
  82. package/lib/victory-util/scale.js +24 -21
  83. package/lib/victory-util/selection.js +6 -4
  84. package/lib/victory-util/textsize.js +12 -8
  85. package/lib/victory-util/timer-context.js +1 -1
  86. package/lib/victory-util/timer.js +3 -5
  87. package/lib/victory-util/user-props.js +139 -0
  88. package/lib/victory-util/wrapper.js +31 -23
  89. package/package.json +5 -12
  90. package/src/index.js +1 -0
  91. package/src/victory-animation/util.js +1 -1
  92. package/src/victory-animation/victory-animation.js +1 -1
  93. package/src/victory-clip-container/victory-clip-container.js +3 -1
  94. package/src/victory-container/victory-container.js +7 -1
  95. package/src/victory-label/victory-label.js +11 -7
  96. package/src/victory-util/add-events.js +2 -1
  97. package/src/victory-util/axis.js +3 -0
  98. package/src/victory-util/common-props.js +2 -2
  99. package/src/victory-util/line-helpers.js +1 -1
  100. package/src/victory-util/scale.js +18 -9
  101. package/src/victory-util/timer.js +1 -1
  102. package/src/victory-util/user-props.js +94 -0
@@ -8,26 +8,38 @@ import _keys from "lodash/keys";
8
8
  import _assign from "lodash/assign";
9
9
  import _defaults from "lodash/defaults";
10
10
 
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
12
 
13
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
13
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
14
 
15
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
16
 
17
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
17
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
+
19
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
+
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
22
 
19
23
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
24
 
21
25
  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); } }
22
26
 
23
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
28
+
29
+ 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); }
24
30
 
25
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
31
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
26
32
 
27
- 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; }
33
+ 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); }; }
34
+
35
+ 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); }
28
36
 
29
37
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
38
 
39
+ 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; } }
40
+
41
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
+
31
43
  /*global window:false */
32
44
  import React from "react";
33
45
  import * as Events from "./events";
@@ -48,363 +60,360 @@ var defaultComponents = [{
48
60
  name: "labels"
49
61
  }];
50
62
  export default (function (WrappedComponent, options) {
51
- return (
52
- /*#__PURE__*/
53
- function (_WrappedComponent) {
54
- _inherits(addEvents, _WrappedComponent);
63
+ return /*#__PURE__*/function (_WrappedComponent) {
64
+ _inherits(addEvents, _WrappedComponent);
55
65
 
56
- function addEvents(props) {
57
- var _this;
66
+ var _super = _createSuper(addEvents);
58
67
 
59
- _classCallCheck(this, addEvents);
68
+ function addEvents(props) {
69
+ var _this;
60
70
 
61
- _this = _possibleConstructorReturn(this, (addEvents.__proto__ || Object.getPrototypeOf(addEvents)).call(this, props));
62
- var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
63
- var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
64
- _this.state = {};
71
+ _classCallCheck(this, addEvents);
65
72
 
66
- _this.getEvents = function (p, target, eventKey) {
67
- return boundGetEvents(p, target, eventKey, getScopedEvents);
68
- };
73
+ _this = _super.call(this, props);
74
+ var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
75
+ var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
76
+ _this.state = {};
69
77
 
70
- _this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
78
+ _this.getEvents = function (p, target, eventKey) {
79
+ return boundGetEvents(p, target, eventKey, getScopedEvents);
80
+ };
71
81
 
72
- var calculatedValues = _this.getCalculatedValues(props);
82
+ _this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
73
83
 
74
- _this.cacheValues(calculatedValues);
84
+ var calculatedValues = _this.getCalculatedValues(props);
75
85
 
76
- _this.externalMutations = _this.getExternalMutations(props);
77
- _this.calculatedState = _this.getStateChanges(props);
78
- _this.globalEvents = {};
79
- _this.prevGlobalEventKeys = [];
80
- _this.boundGlobalEvents = {};
81
- return _this;
82
- }
86
+ _this.cacheValues(calculatedValues);
83
87
 
84
- _createClass(addEvents, [{
85
- key: "shouldComponentUpdate",
86
- value: function shouldComponentUpdate(nextProps) {
87
- var externalMutations = this.getExternalMutations(nextProps);
88
- var animating = this.props.animating || this.props.animate;
89
- var newMutation = !isEqual(externalMutations, this.externalMutations);
90
-
91
- if (animating || newMutation) {
92
- this.cacheValues(this.getCalculatedValues(nextProps));
93
- this.externalMutations = externalMutations;
94
- this.applyExternalMutations(nextProps, externalMutations);
95
- return true;
96
- }
88
+ _this.externalMutations = _this.getExternalMutations(props);
89
+ _this.calculatedState = _this.getStateChanges(props);
90
+ _this.globalEvents = {};
91
+ _this.prevGlobalEventKeys = [];
92
+ _this.boundGlobalEvents = {};
93
+ return _this;
94
+ }
97
95
 
98
- var calculatedState = this.getStateChanges(nextProps);
96
+ _createClass(addEvents, [{
97
+ key: "shouldComponentUpdate",
98
+ value: function shouldComponentUpdate(nextProps) {
99
+ var externalMutations = this.getExternalMutations(nextProps);
100
+ var animating = this.props.animating || this.props.animate;
101
+ var newMutation = !isEqual(externalMutations, this.externalMutations);
99
102
 
100
- if (!isEqual(this.calculatedState, calculatedState)) {
101
- this.cacheValues(this.getCalculatedValues(nextProps));
102
- return true;
103
- }
103
+ if (animating || newMutation) {
104
+ this.cacheValues(this.getCalculatedValues(nextProps));
105
+ this.externalMutations = externalMutations;
106
+ this.applyExternalMutations(nextProps, externalMutations);
107
+ return true;
108
+ }
104
109
 
105
- if (!isEqual(this.props, nextProps)) {
106
- this.cacheValues(this.getCalculatedValues(nextProps));
107
- return true;
108
- }
110
+ var calculatedState = this.getStateChanges(nextProps);
109
111
 
110
- return false;
112
+ if (!isEqual(this.calculatedState, calculatedState)) {
113
+ this.cacheValues(this.getCalculatedValues(nextProps));
114
+ return true;
111
115
  }
112
- }, {
113
- key: "componentDidMount",
114
- value: function componentDidMount() {
115
- var _this2 = this;
116
-
117
- var globalEventKeys = _keys(this.globalEvents);
118
116
 
119
- globalEventKeys.forEach(function (key) {
120
- return _this2.addGlobalListener(key);
121
- });
122
- this.prevGlobalEventKeys = globalEventKeys;
117
+ if (!isEqual(this.props, nextProps)) {
118
+ this.cacheValues(this.getCalculatedValues(nextProps));
119
+ return true;
123
120
  }
124
- }, {
125
- key: "componentDidUpdate",
126
- value: function componentDidUpdate(prevProps) {
127
- var _this3 = this;
128
121
 
129
- var calculatedState = this.getStateChanges(prevProps);
130
- this.calculatedState = calculatedState;
122
+ return false;
123
+ }
124
+ }, {
125
+ key: "componentDidMount",
126
+ value: function componentDidMount() {
127
+ var _this2 = this;
131
128
 
132
- var globalEventKeys = _keys(this.globalEvents);
129
+ var globalEventKeys = _keys(this.globalEvents);
133
130
 
134
- var removedGlobalEventKeys = _difference(this.prevGlobalEventKeys, globalEventKeys);
131
+ globalEventKeys.forEach(function (key) {
132
+ return _this2.addGlobalListener(key);
133
+ });
134
+ this.prevGlobalEventKeys = globalEventKeys;
135
+ }
136
+ }, {
137
+ key: "componentDidUpdate",
138
+ value: function componentDidUpdate(prevProps) {
139
+ var _this3 = this;
135
140
 
136
- removedGlobalEventKeys.forEach(function (key) {
137
- return _this3.removeGlobalListener(key);
138
- });
141
+ var calculatedState = this.getStateChanges(prevProps);
142
+ this.calculatedState = calculatedState;
139
143
 
140
- var addedGlobalEventKeys = _difference(globalEventKeys, this.prevGlobalEventKeys);
144
+ var globalEventKeys = _keys(this.globalEvents);
141
145
 
142
- addedGlobalEventKeys.forEach(function (key) {
143
- return _this3.addGlobalListener(key);
144
- });
145
- this.prevGlobalEventKeys = globalEventKeys;
146
- }
147
- }, {
148
- key: "componentWillUnmount",
149
- value: function componentWillUnmount() {
150
- var _this4 = this;
146
+ var removedGlobalEventKeys = _difference(this.prevGlobalEventKeys, globalEventKeys);
151
147
 
152
- this.prevGlobalEventKeys.forEach(function (key) {
153
- return _this4.removeGlobalListener(key);
154
- });
155
- }
156
- }, {
157
- key: "addGlobalListener",
158
- value: function addGlobalListener(key) {
159
- var _this5 = this;
160
-
161
- var boundListener = function (event) {
162
- var listener = _this5.globalEvents[key];
163
- return listener && listener(Events.emulateReactEvent(event));
164
- };
165
-
166
- this.boundGlobalEvents[key] = boundListener;
167
- window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
168
- }
169
- }, {
170
- key: "removeGlobalListener",
171
- value: function removeGlobalListener(key) {
172
- window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
173
- } // compile all state changes from own and parent state. Order doesn't matter, as any state
174
- // state change should trigger a re-render
175
-
176
- }, {
177
- key: "getStateChanges",
178
- value: function getStateChanges(props) {
179
- var _this6 = this;
180
-
181
- if (!this.hasEvents) {
182
- return {};
183
- }
184
-
185
- var getState = function (key, type) {
186
- var result = _defaults({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
187
-
188
- return _isEmpty(result) ? undefined : result;
189
- };
190
-
191
- options = options || {};
192
- var components = options.components || defaultComponents;
193
- var stateChanges = components.map(function (component) {
194
- if (!props.standalone && component.name === "parent") {
195
- // don't check for changes on parent props for non-standalone components
196
- return undefined;
197
- } else {
198
- return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
199
- return getState(key, component.name);
200
- }).filter(Boolean);
201
- }
202
- }).filter(Boolean);
203
- return stateChanges;
204
- }
205
- }, {
206
- key: "applyExternalMutations",
207
- value: function applyExternalMutations(props, externalMutations) {
208
- if (!_isEmpty(externalMutations)) {
209
- var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
210
- memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo;
211
- return memo;
212
- }, []);
213
- var compiledCallbacks = callbacks.length ? function () {
214
- callbacks.forEach(function (c) {
215
- return c();
216
- });
217
- } : undefined;
218
- this.setState(externalMutations, compiledCallbacks);
219
- }
220
- }
221
- }, {
222
- key: "getCalculatedValues",
223
- value: function getCalculatedValues(props) {
224
- var sharedEvents = props.sharedEvents;
225
- var components = WrappedComponent.expectedComponents;
226
- var componentEvents = Events.getComponentEvents(props, components);
227
- var getSharedEventState = sharedEvents && _isFunction(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
228
- return undefined;
229
- };
230
- var baseProps = this.getBaseProps(props, getSharedEventState);
148
+ removedGlobalEventKeys.forEach(function (key) {
149
+ return _this3.removeGlobalListener(key);
150
+ });
231
151
 
232
- var dataKeys = _keys(baseProps).filter(function (key) {
233
- return key !== "parent";
234
- });
152
+ var addedGlobalEventKeys = _difference(globalEventKeys, this.prevGlobalEventKeys);
235
153
 
236
- var hasEvents = props.events || props.sharedEvents || componentEvents;
237
- var events = this.getAllEvents(props);
238
- return {
239
- componentEvents: componentEvents,
240
- getSharedEventState: getSharedEventState,
241
- baseProps: baseProps,
242
- dataKeys: dataKeys,
243
- hasEvents: hasEvents,
244
- events: events
245
- };
246
- }
247
- }, {
248
- key: "getExternalMutations",
249
- value: function getExternalMutations(props) {
250
- var sharedEvents = props.sharedEvents,
251
- externalEventMutations = props.externalEventMutations;
252
- return _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
253
- }
254
- }, {
255
- key: "cacheValues",
256
- value: function cacheValues(obj) {
257
- var _this7 = this;
154
+ addedGlobalEventKeys.forEach(function (key) {
155
+ return _this3.addGlobalListener(key);
156
+ });
157
+ this.prevGlobalEventKeys = globalEventKeys;
158
+ }
159
+ }, {
160
+ key: "componentWillUnmount",
161
+ value: function componentWillUnmount() {
162
+ var _this4 = this;
163
+
164
+ this.prevGlobalEventKeys.forEach(function (key) {
165
+ return _this4.removeGlobalListener(key);
166
+ });
167
+ }
168
+ }, {
169
+ key: "addGlobalListener",
170
+ value: function addGlobalListener(key) {
171
+ var _this5 = this;
172
+
173
+ var boundListener = function (event) {
174
+ var listener = _this5.globalEvents[key];
175
+ return listener && listener(Events.emulateReactEvent(event));
176
+ };
258
177
 
259
- _keys(obj).forEach(function (key) {
260
- _this7[key] = obj[key];
261
- });
178
+ this.boundGlobalEvents[key] = boundListener;
179
+ window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
180
+ }
181
+ }, {
182
+ key: "removeGlobalListener",
183
+ value: function removeGlobalListener(key) {
184
+ window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
185
+ } // compile all state changes from own and parent state. Order doesn't matter, as any state
186
+ // state change should trigger a re-render
187
+
188
+ }, {
189
+ key: "getStateChanges",
190
+ value: function getStateChanges(props) {
191
+ var _this6 = this;
192
+
193
+ if (!this.hasEvents) {
194
+ return {};
262
195
  }
263
- }, {
264
- key: "getBaseProps",
265
- value: function getBaseProps(props, getSharedEventState) {
266
- getSharedEventState = getSharedEventState || this.getSharedEventState;
267
- var sharedParentState = getSharedEventState("parent", "parent");
268
- var parentState = this.getEventState("parent", "parent");
269
-
270
- var baseParentProps = _defaults({}, parentState, sharedParentState);
271
196
 
272
- var parentPropsList = baseParentProps.parentControlledProps;
273
- var parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
197
+ var getState = function (key, type) {
198
+ var result = _defaults({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
274
199
 
275
- var modifiedProps = _defaults({}, parentProps, props);
200
+ return _isEmpty(result) ? undefined : result;
201
+ };
276
202
 
277
- return _isFunction(WrappedComponent.getBaseProps) ? WrappedComponent.getBaseProps(modifiedProps) : {};
203
+ options = options || {};
204
+ var components = options.components || defaultComponents;
205
+ var stateChanges = components.map(function (component) {
206
+ if (!props.standalone && component.name === "parent") {
207
+ // don't check for changes on parent props for non-standalone components
208
+ return undefined;
209
+ } else {
210
+ return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
211
+ return getState(key, component.name);
212
+ }).filter(Boolean);
213
+ }
214
+ }).filter(Boolean);
215
+ return stateChanges;
216
+ }
217
+ }, {
218
+ key: "applyExternalMutations",
219
+ value: function applyExternalMutations(props, externalMutations) {
220
+ if (!_isEmpty(externalMutations)) {
221
+ var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
222
+ memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo;
223
+ return memo;
224
+ }, []);
225
+ var compiledCallbacks = callbacks.length ? function () {
226
+ callbacks.forEach(function (c) {
227
+ return c();
228
+ });
229
+ } : undefined;
230
+ this.setState(externalMutations, compiledCallbacks);
278
231
  }
279
- }, {
280
- key: "getAllEvents",
281
- value: function getAllEvents(props) {
282
- if (Array.isArray(this.componentEvents)) {
283
- var _componentEvents;
232
+ }
233
+ }, {
234
+ key: "getCalculatedValues",
235
+ value: function getCalculatedValues(props) {
236
+ var sharedEvents = props.sharedEvents;
237
+ var components = WrappedComponent.expectedComponents;
238
+ var componentEvents = Events.getComponentEvents(props, components);
239
+ var getSharedEventState = sharedEvents && _isFunction(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
240
+ return undefined;
241
+ };
242
+ var baseProps = this.getBaseProps(props, getSharedEventState);
243
+
244
+ var dataKeys = _keys(baseProps).filter(function (key) {
245
+ return key !== "parent";
246
+ });
247
+
248
+ var hasEvents = props.events || props.sharedEvents || componentEvents;
249
+ var events = this.getAllEvents(props);
250
+ return {
251
+ componentEvents: componentEvents,
252
+ getSharedEventState: getSharedEventState,
253
+ baseProps: baseProps,
254
+ dataKeys: dataKeys,
255
+ hasEvents: hasEvents,
256
+ events: events
257
+ };
258
+ }
259
+ }, {
260
+ key: "getExternalMutations",
261
+ value: function getExternalMutations(props) {
262
+ var sharedEvents = props.sharedEvents,
263
+ externalEventMutations = props.externalEventMutations;
264
+ return _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
265
+ }
266
+ }, {
267
+ key: "cacheValues",
268
+ value: function cacheValues(obj) {
269
+ var _this7 = this;
270
+
271
+ _keys(obj).forEach(function (key) {
272
+ _this7[key] = obj[key];
273
+ });
274
+ }
275
+ }, {
276
+ key: "getBaseProps",
277
+ value: function getBaseProps(props, getSharedEventState) {
278
+ getSharedEventState = getSharedEventState || this.getSharedEventState;
279
+ var sharedParentState = getSharedEventState("parent", "parent");
280
+ var parentState = this.getEventState("parent", "parent");
284
281
 
285
- return Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
286
- }
282
+ var baseParentProps = _defaults({}, parentState, sharedParentState);
287
283
 
288
- return props.events;
289
- }
290
- }, {
291
- key: "getComponentProps",
292
- value: function getComponentProps(component, type, index) {
293
- var name = this.props.name || WrappedComponent.role;
294
- var key = this.dataKeys && this.dataKeys[index] || index;
295
- var id = "".concat(name, "-").concat(type, "-").concat(key);
296
- var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
297
-
298
- if (!baseProps && !this.hasEvents) {
299
- return undefined;
300
- }
284
+ var parentPropsList = baseParentProps.parentControlledProps;
285
+ var parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
301
286
 
302
- if (this.hasEvents) {
303
- var baseEvents = this.getEvents(this.props, type, key);
287
+ var modifiedProps = _defaults({}, parentProps, props);
304
288
 
305
- var componentProps = _defaults({
306
- index: index,
307
- key: id
308
- }, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
309
- id: id
310
- });
289
+ return _isFunction(WrappedComponent.getBaseProps) ? WrappedComponent.getBaseProps(modifiedProps) : {};
290
+ }
291
+ }, {
292
+ key: "getAllEvents",
293
+ value: function getAllEvents(props) {
294
+ if (Array.isArray(this.componentEvents)) {
295
+ var _this$componentEvents;
311
296
 
312
- var events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
297
+ return Array.isArray(props.events) ? (_this$componentEvents = this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
298
+ }
313
299
 
314
- return _assign({}, componentProps, {
315
- events: events
316
- });
317
- }
300
+ return props.events;
301
+ }
302
+ }, {
303
+ key: "getComponentProps",
304
+ value: function getComponentProps(component, type, index) {
305
+ var name = this.props.name || WrappedComponent.role;
306
+ var key = this.dataKeys && this.dataKeys[index] || index;
307
+ var id = "".concat(name, "-").concat(type, "-").concat(key);
308
+ var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
309
+
310
+ if (!baseProps && !this.hasEvents) {
311
+ return undefined;
312
+ }
313
+
314
+ if (this.hasEvents) {
315
+ var baseEvents = this.getEvents(this.props, type, key);
318
316
 
319
- return _defaults({
317
+ var componentProps = _defaults({
320
318
  index: index,
321
319
  key: id
322
- }, component.props, baseProps, {
320
+ }, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
323
321
  id: id
324
322
  });
325
- }
326
- }, {
327
- key: "renderContainer",
328
- value: function renderContainer(component, children) {
329
- var isContainer = component.type && component.type.role === "container";
330
- var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
331
-
332
- if (parentProps.events) {
333
- this.globalEvents = Events.getGlobalEvents(parentProps.events);
334
- parentProps.events = Events.omitGlobalEvents(parentProps.events);
335
- }
336
323
 
337
- return React.cloneElement(component, parentProps, children);
324
+ var events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
325
+
326
+ return _assign({}, componentProps, {
327
+ events: events
328
+ });
338
329
  }
339
- }, {
340
- key: "animateComponent",
341
- value: function animateComponent(props, defaultAnimationWhitelist) {
342
- var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
343
- return React.createElement(VictoryTransition, {
344
- animate: props.animate,
345
- animationWhitelist: animationWhitelist
346
- }, React.createElement(this.constructor, props));
347
- } // Used by `VictoryLine` and `VictoryArea`
348
-
349
- }, {
350
- key: "renderContinuousData",
351
- value: function renderContinuousData(props) {
352
- var _this8 = this;
353
-
354
- var dataComponent = props.dataComponent,
355
- labelComponent = props.labelComponent,
356
- groupComponent = props.groupComponent;
357
-
358
- var dataKeys = _without(this.dataKeys, "all");
359
-
360
- var labelComponents = dataKeys.reduce(function (memo, key) {
361
- var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
362
-
363
- if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
364
- memo = memo.concat(React.cloneElement(labelComponent, labelProps));
365
- }
366
330
 
367
- return memo;
368
- }, []);
369
- var dataProps = this.getComponentProps(dataComponent, "data", "all");
370
- var children = [React.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
371
- return this.renderContainer(groupComponent, children);
331
+ return _defaults({
332
+ index: index,
333
+ key: id
334
+ }, component.props, baseProps, {
335
+ id: id
336
+ });
337
+ }
338
+ }, {
339
+ key: "renderContainer",
340
+ value: function renderContainer(component, children) {
341
+ var isContainer = component.type && component.type.role === "container";
342
+ var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
343
+
344
+ if (parentProps.events) {
345
+ this.globalEvents = Events.getGlobalEvents(parentProps.events);
346
+ parentProps.events = Events.omitGlobalEvents(parentProps.events);
372
347
  }
373
- }, {
374
- key: "renderData",
375
- value: function renderData(props) {
376
- var _this9 = this;
377
-
378
- var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
379
- var dataComponent = props.dataComponent,
380
- labelComponent = props.labelComponent,
381
- groupComponent = props.groupComponent;
382
- var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
383
- var dataProps = _this9.getComponentProps(dataComponent, "data", index);
384
-
385
- if (shouldRenderDatum(dataProps.datum)) {
386
- validDataComponents.push(React.cloneElement(dataComponent, dataProps));
387
- }
388
-
389
- return validDataComponents;
390
- }, []);
391
- var labelComponents = this.dataKeys.map(function (_dataKey, index) {
392
- var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
393
348
 
394
- if (labelProps.text !== undefined && labelProps.text !== null) {
395
- return React.cloneElement(labelComponent, labelProps);
396
- }
349
+ return /*#__PURE__*/React.cloneElement(component, parentProps, children);
350
+ }
351
+ }, {
352
+ key: "animateComponent",
353
+ value: function animateComponent(props, defaultAnimationWhitelist) {
354
+ var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
355
+ return /*#__PURE__*/React.createElement(VictoryTransition, {
356
+ animate: props.animate,
357
+ animationWhitelist: animationWhitelist
358
+ }, /*#__PURE__*/React.createElement(this.constructor, props));
359
+ } // Used by `VictoryLine` and `VictoryArea`
360
+
361
+ }, {
362
+ key: "renderContinuousData",
363
+ value: function renderContinuousData(props) {
364
+ var _this8 = this;
365
+
366
+ var dataComponent = props.dataComponent,
367
+ labelComponent = props.labelComponent,
368
+ groupComponent = props.groupComponent;
369
+
370
+ var dataKeys = _without(this.dataKeys, "all");
371
+
372
+ var labelComponents = dataKeys.reduce(function (memo, key) {
373
+ var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
374
+
375
+ if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
376
+ memo = memo.concat( /*#__PURE__*/React.cloneElement(labelComponent, labelProps));
377
+ }
397
378
 
398
- return undefined;
399
- }).filter(Boolean);
379
+ return memo;
380
+ }, []);
381
+ var dataProps = this.getComponentProps(dataComponent, "data", "all");
382
+ var children = [/*#__PURE__*/React.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
383
+ return this.renderContainer(groupComponent, children);
384
+ }
385
+ }, {
386
+ key: "renderData",
387
+ value: function renderData(props) {
388
+ var _this9 = this;
389
+
390
+ var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
391
+ var dataComponent = props.dataComponent,
392
+ labelComponent = props.labelComponent,
393
+ groupComponent = props.groupComponent;
394
+ var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
395
+ var dataProps = _this9.getComponentProps(dataComponent, "data", index);
396
+
397
+ if (shouldRenderDatum(dataProps.datum)) {
398
+ validDataComponents.push( /*#__PURE__*/React.cloneElement(dataComponent, dataProps));
399
+ }
400
400
 
401
- var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
401
+ return validDataComponents;
402
+ }, []);
403
+ var labelComponents = this.dataKeys.map(function (_dataKey, index) {
404
+ var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
402
405
 
403
- return this.renderContainer(groupComponent, children);
404
- }
405
- }]);
406
+ if (labelProps.text !== undefined && labelProps.text !== null) {
407
+ return /*#__PURE__*/React.cloneElement(labelComponent, labelProps);
408
+ }
409
+
410
+ return undefined;
411
+ }).filter(Boolean);
412
+ var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
413
+ return this.renderContainer(groupComponent, children);
414
+ }
415
+ }]);
406
416
 
407
- return addEvents;
408
- }(WrappedComponent)
409
- );
417
+ return addEvents;
418
+ }(WrappedComponent);
410
419
  });