victory-core 36.1.0 → 36.3.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 (36) hide show
  1. package/dist/victory-core.js +852 -728
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.d.ts +2 -0
  4. package/es/index.js +2 -1
  5. package/es/victory-accessible-group/victory-accessible-group.js +3 -1
  6. package/es/victory-animation/victory-animation.js +3 -1
  7. package/es/victory-clip-container/victory-clip-container.js +3 -1
  8. package/es/victory-container/victory-container.js +3 -1
  9. package/es/victory-portal/portal.js +3 -1
  10. package/es/victory-portal/victory-portal.js +3 -1
  11. package/es/victory-transition/victory-transition.js +3 -1
  12. package/es/victory-util/add-events.js +308 -305
  13. package/es/victory-util/hooks/index.js +2 -0
  14. package/es/victory-util/{hooks.js → hooks/use-animation-state.js} +2 -9
  15. package/es/victory-util/hooks/use-previous-props.js +8 -0
  16. package/es/victory-util/timer.js +3 -1
  17. package/lib/index.d.ts +2 -0
  18. package/lib/index.js +4 -62
  19. package/lib/victory-accessible-group/victory-accessible-group.js +3 -1
  20. package/lib/victory-animation/victory-animation.js +3 -1
  21. package/lib/victory-clip-container/victory-clip-container.js +3 -1
  22. package/lib/victory-container/victory-container.js +3 -1
  23. package/lib/victory-portal/portal.js +3 -1
  24. package/lib/victory-portal/victory-portal.js +3 -1
  25. package/lib/victory-transition/victory-transition.js +3 -1
  26. package/lib/victory-util/add-events.js +304 -301
  27. package/lib/victory-util/hooks/index.js +21 -0
  28. package/lib/victory-util/{hooks.js → hooks/use-animation-state.js} +3 -14
  29. package/lib/victory-util/hooks/use-previous-props.js +22 -0
  30. package/lib/victory-util/timer.js +3 -1
  31. package/package.json +2 -2
  32. package/src/index.d.ts +2 -0
  33. package/src/index.js +1 -1
  34. package/src/victory-util/hooks/index.js +2 -0
  35. package/src/victory-util/{hooks.js → hooks/use-animation-state.js} +2 -10
  36. package/src/victory-util/hooks/use-previous-props.js +9 -0
@@ -70,344 +70,347 @@ var defaultComponents = [{
70
70
  }];
71
71
 
72
72
  var _default = function _default(WrappedComponent, options) {
73
- return /*#__PURE__*/function (_WrappedComponent) {
74
- _inherits(addEvents, _WrappedComponent);
73
+ return (
74
+ /*#__PURE__*/
75
+ function (_WrappedComponent) {
76
+ _inherits(addEvents, _WrappedComponent);
75
77
 
76
- function addEvents(props) {
77
- var _this;
78
+ function addEvents(props) {
79
+ var _this;
78
80
 
79
- _classCallCheck(this, addEvents);
81
+ _classCallCheck(this, addEvents);
80
82
 
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 = {};
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 = {};
85
87
 
86
- _this.getEvents = function (p, target, eventKey) {
87
- return boundGetEvents(p, target, eventKey, getScopedEvents);
88
- };
88
+ _this.getEvents = function (p, target, eventKey) {
89
+ return boundGetEvents(p, target, eventKey, getScopedEvents);
90
+ };
89
91
 
90
- _this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
92
+ _this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
91
93
 
92
- var calculatedValues = _this.getCalculatedValues(props);
94
+ var calculatedValues = _this.getCalculatedValues(props);
93
95
 
94
- _this.cacheValues(calculatedValues);
96
+ _this.cacheValues(calculatedValues);
95
97
 
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
- }
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
+ }
103
105
 
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);
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
+ }
110
119
 
111
- if (animating || newMutation) {
112
- this.cacheValues(this.getCalculatedValues(nextProps));
113
- this.externalMutations = externalMutations;
114
- this.applyExternalMutations(nextProps, externalMutations);
115
- return true;
116
- }
120
+ var calculatedState = this.getStateChanges(nextProps);
117
121
 
118
- var calculatedState = this.getStateChanges(nextProps);
122
+ if (!(0, _reactFastCompare.default)(this.calculatedState, calculatedState)) {
123
+ this.cacheValues(this.getCalculatedValues(nextProps));
124
+ return true;
125
+ }
119
126
 
120
- if (!(0, _reactFastCompare.default)(this.calculatedState, calculatedState)) {
121
- this.cacheValues(this.getCalculatedValues(nextProps));
122
- return true;
123
- }
127
+ if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
128
+ this.cacheValues(this.getCalculatedValues(nextProps));
129
+ return true;
130
+ }
124
131
 
125
- if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
126
- this.cacheValues(this.getCalculatedValues(nextProps));
127
- return true;
132
+ return false;
128
133
  }
