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.
- package/dist/victory-core.js +852 -728
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +2 -0
- 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.d.ts +2 -0
- 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.d.ts +2 -0
- 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
|
@@ -70,344 +70,347 @@ var defaultComponents = [{
|
|
|
70
70
|
}];
|
|
71
71
|
|
|
72
72
|
var _default = function _default(WrappedComponent, options) {
|
|
73
|
-
return
|
|
74
|
-
|
|
73
|
+
return (
|
|
74
|
+
/*#__PURE__*/
|
|
75
|
+
function (_WrappedComponent) {
|
|
76
|
+
_inherits(addEvents, _WrappedComponent);
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
function addEvents(props) {
|
|
79
|
+
var _this;
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
_classCallCheck(this, addEvents);
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
_this.getEvents = function (p, target, eventKey) {
|
|
89
|
+
return boundGetEvents(p, target, eventKey, getScopedEvents);
|
|
90
|
+
};
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
var calculatedValues = _this.getCalculatedValues(props);
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
_this.cacheValues(calculatedValues);
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
+
if (!(0, _reactFastCompare.default)(this.calculatedState, calculatedState)) {
|
|
123
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
119
126
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
128
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
127
|
-
return true;
|
|
132
|
+
return false;
|
|
128
133
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
var
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
398
|
+
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
399
|
+
return _react.default.cloneElement(labelComponent, labelProps);
|
|
400
|
+
}
|
|
399
401
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
+
return undefined;
|
|
403
|
+
}).filter(Boolean);
|
|
402
404
|
|
|
403
|
-
|
|
405
|
+
var children = _toConsumableArray(dataComponents).concat(_toConsumableArray(labelComponents));
|
|
404
406
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
407
|
+
return this.renderContainer(groupComponent, children);
|
|
408
|
+
}
|
|
409
|
+
}]);
|
|
408
410
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
+
return addEvents;
|
|
412
|
+
}(WrappedComponent)
|
|
413
|
+
);
|
|
411
414
|
};
|
|
412
415
|
|
|
413
416
|
exports.default = _default;
|