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