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