victory-core 36.1.0 → 36.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/victory-core.js +852 -728
- package/dist/victory-core.min.js +1 -1
- package/es/index.js +2 -1
- package/es/victory-accessible-group/victory-accessible-group.js +3 -1
- package/es/victory-animation/victory-animation.js +3 -1
- package/es/victory-clip-container/victory-clip-container.js +3 -1
- package/es/victory-container/victory-container.js +3 -1
- package/es/victory-portal/portal.js +3 -1
- package/es/victory-portal/victory-portal.js +3 -1
- package/es/victory-transition/victory-transition.js +3 -1
- package/es/victory-util/add-events.js +308 -305
- package/es/victory-util/hooks/index.js +2 -0
- package/es/victory-util/{hooks.js → hooks/use-animation-state.js} +2 -9
- package/es/victory-util/hooks/use-previous-props.js +8 -0
- package/es/victory-util/timer.js +3 -1
- package/lib/index.js +4 -62
- package/lib/victory-accessible-group/victory-accessible-group.js +3 -1
- package/lib/victory-animation/victory-animation.js +3 -1
- package/lib/victory-clip-container/victory-clip-container.js +3 -1
- package/lib/victory-container/victory-container.js +3 -1
- package/lib/victory-portal/portal.js +3 -1
- package/lib/victory-portal/victory-portal.js +3 -1
- package/lib/victory-transition/victory-transition.js +3 -1
- package/lib/victory-util/add-events.js +304 -301
- package/lib/victory-util/hooks/index.js +21 -0
- package/lib/victory-util/{hooks.js → hooks/use-animation-state.js} +3 -14
- package/lib/victory-util/hooks/use-previous-props.js +22 -0
- package/lib/victory-util/timer.js +3 -1
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/victory-util/hooks/index.js +2 -0
- package/src/victory-util/{hooks.js → hooks/use-animation-state.js} +2 -10
- package/src/victory-util/hooks/use-previous-props.js +9 -0
|
@@ -48,360 +48,363 @@ var defaultComponents = [{
|
|
|
48
48
|
name: "labels"
|
|
49
49
|
}];
|
|
50
50
|
export default (function (WrappedComponent, options) {
|
|
51
|
-
return
|
|
52
|
-
|
|
51
|
+
return (
|
|
52
|
+
/*#__PURE__*/
|
|
53
|
+
function (_WrappedComponent) {
|
|
54
|
+
_inherits(addEvents, _WrappedComponent);
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
function addEvents(props) {
|
|
57
|
+
var _this;
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
_classCallCheck(this, addEvents);
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
_this = _possibleConstructorReturn(this, (addEvents.__proto__ || Object.getPrototypeOf(addEvents)).call(this, props));
|
|
62
|
+
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
|
|
63
|
+
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
|
|
64
|
+
_this.state = {};
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
_this.getEvents = function (p, target, eventKey) {
|
|
67
|
+
return boundGetEvents(p, target, eventKey, getScopedEvents);
|
|
68
|
+
};
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
var calculatedValues = _this.getCalculatedValues(props);
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
_this.cacheValues(calculatedValues);
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
_this.externalMutations = _this.getExternalMutations(props);
|
|
77
|
+
_this.calculatedState = _this.getStateChanges(props);
|
|
78
|
+
_this.globalEvents = {};
|
|
79
|
+
_this.prevGlobalEventKeys = [];
|
|
80
|
+
_this.boundGlobalEvents = {};
|
|
81
|
+
return _this;
|
|
82
|
+
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
_createClass(addEvents, [{
|
|
85
|
+
key: "shouldComponentUpdate",
|
|
86
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
87
|
+
var externalMutations = this.getExternalMutations(nextProps);
|
|
88
|
+
var animating = this.props.animating || this.props.animate;
|
|
89
|
+
var newMutation = !isEqual(externalMutations, this.externalMutations);
|
|
90
|
+
|
|
91
|
+
if (animating || newMutation) {
|
|
92
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
93
|
+
this.externalMutations = externalMutations;
|
|
94
|
+
this.applyExternalMutations(nextProps, externalMutations);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
91
|
-
this.externalMutations = externalMutations;
|
|
92
|
-
this.applyExternalMutations(nextProps, externalMutations);
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
98
|
+
var calculatedState = this.getStateChanges(nextProps);
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
if (!isEqual(this.calculatedState, calculatedState)) {
|
|
101
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
if (!isEqual(this.props, nextProps)) {
|
|
106
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
105
|
-
return true;
|
|
110
|
+
return false;
|
|
106
111
|
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "componentDidMount",
|
|
114
|
+
value: function componentDidMount() {
|
|
115
|
+
var _this2 = this;
|
|
107
116
|
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "componentDidMount",
|
|
112
|
-
value: function componentDidMount() {
|
|
113
|
-
var _this2 = this;
|
|
117
|
+
var globalEventKeys = _keys(this.globalEvents);
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
value: function componentDidUpdate(prevProps) {
|
|
125
|
-
var _this3 = this;
|
|
119
|
+
globalEventKeys.forEach(function (key) {
|
|
120
|
+
return _this2.addGlobalListener(key);
|
|
121
|
+
});
|
|
122
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "componentDidUpdate",
|
|
126
|
+
value: function componentDidUpdate(prevProps) {
|
|
127
|
+
var _this3 = this;
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
var calculatedState = this.getStateChanges(prevProps);
|
|
130
|
+
this.calculatedState = calculatedState;
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
var globalEventKeys = _keys(this.globalEvents);
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
var removedGlobalEventKeys = _difference(this.prevGlobalEventKeys, globalEventKeys);
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
removedGlobalEventKeys.forEach(function (key) {
|
|
137
|
+
return _this3.removeGlobalListener(key);
|
|
138
|
+
});
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
var addedGlobalEventKeys = _difference(globalEventKeys, this.prevGlobalEventKeys);
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.prevGlobalEventKeys.forEach(function (key) {
|
|
151
|
-
return _this4.removeGlobalListener(key);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: "addGlobalListener",
|
|
156
|
-
value: function addGlobalListener(key) {
|
|
157
|
-
var _this5 = this;
|
|
158
|
-
|
|
159
|
-
var boundListener = function (event) {
|
|
160
|
-
var listener = _this5.globalEvents[key];
|
|
161
|
-
return listener && listener(Events.emulateReactEvent(event));
|
|
162
|
-
};
|
|
142
|
+
addedGlobalEventKeys.forEach(function (key) {
|
|
143
|
+
return _this3.addGlobalListener(key);
|
|
144
|
+
});
|
|
145
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "componentWillUnmount",
|
|
149
|
+
value: function componentWillUnmount() {
|
|
150
|
+
var _this4 = this;
|
|
163
151
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return {};
|
|
152
|
+
this.prevGlobalEventKeys.forEach(function (key) {
|
|
153
|
+
return _this4.removeGlobalListener(key);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "addGlobalListener",
|
|
158
|
+
value: function addGlobalListener(key) {
|
|
159
|
+
var _this5 = this;
|
|
160
|
+
|
|
161
|
+
var boundListener = function (event) {
|
|
162
|
+
var listener = _this5.globalEvents[key];
|
|
163
|
+
return listener && listener(Events.emulateReactEvent(event));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
this.boundGlobalEvents[key] = boundListener;
|
|
167
|
+
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
|
|
181
168
|
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "removeGlobalListener",
|
|
171
|
+
value: function removeGlobalListener(key) {
|
|
172
|
+
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
|
|
173
|
+
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
174
|
+
// state change should trigger a re-render
|
|
175
|
+
|
|
176
|
+
}, {
|
|
177
|
+
key: "getStateChanges",
|
|
178
|
+
value: function getStateChanges(props) {
|
|
179
|
+
var _this6 = this;
|
|
180
|
+
|
|
181
|
+
if (!this.hasEvents) {
|
|
182
|
+
return {};
|
|
183
|
+
}
|
|
182
184
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
var getState = function (key, type) {
|
|
186
|
+
var result = _defaults({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
|
|
187
|
+
|
|
188
|
+
return _isEmpty(result) ? undefined : result;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
options = options || {};
|
|
192
|
+
var components = options.components || defaultComponents;
|
|
193
|
+
var stateChanges = components.map(function (component) {
|
|
194
|
+
if (!props.standalone && component.name === "parent") {
|
|
195
|
+
// don't check for changes on parent props for non-standalone components
|
|
196
|
+
return undefined;
|
|
197
|
+
} else {
|
|
198
|
+
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
199
|
+
return getState(key, component.name);
|
|
200
|
+
}).filter(Boolean);
|
|
201
|
+
}
|
|
202
|
+
}).filter(Boolean);
|
|
203
|
+
return stateChanges;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "applyExternalMutations",
|
|
207
|
+
value: function applyExternalMutations(props, externalMutations) {
|
|
208
|
+
if (!_isEmpty(externalMutations)) {
|
|
209
|
+
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
210
|
+
memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
211
|
+
return memo;
|
|
212
|
+
}, []);
|
|
213
|
+
var compiledCallbacks = callbacks.length ? function () {
|
|
214
|
+
callbacks.forEach(function (c) {
|
|
215
|
+
return c();
|
|
216
|
+
});
|
|
217
|
+
} : undefined;
|
|
218
|
+
this.setState(externalMutations, compiledCallbacks);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "getCalculatedValues",
|
|
223
|
+
value: function getCalculatedValues(props) {
|
|
224
|
+
var sharedEvents = props.sharedEvents;
|
|
225
|
+
var components = WrappedComponent.expectedComponents;
|
|
226
|
+
var componentEvents = Events.getComponentEvents(props, components);
|
|
227
|
+
var getSharedEventState = sharedEvents && _isFunction(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
var baseProps = this.getBaseProps(props, getSharedEventState);
|
|
185
231
|
|
|
186
|
-
|
|
187
|
-
|
|
232
|
+
var dataKeys = _keys(baseProps).filter(function (key) {
|
|
233
|
+
return key !== "parent";
|
|
234
|
+
});
|
|
188
235
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
}).filter(Boolean);
|
|
201
|
-
return stateChanges;
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "applyExternalMutations",
|
|
205
|
-
value: function applyExternalMutations(props, externalMutations) {
|
|
206
|
-
if (!_isEmpty(externalMutations)) {
|
|
207
|
-
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
208
|
-
memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
209
|
-
return memo;
|
|
210
|
-
}, []);
|
|
211
|
-
var compiledCallbacks = callbacks.length ? function () {
|
|
212
|
-
callbacks.forEach(function (c) {
|
|
213
|
-
return c();
|
|
214
|
-
});
|
|
215
|
-
} : undefined;
|
|
216
|
-
this.setState(externalMutations, compiledCallbacks);
|
|
236
|
+
var hasEvents = props.events || props.sharedEvents || componentEvents;
|
|
237
|
+
var events = this.getAllEvents(props);
|
|
238
|
+
return {
|
|
239
|
+
componentEvents: componentEvents,
|
|
240
|
+
getSharedEventState: getSharedEventState,
|
|
241
|
+
baseProps: baseProps,
|
|
242
|
+
dataKeys: dataKeys,
|
|
243
|
+
hasEvents: hasEvents,
|
|
244
|
+
events: events
|
|
245
|
+
};
|
|
217
246
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var dataKeys = _keys(baseProps).filter(function (key) {
|
|
231
|
-
return key !== "parent";
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
var hasEvents = props.events || props.sharedEvents || componentEvents;
|
|
235
|
-
var events = this.getAllEvents(props);
|
|
236
|
-
return {
|
|
237
|
-
componentEvents: componentEvents,
|
|
238
|
-
getSharedEventState: getSharedEventState,
|
|
239
|
-
baseProps: baseProps,
|
|
240
|
-
dataKeys: dataKeys,
|
|
241
|
-
hasEvents: hasEvents,
|
|
242
|
-
events: events
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "getExternalMutations",
|
|
247
|
-
value: function getExternalMutations(props) {
|
|
248
|
-
var sharedEvents = props.sharedEvents,
|
|
249
|
-
externalEventMutations = props.externalEventMutations;
|
|
250
|
-
return _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
|
|
251
|
-
}
|
|
252
|
-
}, {
|
|
253
|
-
key: "cacheValues",
|
|
254
|
-
value: function cacheValues(obj) {
|
|
255
|
-
var _this7 = this;
|
|
256
|
-
|
|
257
|
-
_keys(obj).forEach(function (key) {
|
|
258
|
-
_this7[key] = obj[key];
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}, {
|
|
262
|
-
key: "getBaseProps",
|
|
263
|
-
value: function getBaseProps(props, getSharedEventState) {
|
|
264
|
-
getSharedEventState = getSharedEventState || this.getSharedEventState;
|
|
265
|
-
var sharedParentState = getSharedEventState("parent", "parent");
|
|
266
|
-
var parentState = this.getEventState("parent", "parent");
|
|
247
|
+
}, {
|
|
248
|
+
key: "getExternalMutations",
|
|
249
|
+
value: function getExternalMutations(props) {
|
|
250
|
+
var sharedEvents = props.sharedEvents,
|
|
251
|
+
externalEventMutations = props.externalEventMutations;
|
|
252
|
+
return _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "cacheValues",
|
|
256
|
+
value: function cacheValues(obj) {
|
|
257
|
+
var _this7 = this;
|
|
267
258
|
|
|
268
|
-
|
|
259
|
+
_keys(obj).forEach(function (key) {
|
|
260
|
+
_this7[key] = obj[key];
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
key: "getBaseProps",
|
|
265
|
+
value: function getBaseProps(props, getSharedEventState) {
|
|
266
|
+
getSharedEventState = getSharedEventState || this.getSharedEventState;
|
|
267
|
+
var sharedParentState = getSharedEventState("parent", "parent");
|
|
268
|
+
var parentState = this.getEventState("parent", "parent");
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
var parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
|
|
270
|
+
var baseParentProps = _defaults({}, parentState, sharedParentState);
|
|
272
271
|
|
|
273
|
-
|
|
272
|
+
var parentPropsList = baseParentProps.parentControlledProps;
|
|
273
|
+
var parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
}, {
|
|
278
|
-
key: "getAllEvents",
|
|
279
|
-
value: function getAllEvents(props) {
|
|
280
|
-
if (Array.isArray(this.componentEvents)) {
|
|
281
|
-
var _componentEvents;
|
|
275
|
+
var modifiedProps = _defaults({}, parentProps, props);
|
|
282
276
|
|
|
283
|
-
return
|
|
277
|
+
return _isFunction(WrappedComponent.getBaseProps) ? WrappedComponent.getBaseProps(modifiedProps) : {};
|
|
284
278
|
}
|
|
279
|
+
}, {
|
|
280
|
+
key: "getAllEvents",
|
|
281
|
+
value: function getAllEvents(props) {
|
|
282
|
+
if (Array.isArray(this.componentEvents)) {
|
|
283
|
+
var _componentEvents;
|
|
285
284
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
value: function getComponentProps(component, type, index) {
|
|
291
|
-
var name = this.props.name || WrappedComponent.role;
|
|
292
|
-
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
293
|
-
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
294
|
-
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
295
|
-
|
|
296
|
-
if (!baseProps && !this.hasEvents) {
|
|
297
|
-
return undefined;
|
|
285
|
+
return Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return props.events;
|
|
298
289
|
}
|
|
290
|
+
}, {
|
|
291
|
+
key: "getComponentProps",
|
|
292
|
+
value: function getComponentProps(component, type, index) {
|
|
293
|
+
var name = this.props.name || WrappedComponent.role;
|
|
294
|
+
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
295
|
+
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
296
|
+
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
297
|
+
|
|
298
|
+
if (!baseProps && !this.hasEvents) {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (this.hasEvents) {
|
|
303
|
+
var baseEvents = this.getEvents(this.props, type, key);
|
|
304
|
+
|
|
305
|
+
var componentProps = _defaults({
|
|
306
|
+
index: index,
|
|
307
|
+
key: id
|
|
308
|
+
}, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
|
|
309
|
+
id: id
|
|
310
|
+
});
|
|
299
311
|
|
|
300
|
-
|
|
301
|
-
var baseEvents = this.getEvents(this.props, type, key);
|
|
312
|
+
var events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
|
|
302
313
|
|
|
303
|
-
|
|
314
|
+
return _assign({}, componentProps, {
|
|
315
|
+
events: events
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return _defaults({
|
|
304
320
|
index: index,
|
|
305
321
|
key: id
|
|
306
|
-
},
|
|
322
|
+
}, component.props, baseProps, {
|
|
307
323
|
id: id
|
|
308
324
|
});
|
|
309
|
-
|
|
310
|
-
var events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
|
|
311
|
-
|
|
312
|
-
return _assign({}, componentProps, {
|
|
313
|
-
events: events
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return _defaults({
|
|
318
|
-
index: index,
|
|
319
|
-
key: id
|
|
320
|
-
}, component.props, baseProps, {
|
|
321
|
-
id: id
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
key: "renderContainer",
|
|
326
|
-
value: function renderContainer(component, children) {
|
|
327
|
-
var isContainer = component.type && component.type.role === "container";
|
|
328
|
-
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
329
|
-
|
|
330
|
-
if (parentProps.events) {
|
|
331
|
-
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
332
|
-
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
333
325
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
animationWhitelist: animationWhitelist
|
|
344
|
-
}, React.createElement(this.constructor, props));
|
|
345
|
-
} // Used by `VictoryLine` and `VictoryArea`
|
|
346
|
-
|
|
347
|
-
}, {
|
|
348
|
-
key: "renderContinuousData",
|
|
349
|
-
value: function renderContinuousData(props) {
|
|
350
|
-
var _this8 = this;
|
|
351
|
-
|
|
352
|
-
var dataComponent = props.dataComponent,
|
|
353
|
-
labelComponent = props.labelComponent,
|
|
354
|
-
groupComponent = props.groupComponent;
|
|
355
|
-
|
|
356
|
-
var dataKeys = _without(this.dataKeys, "all");
|
|
357
|
-
|
|
358
|
-
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
359
|
-
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
360
|
-
|
|
361
|
-
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
362
|
-
memo = memo.concat(React.cloneElement(labelComponent, labelProps));
|
|
326
|
+
}, {
|
|
327
|
+
key: "renderContainer",
|
|
328
|
+
value: function renderContainer(component, children) {
|
|
329
|
+
var isContainer = component.type && component.type.role === "container";
|
|
330
|
+
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
331
|
+
|
|
332
|
+
if (parentProps.events) {
|
|
333
|
+
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
334
|
+
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
363
335
|
}
|
|
364
336
|
|
|
365
|
-
return
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
337
|
+
return React.cloneElement(component, parentProps, children);
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
key: "animateComponent",
|
|
341
|
+
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
342
|
+
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
343
|
+
return React.createElement(VictoryTransition, {
|
|
344
|
+
animate: props.animate,
|
|
345
|
+
animationWhitelist: animationWhitelist
|
|
346
|
+
}, React.createElement(this.constructor, props));
|
|
347
|
+
} // Used by `VictoryLine` and `VictoryArea`
|
|
348
|
+
|
|
349
|
+
}, {
|
|
350
|
+
key: "renderContinuousData",
|
|
351
|
+
value: function renderContinuousData(props) {
|
|
352
|
+
var _this8 = this;
|
|
353
|
+
|
|
354
|
+
var dataComponent = props.dataComponent,
|
|
355
|
+
labelComponent = props.labelComponent,
|
|
356
|
+
groupComponent = props.groupComponent;
|
|
357
|
+
|
|
358
|
+
var dataKeys = _without(this.dataKeys, "all");
|
|
359
|
+
|
|
360
|
+
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
361
|
+
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
362
|
+
|
|
363
|
+
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
364
|
+
memo = memo.concat(React.cloneElement(labelComponent, labelProps));
|
|
365
|
+
}
|
|
386
366
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var
|
|
367
|
+
return memo;
|
|
368
|
+
}, []);
|
|
369
|
+
var dataProps = this.getComponentProps(dataComponent, "data", "all");
|
|
370
|
+
var children = [React.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
|
|
371
|
+
return this.renderContainer(groupComponent, children);
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "renderData",
|
|
375
|
+
value: function renderData(props) {
|
|
376
|
+
var _this9 = this;
|
|
377
|
+
|
|
378
|
+
var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
|
|
379
|
+
var dataComponent = props.dataComponent,
|
|
380
|
+
labelComponent = props.labelComponent,
|
|
381
|
+
groupComponent = props.groupComponent;
|
|
382
|
+
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
383
|
+
var dataProps = _this9.getComponentProps(dataComponent, "data", index);
|
|
384
|
+
|
|
385
|
+
if (shouldRenderDatum(dataProps.datum)) {
|
|
386
|
+
validDataComponents.push(React.cloneElement(dataComponent, dataProps));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return validDataComponents;
|
|
390
|
+
}, []);
|
|
391
|
+
var labelComponents = this.dataKeys.map(function (_dataKey, index) {
|
|
392
|
+
var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
|
|
391
393
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
395
|
+
return React.cloneElement(labelComponent, labelProps);
|
|
396
|
+
}
|
|
395
397
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
+
return undefined;
|
|
399
|
+
}).filter(Boolean);
|
|
398
400
|
|
|
399
|
-
|
|
401
|
+
var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
|
|
400
402
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
return this.renderContainer(groupComponent, children);
|
|
404
|
+
}
|
|
405
|
+
}]);
|
|
404
406
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
+
return addEvents;
|
|
408
|
+
}(WrappedComponent)
|
|
409
|
+
);
|
|
407
410
|
});
|