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