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.
- package/LICENSE.txt +30 -0
- package/dist/victory-core.js +4376 -1142
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +6 -0
- package/es/index.js +8 -2
- 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-label/victory-label.js +3 -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/hooks.js +137 -0
- 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/es/victory-util/wrapper.js +372 -457
- package/lib/index.d.ts +6 -0
- package/lib/index.js +78 -8
- 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-label/victory-label.js +3 -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/hooks.js +162 -0
- 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/lib/victory-util/wrapper.js +389 -446
- package/package.json +7 -3
- package/src/index.d.ts +6 -0
- package/src/index.js +5 -1
- package/src/victory-label/victory-label.js +3 -3
- package/src/victory-primitives/point.js +1 -1
- package/src/victory-util/hooks.js +131 -0
- package/src/victory-util/line-helpers.js +54 -0
- package/src/{victory-primitives/path-helpers.js → victory-util/point-path-helpers.js} +0 -0
- package/src/victory-util/transitions.js +0 -1
- 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
|
-
|
|
75
|
-
function (_WrappedComponent) {
|
|
76
|
-
_inherits(addEvents, _WrappedComponent);
|
|
73
|
+
return /*#__PURE__*/function (_WrappedComponent) {
|
|
74
|
+
_inherits(addEvents, _WrappedComponent);
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
function addEvents(props) {
|
|
77
|
+
var _this;
|
|
80
78
|
|
|
81
|
-
|
|
79
|
+
_classCallCheck(this, addEvents);
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
_this.getEvents = function (p, target, eventKey) {
|
|
87
|
+
return boundGetEvents(p, target, eventKey, getScopedEvents);
|
|
88
|
+
};
|
|
91
89
|
|
|
92
|
-
|
|
90
|
+
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
var calculatedValues = _this.getCalculatedValues(props);
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
_this.cacheValues(calculatedValues);
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
128
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
118
|
+
var calculatedState = this.getStateChanges(nextProps);
|
|
131
119
|
|
|
132
|
-
|
|
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
|
-
|
|
169
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
key
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
399
|
-
|
|
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
|
-
|
|
403
|
-
|
|
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
|
-
|
|
400
|
+
return undefined;
|
|
401
|
+
}).filter(Boolean);
|
|
406
402
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
403
|
+
var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
|
|
404
|
+
|
|
405
|
+
return this.renderContainer(groupComponent, children);
|
|
406
|
+
}
|
|
407
|
+
}]);
|
|
410
408
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
);
|
|
409
|
+
return addEvents;
|
|
410
|
+
}(WrappedComponent);
|
|
414
411
|
};
|
|
415
412
|
|
|
416
413
|
exports.default = _default;
|