victory-core 36.3.2 → 36.4.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 +14175 -14191
- package/dist/victory-core.min.js +1 -1
- package/es/victory-accessible-group/victory-accessible-group.js +38 -40
- package/es/victory-animation/util.js +1 -1
- package/es/victory-animation/victory-animation.js +46 -48
- package/es/victory-clip-container/victory-clip-container.js +71 -73
- package/es/victory-container/victory-container.js +82 -92
- package/es/victory-label/victory-label.js +29 -24
- package/es/victory-portal/portal-context.js +1 -1
- package/es/victory-portal/portal.js +28 -26
- package/es/victory-portal/victory-portal.js +31 -41
- package/es/victory-primitives/arc.js +6 -4
- package/es/victory-primitives/background.js +8 -6
- package/es/victory-primitives/border.js +6 -4
- package/es/victory-primitives/circle.js +8 -4
- package/es/victory-primitives/clip-path.js +1 -1
- package/es/victory-primitives/line-segment.js +6 -4
- package/es/victory-primitives/line.js +8 -4
- package/es/victory-primitives/path.js +7 -3
- package/es/victory-primitives/point.js +6 -4
- package/es/victory-primitives/rect.js +8 -4
- package/es/victory-primitives/text.js +7 -3
- package/es/victory-primitives/tspan.js +1 -1
- package/es/victory-primitives/whisker.js +9 -7
- package/es/victory-transition/victory-transition.js +30 -32
- package/es/victory-util/add-events.js +326 -317
- package/es/victory-util/axis.js +12 -5
- package/es/victory-util/collection.js +8 -4
- package/es/victory-util/data.js +9 -5
- package/es/victory-util/domain.js +8 -4
- package/es/victory-util/events.js +8 -4
- package/es/victory-util/helpers.js +1 -1
- package/es/victory-util/hooks/use-animation-state.js +11 -5
- package/es/victory-util/line-helpers.js +1 -1
- package/es/victory-util/scale.js +19 -19
- package/es/victory-util/textsize.js +11 -7
- package/es/victory-util/timer-context.js +1 -1
- package/es/victory-util/timer.js +3 -5
- package/es/victory-util/user-props.js +31 -4
- package/es/victory-util/wrapper.js +18 -12
- package/lib/index.js +68 -58
- package/lib/victory-accessible-group/victory-accessible-group.js +38 -40
- package/lib/victory-animation/util.js +2 -2
- package/lib/victory-animation/victory-animation.js +49 -49
- package/lib/victory-clip-container/victory-clip-container.js +74 -74
- package/lib/victory-container/victory-container.js +85 -93
- package/lib/victory-label/victory-label.js +35 -27
- package/lib/victory-portal/portal-context.js +1 -1
- package/lib/victory-portal/portal.js +31 -27
- package/lib/victory-portal/victory-portal.js +34 -42
- package/lib/victory-primitives/arc.js +9 -5
- package/lib/victory-primitives/background.js +11 -7
- package/lib/victory-primitives/border.js +9 -5
- package/lib/victory-primitives/circle.js +8 -4
- package/lib/victory-primitives/clip-path.js +1 -1
- package/lib/victory-primitives/line-segment.js +9 -5
- package/lib/victory-primitives/line.js +8 -4
- package/lib/victory-primitives/path.js +7 -3
- package/lib/victory-primitives/point.js +9 -5
- package/lib/victory-primitives/rect.js +8 -4
- package/lib/victory-primitives/text.js +7 -3
- package/lib/victory-primitives/tspan.js +1 -1
- package/lib/victory-primitives/whisker.js +12 -8
- package/lib/victory-transition/victory-transition.js +33 -33
- package/lib/victory-util/add-events.js +325 -313
- package/lib/victory-util/axis.js +20 -11
- package/lib/victory-util/collection.js +11 -7
- package/lib/victory-util/common-props.js +4 -2
- package/lib/victory-util/data.js +13 -7
- package/lib/victory-util/default-transitions.js +1 -1
- package/lib/victory-util/domain.js +11 -5
- package/lib/victory-util/events.js +17 -11
- package/lib/victory-util/helpers.js +14 -14
- package/lib/victory-util/hooks/index.js +4 -4
- package/lib/victory-util/hooks/use-animation-state.js +14 -6
- package/lib/victory-util/immutable.js +3 -3
- package/lib/victory-util/label-helpers.js +6 -4
- package/lib/victory-util/line-helpers.js +4 -2
- package/lib/victory-util/prop-types.js +5 -3
- package/lib/victory-util/scale.js +24 -21
- package/lib/victory-util/selection.js +6 -4
- package/lib/victory-util/textsize.js +12 -8
- package/lib/victory-util/timer-context.js +1 -1
- package/lib/victory-util/timer.js +3 -5
- package/lib/victory-util/user-props.js +31 -4
- package/lib/victory-util/wrapper.js +31 -23
- package/package.json +4 -11
- package/src/victory-animation/util.js +1 -1
- package/src/victory-animation/victory-animation.js +1 -1
- package/src/victory-label/victory-label.js +6 -6
- package/src/victory-util/axis.js +3 -0
- package/src/victory-util/line-helpers.js +1 -1
- package/src/victory-util/scale.js +18 -9
- package/src/victory-util/timer.js +1 -1
- package/src/victory-util/user-props.js +18 -1
|
@@ -8,26 +8,38 @@ import _keys from "lodash/keys";
|
|
|
8
8
|
import _assign from "lodash/assign";
|
|
9
9
|
import _defaults from "lodash/defaults";
|
|
10
10
|
|
|
11
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
12
|
|
|
13
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
14
|
|
|
15
|
-
function
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
16
|
|
|
17
|
-
function
|
|
17
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
|
+
|
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
+
|
|
21
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
22
|
|
|
19
23
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
24
|
|
|
21
25
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
22
26
|
|
|
23
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
27
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
28
|
+
|
|
29
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
24
30
|
|
|
25
|
-
function
|
|
31
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
26
32
|
|
|
27
|
-
function
|
|
33
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
34
|
+
|
|
35
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
28
36
|
|
|
29
37
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
38
|
|
|
39
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
40
|
+
|
|
41
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
42
|
+
|
|
31
43
|
/*global window:false */
|
|
32
44
|
import React from "react";
|
|
33
45
|
import * as Events from "./events";
|
|
@@ -49,365 +61,362 @@ var defaultComponents = [{
|
|
|
49
61
|
name: "labels"
|
|
50
62
|
}];
|
|
51
63
|
export default (function (WrappedComponent, options) {
|
|
52
|
-
return (
|
|
53
|
-
|
|
54
|
-
function (_WrappedComponent) {
|
|
55
|
-
_inherits(addEvents, _WrappedComponent);
|
|
64
|
+
return /*#__PURE__*/function (_WrappedComponent) {
|
|
65
|
+
_inherits(addEvents, _WrappedComponent);
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
var _this;
|
|
67
|
+
var _super = _createSuper(addEvents);
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
function addEvents(props) {
|
|
70
|
+
var _this;
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
|
|
64
|
-
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
|
|
65
|
-
_this.state = {};
|
|
72
|
+
_classCallCheck(this, addEvents);
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
_this = _super.call(this, props);
|
|
75
|
+
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
|
|
76
|
+
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
|
|
77
|
+
_this.state = {};
|
|
70
78
|
|
|
71
|
-
|
|
79
|
+
_this.getEvents = function (p, target, eventKey) {
|
|
80
|
+
return boundGetEvents(p, target, eventKey, getScopedEvents);
|
|
81
|
+
};
|
|
72
82
|
|
|
73
|
-
|
|
83
|
+
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
|
|
74
84
|
|
|
75
|
-
|
|
85
|
+
var calculatedValues = _this.getCalculatedValues(props);
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
_this.calculatedState = _this.getStateChanges(props);
|
|
79
|
-
_this.globalEvents = {};
|
|
80
|
-
_this.prevGlobalEventKeys = [];
|
|
81
|
-
_this.boundGlobalEvents = {};
|
|
82
|
-
return _this;
|
|
83
|
-
}
|
|
87
|
+
_this.cacheValues(calculatedValues);
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (animating || newMutation) {
|
|
93
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
94
|
-
this.externalMutations = externalMutations;
|
|
95
|
-
this.applyExternalMutations(nextProps, externalMutations);
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
89
|
+
_this.externalMutations = _this.getExternalMutations(props);
|
|
90
|
+
_this.calculatedState = _this.getStateChanges(props);
|
|
91
|
+
_this.globalEvents = {};
|
|
92
|
+
_this.prevGlobalEventKeys = [];
|
|
93
|
+
_this.boundGlobalEvents = {};
|
|
94
|
+
return _this;
|
|
95
|
+
}
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
_createClass(addEvents, [{
|
|
98
|
+
key: "shouldComponentUpdate",
|
|
99
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
100
|
+
var externalMutations = this.getExternalMutations(nextProps);
|
|
101
|
+
var animating = this.props.animating || this.props.animate;
|
|
102
|
+
var newMutation = !isEqual(externalMutations, this.externalMutations);
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (animating || newMutation) {
|
|
105
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
106
|
+
this.externalMutations = externalMutations;
|
|
107
|
+
this.applyExternalMutations(nextProps, externalMutations);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
105
110
|
|
|
106
|
-
|
|
107
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
111
|
+
var calculatedState = this.getStateChanges(nextProps);
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
if (!isEqual(this.calculatedState, calculatedState)) {
|
|
114
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
115
|
+
return true;
|
|
112
116
|
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "componentDidMount",
|
|
115
|
-
value: function componentDidMount() {
|
|
116
|
-
var _this2 = this;
|
|
117
|
-
|
|
118
|
-
var globalEventKeys = _keys(this.globalEvents);
|
|
119
117
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.prevGlobalEventKeys = globalEventKeys;
|
|
118
|
+
if (!isEqual(this.props, nextProps)) {
|
|
119
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
120
|
+
return true;
|
|
124
121
|
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "componentDidUpdate",
|
|
127
|
-
value: function componentDidUpdate(prevProps) {
|
|
128
|
-
var _this3 = this;
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "componentDidMount",
|
|
127
|
+
value: function componentDidMount() {
|
|
128
|
+
var _this2 = this;
|
|
132
129
|
|
|
133
|
-
|
|
130
|
+
var globalEventKeys = _keys(this.globalEvents);
|
|
134
131
|
|
|
135
|
-
|
|
132
|
+
globalEventKeys.forEach(function (key) {
|
|
133
|
+
return _this2.addGlobalListener(key);
|
|
134
|
+
});
|
|
135
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "componentDidUpdate",
|
|
139
|
+
value: function componentDidUpdate(prevProps) {
|
|
140
|
+
var _this3 = this;
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
142
|
+
var calculatedState = this.getStateChanges(prevProps);
|
|
143
|
+
this.calculatedState = calculatedState;
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
var globalEventKeys = _keys(this.globalEvents);
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
return _this3.addGlobalListener(key);
|
|
145
|
-
});
|
|
146
|
-
this.prevGlobalEventKeys = globalEventKeys;
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "componentWillUnmount",
|
|
150
|
-
value: function componentWillUnmount() {
|
|
151
|
-
var _this4 = this;
|
|
147
|
+
var removedGlobalEventKeys = _difference(this.prevGlobalEventKeys, globalEventKeys);
|
|
152
148
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
}, {
|
|
158
|
-
key: "addGlobalListener",
|
|
159
|
-
value: function addGlobalListener(key) {
|
|
160
|
-
var _this5 = this;
|
|
161
|
-
|
|
162
|
-
var boundListener = function (event) {
|
|
163
|
-
var listener = _this5.globalEvents[key];
|
|
164
|
-
return listener && listener(Events.emulateReactEvent(event));
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
this.boundGlobalEvents[key] = boundListener;
|
|
168
|
-
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
|
|
169
|
-
}
|
|
170
|
-
}, {
|
|
171
|
-
key: "removeGlobalListener",
|
|
172
|
-
value: function removeGlobalListener(key) {
|
|
173
|
-
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
|
|
174
|
-
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
175
|
-
// state change should trigger a re-render
|
|
176
|
-
|
|
177
|
-
}, {
|
|
178
|
-
key: "getStateChanges",
|
|
179
|
-
value: function getStateChanges(props) {
|
|
180
|
-
var _this6 = this;
|
|
181
|
-
|
|
182
|
-
if (!this.hasEvents) {
|
|
183
|
-
return {};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
var getState = function (key, type) {
|
|
187
|
-
var result = _defaults({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
|
|
188
|
-
|
|
189
|
-
return _isEmpty(result) ? undefined : result;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
options = options || {};
|
|
193
|
-
var components = options.components || defaultComponents;
|
|
194
|
-
var stateChanges = components.map(function (component) {
|
|
195
|
-
if (!props.standalone && component.name === "parent") {
|
|
196
|
-
// don't check for changes on parent props for non-standalone components
|
|
197
|
-
return undefined;
|
|
198
|
-
} else {
|
|
199
|
-
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
200
|
-
return getState(key, component.name);
|
|
201
|
-
}).filter(Boolean);
|
|
202
|
-
}
|
|
203
|
-
}).filter(Boolean);
|
|
204
|
-
return stateChanges;
|
|
205
|
-
}
|
|
206
|
-
}, {
|
|
207
|
-
key: "applyExternalMutations",
|
|
208
|
-
value: function applyExternalMutations(props, externalMutations) {
|
|
209
|
-
if (!_isEmpty(externalMutations)) {
|
|
210
|
-
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
211
|
-
memo = _isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
212
|
-
return memo;
|
|
213
|
-
}, []);
|
|
214
|
-
var compiledCallbacks = callbacks.length ? function () {
|
|
215
|
-
callbacks.forEach(function (c) {
|
|
216
|
-
return c();
|
|
217
|
-
});
|
|
218
|
-
} : undefined;
|
|
219
|
-
this.setState(externalMutations, compiledCallbacks);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}, {
|
|
223
|
-
key: "getCalculatedValues",
|
|
224
|
-
value: function getCalculatedValues(props) {
|
|
225
|
-
var sharedEvents = props.sharedEvents;
|
|
226
|
-
var components = WrappedComponent.expectedComponents;
|
|
227
|
-
var componentEvents = Events.getComponentEvents(props, components);
|
|
228
|
-
var getSharedEventState = sharedEvents && _isFunction(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
|
|
229
|
-
return undefined;
|
|
230
|
-
};
|
|
231
|
-
var baseProps = this.getBaseProps(props, getSharedEventState);
|
|
149
|
+
removedGlobalEventKeys.forEach(function (key) {
|
|
150
|
+
return _this3.removeGlobalListener(key);
|
|
151
|
+
});
|
|
232
152
|
|
|
233
|
-
|
|
234
|
-
return key !== "parent";
|
|
235
|
-
});
|
|
153
|
+
var addedGlobalEventKeys = _difference(globalEventKeys, this.prevGlobalEventKeys);
|
|
236
154
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
155
|
+
addedGlobalEventKeys.forEach(function (key) {
|
|
156
|
+
return _this3.addGlobalListener(key);
|
|
157
|
+
});
|
|
158
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "componentWillUnmount",
|
|
162
|
+
value: function componentWillUnmount() {
|
|
163
|
+
var _this4 = this;
|
|
164
|
+
|
|
165
|
+
this.prevGlobalEventKeys.forEach(function (key) {
|
|
166
|
+
return _this4.removeGlobalListener(key);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "addGlobalListener",
|
|
171
|
+
value: function addGlobalListener(key) {
|
|
172
|
+
var _this5 = this;
|
|
173
|
+
|
|
174
|
+
var boundListener = function (event) {
|
|
175
|
+
var listener = _this5.globalEvents[key];
|
|
176
|
+
return listener && listener(Events.emulateReactEvent(event));
|
|
177
|
+
};
|
|
259
178
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
179
|
+
this.boundGlobalEvents[key] = boundListener;
|
|
180
|
+
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "removeGlobalListener",
|
|
184
|
+
value: function removeGlobalListener(key) {
|
|
185
|
+
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
|
|
186
|
+
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
187
|
+
// state change should trigger a re-render
|
|
188
|
+
|
|
189
|
+
}, {
|
|
190
|
+
key: "getStateChanges",
|
|
191
|
+
value: function getStateChanges(props) {
|
|
192
|
+
var _this6 = this;
|
|
193
|
+
|
|
194
|
+
if (!this.hasEvents) {
|
|
195
|
+
return {};
|
|
263
196
|
}
|
|
264
|
-
}, {
|
|
265
|
-
key: "getBaseProps",
|
|
266
|
-
value: function getBaseProps(props, getSharedEventState) {
|
|
267
|
-
getSharedEventState = getSharedEventState || this.getSharedEventState;
|
|
268
|
-
var sharedParentState = getSharedEventState("parent", "parent");
|
|
269
|
-
var parentState = this.getEventState("parent", "parent");
|
|
270
|
-
|
|
271
|
-
var baseParentProps = _defaults({}, parentState, sharedParentState);
|
|
272
197
|
|
|
273
|
-
|
|
274
|
-
var
|
|
198
|
+
var getState = function (key, type) {
|
|
199
|
+
var result = _defaults({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
|
|
275
200
|
|
|
276
|
-
|
|
201
|
+
return _isEmpty(result) ? undefined : result;
|
|
202
|
+
};
|
|
277
203
|
|
|
278
|
-
|
|
204
|
+
options = options || {};
|
|
205
|
+
var components = options.components || defaultComponents;
|
|
206
|
+
var stateChanges = components.map(function (component) {
|
|
207
|
+
if (!props.standalone && component.name === "parent") {
|
|
208
|
+
// don't check for changes on parent props for non-standalone components
|
|
209
|
+
return undefined;
|
|
210
|
+
} else {
|
|
211
|
+
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
212
|
+
return getState(key, component.name);
|
|
213
|
+
}).filter(Boolean);
|
|
214
|
+
}
|
|
215
|
+
}).filter(Boolean);
|
|
216
|
+
return stateChanges;
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
219
|
+
key: "applyExternalMutations",
|
|
220
|
+
value: function applyExternalMutations(props, externalMutations) {
|
|
221
|
+
if (!_isEmpty(externalMutations)) {
|
|
222
|
+
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
223
|
+
memo = _isFunction(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);
|
|
279
232
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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 && _isFunction(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
|
|
241
|
+
return undefined;
|
|
242
|
+
};
|
|
243
|
+
var baseProps = this.getBaseProps(props, getSharedEventState);
|
|
244
|
+
|
|
245
|
+
var dataKeys = _keys(baseProps).filter(function (key) {
|
|
246
|
+
return key !== "parent";
|
|
247
|
+
});
|
|
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 _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "cacheValues",
|
|
269
|
+
value: function cacheValues(obj) {
|
|
270
|
+
var _this7 = this;
|
|
271
|
+
|
|
272
|
+
_keys(obj).forEach(function (key) {
|
|
273
|
+
_this7[key] = obj[key];
|
|
274
|
+
});
|
|
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");
|
|
285
282
|
|
|
286
|
-
|
|
287
|
-
}
|
|
283
|
+
var baseParentProps = _defaults({}, parentState, sharedParentState);
|
|
288
284
|
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
key: "getComponentProps",
|
|
293
|
-
value: function getComponentProps(component, type, index) {
|
|
294
|
-
var name = this.props.name || WrappedComponent.role;
|
|
295
|
-
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
296
|
-
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
297
|
-
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
298
|
-
|
|
299
|
-
if (!baseProps && !this.hasEvents) {
|
|
300
|
-
return undefined;
|
|
301
|
-
}
|
|
285
|
+
var parentPropsList = baseParentProps.parentControlledProps;
|
|
286
|
+
var parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
|
|
302
287
|
|
|
303
|
-
|
|
304
|
-
var baseEvents = this.getEvents(this.props, type, key);
|
|
288
|
+
var modifiedProps = _defaults({}, parentProps, props);
|
|
305
289
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
290
|
+
return _isFunction(WrappedComponent.getBaseProps) ? WrappedComponent.getBaseProps(modifiedProps) : {};
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
key: "getAllEvents",
|
|
294
|
+
value: function getAllEvents(props) {
|
|
295
|
+
if (Array.isArray(this.componentEvents)) {
|
|
296
|
+
var _this$componentEvents;
|
|
312
297
|
|
|
313
|
-
|
|
298
|
+
return Array.isArray(props.events) ? (_this$componentEvents = this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
|
|
299
|
+
}
|
|
314
300
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
301
|
+
return props.events;
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "getComponentProps",
|
|
305
|
+
value: function getComponentProps(component, type, index) {
|
|
306
|
+
var name = this.props.name || WrappedComponent.role;
|
|
307
|
+
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
308
|
+
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
309
|
+
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
310
|
+
|
|
311
|
+
if (!baseProps && !this.hasEvents) {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (this.hasEvents) {
|
|
316
|
+
var baseEvents = this.getEvents(this.props, type, key);
|
|
319
317
|
|
|
320
|
-
|
|
318
|
+
var componentProps = _defaults({
|
|
321
319
|
index: index,
|
|
322
320
|
key: id
|
|
323
|
-
}, component.props, baseProps, {
|
|
321
|
+
}, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
|
|
324
322
|
id: id
|
|
325
323
|
});
|
|
326
|
-
}
|
|
327
|
-
}, {
|
|
328
|
-
key: "renderContainer",
|
|
329
|
-
value: function renderContainer(component, children) {
|
|
330
|
-
var isContainer = component.type && component.type.role === "container";
|
|
331
|
-
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
332
|
-
|
|
333
|
-
if (parentProps.events) {
|
|
334
|
-
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
335
|
-
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
336
|
-
}
|
|
337
324
|
|
|
338
|
-
|
|
325
|
+
var events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
|
|
326
|
+
|
|
327
|
+
return _assign({}, componentProps, {
|
|
328
|
+
events: events
|
|
329
|
+
});
|
|
339
330
|
}
|
|
340
|
-
}, {
|
|
341
|
-
key: "animateComponent",
|
|
342
|
-
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
343
|
-
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
344
|
-
return React.createElement(VictoryTransition, {
|
|
345
|
-
animate: props.animate,
|
|
346
|
-
animationWhitelist: animationWhitelist
|
|
347
|
-
}, React.createElement(this.constructor, props));
|
|
348
|
-
} // Used by `VictoryLine` and `VictoryArea`
|
|
349
|
-
|
|
350
|
-
}, {
|
|
351
|
-
key: "renderContinuousData",
|
|
352
|
-
value: function renderContinuousData(props) {
|
|
353
|
-
var _this8 = this;
|
|
354
|
-
|
|
355
|
-
var dataComponent = props.dataComponent,
|
|
356
|
-
labelComponent = props.labelComponent,
|
|
357
|
-
groupComponent = props.groupComponent;
|
|
358
|
-
|
|
359
|
-
var dataKeys = _without(this.dataKeys, "all");
|
|
360
|
-
|
|
361
|
-
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
362
|
-
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
363
|
-
|
|
364
|
-
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
365
|
-
memo = memo.concat(React.cloneElement(labelComponent, labelProps));
|
|
366
|
-
}
|
|
367
331
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
332
|
+
return _defaults({
|
|
333
|
+
index: index,
|
|
334
|
+
key: id
|
|
335
|
+
}, component.props, baseProps, {
|
|
336
|
+
id: id
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
key: "renderContainer",
|
|
341
|
+
value: function renderContainer(component, children) {
|
|
342
|
+
var isContainer = component.type && component.type.role === "container";
|
|
343
|
+
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
344
|
+
|
|
345
|
+
if (parentProps.events) {
|
|
346
|
+
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
347
|
+
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
373
348
|
}
|
|
374
|
-
}, {
|
|
375
|
-
key: "renderData",
|
|
376
|
-
value: function renderData(props) {
|
|
377
|
-
var _this9 = this;
|
|
378
|
-
|
|
379
|
-
var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
|
|
380
|
-
var dataComponent = props.dataComponent,
|
|
381
|
-
labelComponent = props.labelComponent,
|
|
382
|
-
groupComponent = props.groupComponent;
|
|
383
|
-
var userProps = UserProps.getSafeUserProps(props);
|
|
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.cloneElement(dataComponent, dataProps));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
return validDataComponents;
|
|
392
|
-
}, []);
|
|
393
|
-
var labelComponents = this.dataKeys.map(function (_dataKey, index) {
|
|
394
|
-
var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
|
|
395
349
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
350
|
+
return /*#__PURE__*/React.cloneElement(component, parentProps, children);
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
key: "animateComponent",
|
|
354
|
+
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
355
|
+
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
356
|
+
return /*#__PURE__*/React.createElement(VictoryTransition, {
|
|
357
|
+
animate: props.animate,
|
|
358
|
+
animationWhitelist: animationWhitelist
|
|
359
|
+
}, /*#__PURE__*/React.createElement(this.constructor, props));
|
|
360
|
+
} // Used by `VictoryLine` and `VictoryArea`
|
|
361
|
+
|
|
362
|
+
}, {
|
|
363
|
+
key: "renderContinuousData",
|
|
364
|
+
value: function renderContinuousData(props) {
|
|
365
|
+
var _this8 = this;
|
|
366
|
+
|
|
367
|
+
var dataComponent = props.dataComponent,
|
|
368
|
+
labelComponent = props.labelComponent,
|
|
369
|
+
groupComponent = props.groupComponent;
|
|
370
|
+
|
|
371
|
+
var dataKeys = _without(this.dataKeys, "all");
|
|
372
|
+
|
|
373
|
+
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
374
|
+
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
375
|
+
|
|
376
|
+
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
377
|
+
memo = memo.concat( /*#__PURE__*/React.cloneElement(labelComponent, labelProps));
|
|
378
|
+
}
|
|
399
379
|
|
|
400
|
-
|
|
401
|
-
|
|
380
|
+
return memo;
|
|
381
|
+
}, []);
|
|
382
|
+
var dataProps = this.getComponentProps(dataComponent, "data", "all");
|
|
383
|
+
var children = [/*#__PURE__*/React.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
|
|
384
|
+
return this.renderContainer(groupComponent, children);
|
|
385
|
+
}
|
|
386
|
+
}, {
|
|
387
|
+
key: "renderData",
|
|
388
|
+
value: function renderData(props) {
|
|
389
|
+
var _this9 = this;
|
|
390
|
+
|
|
391
|
+
var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
|
|
392
|
+
var dataComponent = props.dataComponent,
|
|
393
|
+
labelComponent = props.labelComponent,
|
|
394
|
+
groupComponent = props.groupComponent;
|
|
395
|
+
var userProps = UserProps.getSafeUserProps(props);
|
|
396
|
+
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
397
|
+
var dataProps = _this9.getComponentProps(dataComponent, "data", index);
|
|
398
|
+
|
|
399
|
+
if (shouldRenderDatum(dataProps.datum)) {
|
|
400
|
+
validDataComponents.push( /*#__PURE__*/React.cloneElement(dataComponent, dataProps));
|
|
401
|
+
}
|
|
402
402
|
|
|
403
|
-
|
|
403
|
+
return validDataComponents;
|
|
404
|
+
}, []);
|
|
405
|
+
var labelComponents = this.dataKeys.map(function (_dataKey, index) {
|
|
406
|
+
var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
|
|
404
407
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
409
|
+
return /*#__PURE__*/React.cloneElement(labelComponent, labelProps);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return undefined;
|
|
413
|
+
}).filter(Boolean);
|
|
414
|
+
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
|
|
415
|
+
var group = /*#__PURE__*/React.cloneElement(groupComponent, userProps, children);
|
|
416
|
+
return this.renderContainer(group, children);
|
|
417
|
+
}
|
|
418
|
+
}]);
|
|
409
419
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
);
|
|
420
|
+
return addEvents;
|
|
421
|
+
}(WrappedComponent);
|
|
413
422
|
});
|