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