129
-
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
- };
179
-
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 {};
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;
144
+ }
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;
197
162
  }
163
+ }, {
164
+ key: "componentWillUnmount",
165
+ value: function componentWillUnmount() {
166
+ var _this4 = this;
198
167
 
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
- };
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);
184
+ }
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
+ }
203
200
 
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
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);
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);
214
234
  }
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();
229
- });
230
- } : undefined;
231
- this.setState(externalMutations, compiledCallbacks);
232
235
  }
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;
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;
291
271
 
292
- return Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
272
+ (0, _keys2.default)(obj).forEach(function (key) {
273
+ _this7[key] = obj[key];
274
+ });
293
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) : {};
287
+ }
288
+ }, {
289
+ key: "getAllEvents",
290
+ value: function getAllEvents(props) {
291
+ if (Array.isArray(this.componentEvents)) {
292
+ var _componentEvents;
294
293
 
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;
294
+ return Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
295
+ }
296
+
297
+ return props.events;
307
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) {
308
+ return undefined;
309
+ }
308
310
 
309
- if (this.hasEvents) {
310
- var baseEvents = this.getEvents(this.props, type, key);
311
- var componentProps = (0, _defaults2.default)({
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
322
+ });
323
+ }
324
+
325
+ return (0, _defaults2.default)({
312
326
  index: index,
313
327
  key: id
314
- }, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
328
+ }, component.props, baseProps, {
315
329
  id: id
316
330
  });
317
- var events = (0, _defaults2.default)({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
318
- return (0, _assign2.default)({}, componentProps, {
319
- events: events
320
- });
321
331
  }
322
-
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);
339
- }
340
-
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));
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);
367
341
  }
368
342
 
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
- }
343
+ return _react.default.cloneElement(component, parentProps, children);
344
+ }
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
+ }
390
370
 
391
- return validDataComponents;
392
- }, []);
393
- var labelComponents = this.dataKeys.map(function (_dataKey, index) {
394
- var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
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);
395
397
 
396
- if (labelProps.text !== undefined && labelProps.text !== null) {
397
- return _react.default.cloneElement(labelComponent, labelProps);
398
- }
398
+ if (labelProps.text !== undefined && labelProps.text !== null) {
399
+ return _react.default.cloneElement(labelComponent, labelProps);
400
+ }
399
401
 
400
- return undefined;
401
- }).filter(Boolean);
402
+ return undefined;
403
+ }).filter(Boolean);
402
404
 
403
- var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
405
+ var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
404
406
 
405
- return this.renderContainer(groupComponent, children);
406
- }
407
- }]);
407
+ return this.renderContainer(groupComponent, children);
408
+ }
409
+ }]);
408
410
 
409
- return addEvents;
410
- }(WrappedComponent);
411
+ return addEvents;
412
+ }(WrappedComponent)
413
+ );
411
414
  };
412
415
 
413
416
  exports.default = _default;