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
|
@@ -33,30 +33,44 @@ var _victoryTransition = _interopRequireDefault(require("../victory-transition/v
|
|
|
33
33
|
|
|
34
34
|
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
39
|
|
|
38
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
41
|
|
|
40
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
42
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
43
|
+
|
|
44
|
+
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."); }
|
|
45
|
+
|
|
46
|
+
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); }
|
|
41
47
|
|
|
42
|
-
function
|
|
48
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
49
|
|
|
44
|
-
function
|
|
50
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
51
|
|
|
46
|
-
function
|
|
52
|
+
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; }
|
|
47
53
|
|
|
48
54
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
49
55
|
|
|
50
56
|
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); } }
|
|
51
57
|
|
|
52
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
59
|
+
|
|
60
|
+
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); }
|
|
61
|
+
|
|
62
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
53
63
|
|
|
54
|
-
function
|
|
64
|
+
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); }; }
|
|
55
65
|
|
|
56
|
-
function
|
|
66
|
+
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); }
|
|
57
67
|
|
|
58
68
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
59
69
|
|
|
70
|
+
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; } }
|
|
71
|
+
|
|
72
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
73
|
+
|
|
60
74
|
var datumHasXandY = function (datum) {
|
|
61
75
|
return !(0, _isNil2.default)(datum._x) && !(0, _isNil2.default)(datum._y);
|
|
62
76
|
}; // used for checking state changes. Expected components can be passed in via options
|
|
@@ -72,350 +86,348 @@ var defaultComponents = [{
|
|
|
72
86
|
}];
|
|
73
87
|
|
|
74
88
|
var _default = function _default(WrappedComponent, options) {
|
|
75
|
-
return (
|
|
76
|
-
|
|
77
|
-
function (_WrappedComponent) {
|
|
78
|
-
_inherits(addEvents, _WrappedComponent);
|
|
89
|
+
return /*#__PURE__*/function (_WrappedComponent) {
|
|
90
|
+
_inherits(addEvents, _WrappedComponent);
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
var _this;
|
|
92
|
+
var _super = _createSuper(addEvents);
|
|
82
93
|
|
|
83
|
-
|
|
94
|
+
function addEvents(props) {
|
|
95
|
+
var _this;
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
|
|
87
|
-
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
|
|
88
|
-
_this.state = {};
|
|
97
|
+
_classCallCheck(this, addEvents);
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
_this = _super.call(this, props);
|
|
100
|
+
var getScopedEvents = Events.getScopedEvents.bind(_assertThisInitialized(_this));
|
|
101
|
+
var boundGetEvents = Events.getEvents.bind(_assertThisInitialized(_this));
|
|
102
|
+
_this.state = {};
|
|
93
103
|
|
|
94
|
-
|
|
104
|
+
_this.getEvents = function (p, target, eventKey) {
|
|
105
|
+
return boundGetEvents(p, target, eventKey, getScopedEvents);
|
|
106
|
+
};
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
_this.getEventState = Events.getEventState.bind(_assertThisInitialized(_this));
|
|
97
109
|
|
|
98
|
-
|
|
110
|
+
var calculatedValues = _this.getCalculatedValues(props);
|
|
99
111
|
|
|
100
|
-
|
|
101
|
-
_this.calculatedState = _this.getStateChanges(props);
|
|
102
|
-
_this.globalEvents = {};
|
|
103
|
-
_this.prevGlobalEventKeys = [];
|
|
104
|
-
_this.boundGlobalEvents = {};
|
|
105
|
-
return _this;
|
|
106
|
-
}
|
|
112
|
+
_this.cacheValues(calculatedValues);
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (animating || newMutation) {
|
|
116
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
117
|
-
this.externalMutations = externalMutations;
|
|
118
|
-
this.applyExternalMutations(nextProps, externalMutations);
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
114
|
+
_this.externalMutations = _this.getExternalMutations(props);
|
|
115
|
+
_this.calculatedState = _this.getStateChanges(props);
|
|
116
|
+
_this.globalEvents = {};
|
|
117
|
+
_this.prevGlobalEventKeys = [];
|
|
118
|
+
_this.boundGlobalEvents = {};
|
|
119
|
+
return _this;
|
|
120
|
+
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
_createClass(addEvents, [{
|
|
123
|
+
key: "shouldComponentUpdate",
|
|
124
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
125
|
+
var externalMutations = this.getExternalMutations(nextProps);
|
|
126
|
+
var animating = this.props.animating || this.props.animate;
|
|
127
|
+
var newMutation = !(0, _reactFastCompare.default)(externalMutations, this.externalMutations);
|
|
123
128
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
if (animating || newMutation) {
|
|
130
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
131
|
+
this.externalMutations = externalMutations;
|
|
132
|
+
this.applyExternalMutations(nextProps, externalMutations);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
128
135
|
|
|
129
|
-
|
|
130
|
-
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
136
|
+
var calculatedState = this.getStateChanges(nextProps);
|
|
133
137
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
key: "componentDidMount",
|
|
138
|
-
value: function componentDidMount() {
|
|
139
|
-
var _this2 = this;
|
|
140
|
-
|
|
141
|
-
var globalEventKeys = (0, _keys2.default)(this.globalEvents);
|
|
142
|
-
globalEventKeys.forEach(function (key) {
|
|
143
|
-
return _this2.addGlobalListener(key);
|
|
144
|
-
});
|
|
145
|
-
this.prevGlobalEventKeys = globalEventKeys;
|
|
138
|
+
if (!(0, _reactFastCompare.default)(this.calculatedState, calculatedState)) {
|
|
139
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
140
|
+
return true;
|
|
146
141
|
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "componentDidUpdate",
|
|
149
|
-
value: function componentDidUpdate(prevProps) {
|
|
150
|
-
var _this3 = this;
|
|
151
|
-
|
|
152
|
-
var calculatedState = this.getStateChanges(prevProps);
|
|
153
|
-
this.calculatedState = calculatedState;
|
|
154
|
-
var globalEventKeys = (0, _keys2.default)(this.globalEvents);
|
|
155
|
-
var removedGlobalEventKeys = (0, _difference2.default)(this.prevGlobalEventKeys, globalEventKeys);
|
|
156
|
-
removedGlobalEventKeys.forEach(function (key) {
|
|
157
|
-
return _this3.removeGlobalListener(key);
|
|
158
|
-
});
|
|
159
|
-
var addedGlobalEventKeys = (0, _difference2.default)(globalEventKeys, this.prevGlobalEventKeys);
|
|
160
|
-
addedGlobalEventKeys.forEach(function (key) {
|
|
161
|
-
return _this3.addGlobalListener(key);
|
|
162
|
-
});
|
|
163
|
-
this.prevGlobalEventKeys = globalEventKeys;
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "componentWillUnmount",
|
|
167
|
-
value: function componentWillUnmount() {
|
|
168
|
-
var _this4 = this;
|
|
169
142
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
143
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
144
|
+
this.cacheValues(this.getCalculatedValues(nextProps));
|
|
145
|
+
return true;
|
|
173
146
|
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "addGlobalListener",
|
|
176
|
-
value: function addGlobalListener(key) {
|
|
177
|
-
var _this5 = this;
|
|
178
|
-
|
|
179
|
-
var boundListener = function (event) {
|
|
180
|
-
var listener = _this5.globalEvents[key];
|
|
181
|
-
return listener && listener(Events.emulateReactEvent(event));
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
this.boundGlobalEvents[key] = boundListener;
|
|
185
|
-
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
key: "removeGlobalListener",
|
|
189
|
-
value: function removeGlobalListener(key) {
|
|
190
|
-
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
|
|
191
|
-
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
192
|
-
// state change should trigger a re-render
|
|
193
|
-
|
|
194
|
-
}, {
|
|
195
|
-
key: "getStateChanges",
|
|
196
|
-
value: function getStateChanges(props) {
|
|
197
|
-
var _this6 = this;
|
|
198
|
-
|
|
199
|
-
if (!this.hasEvents) {
|
|
200
|
-
return {};
|
|
201
|
-
}
|
|
202
147
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
key
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
var events = this.getAllEvents(props);
|
|
253
|
-
return {
|
|
254
|
-
componentEvents: componentEvents,
|
|
255
|
-
getSharedEventState: getSharedEventState,
|
|
256
|
-
baseProps: baseProps,
|
|
257
|
-
dataKeys: dataKeys,
|
|
258
|
-
hasEvents: hasEvents,
|
|
259
|
-
events: events
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
}, {
|
|
263
|
-
key: "getExternalMutations",
|
|
264
|
-
value: function getExternalMutations(props) {
|
|
265
|
-
var sharedEvents = props.sharedEvents,
|
|
266
|
-
externalEventMutations = props.externalEventMutations;
|
|
267
|
-
return (0, _isEmpty2.default)(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
|
|
268
|
-
}
|
|
269
|
-
}, {
|
|
270
|
-
key: "cacheValues",
|
|
271
|
-
value: function cacheValues(obj) {
|
|
272
|
-
var _this7 = this;
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "componentDidMount",
|
|
152
|
+
value: function componentDidMount() {
|
|
153
|
+
var _this2 = this;
|
|
154
|
+
|
|
155
|
+
var globalEventKeys = (0, _keys2.default)(this.globalEvents);
|
|
156
|
+
globalEventKeys.forEach(function (key) {
|
|
157
|
+
return _this2.addGlobalListener(key);
|
|
158
|
+
});
|
|
159
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "componentDidUpdate",
|
|
163
|
+
value: function componentDidUpdate(prevProps) {
|
|
164
|
+
var _this3 = this;
|
|
165
|
+
|
|
166
|
+
var calculatedState = this.getStateChanges(prevProps);
|
|
167
|
+
this.calculatedState = calculatedState;
|
|
168
|
+
var globalEventKeys = (0, _keys2.default)(this.globalEvents);
|
|
169
|
+
var removedGlobalEventKeys = (0, _difference2.default)(this.prevGlobalEventKeys, globalEventKeys);
|
|
170
|
+
removedGlobalEventKeys.forEach(function (key) {
|
|
171
|
+
return _this3.removeGlobalListener(key);
|
|
172
|
+
});
|
|
173
|
+
var addedGlobalEventKeys = (0, _difference2.default)(globalEventKeys, this.prevGlobalEventKeys);
|
|
174
|
+
addedGlobalEventKeys.forEach(function (key) {
|
|
175
|
+
return _this3.addGlobalListener(key);
|
|
176
|
+
});
|
|
177
|
+
this.prevGlobalEventKeys = globalEventKeys;
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
key: "componentWillUnmount",
|
|
181
|
+
value: function componentWillUnmount() {
|
|
182
|
+
var _this4 = this;
|
|
183
|
+
|
|
184
|
+
this.prevGlobalEventKeys.forEach(function (key) {
|
|
185
|
+
return _this4.removeGlobalListener(key);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "addGlobalListener",
|
|
190
|
+
value: function addGlobalListener(key) {
|
|
191
|
+
var _this5 = this;
|
|
192
|
+
|
|
193
|
+
var boundListener = function (event) {
|
|
194
|
+
var listener = _this5.globalEvents[key];
|
|
195
|
+
return listener && listener(Events.emulateReactEvent(event));
|
|
196
|
+
};
|
|
273
197
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
198
|
+
this.boundGlobalEvents[key] = boundListener;
|
|
199
|
+
window.addEventListener(Events.getGlobalEventNameFromKey(key), boundListener);
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "removeGlobalListener",
|
|
203
|
+
value: function removeGlobalListener(key) {
|
|
204
|
+
window.removeEventListener(Events.getGlobalEventNameFromKey(key), this.boundGlobalEvents[key]);
|
|
205
|
+
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
206
|
+
// state change should trigger a re-render
|
|
207
|
+
|
|
208
|
+
}, {
|
|
209
|
+
key: "getStateChanges",
|
|
210
|
+
value: function getStateChanges(props) {
|
|
211
|
+
var _this6 = this;
|
|
212
|
+
|
|
213
|
+
if (!this.hasEvents) {
|
|
214
|
+
return {};
|
|
289
215
|
}
|
|
290
|
-
}, {
|
|
291
|
-
key: "getAllEvents",
|
|
292
|
-
value: function getAllEvents(props) {
|
|
293
|
-
if (Array.isArray(this.componentEvents)) {
|
|
294
|
-
var _componentEvents;
|
|
295
216
|
|
|
296
|
-
|
|
297
|
-
}
|
|
217
|
+
var getState = function (key, type) {
|
|
218
|
+
var result = (0, _defaults2.default)({}, _this6.getEventState(key, type), _this6.getSharedEventState(key, type));
|
|
219
|
+
return (0, _isEmpty2.default)(result) ? undefined : result;
|
|
220
|
+
};
|
|
298
221
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var name = this.props.name || WrappedComponent.role;
|
|
305
|
-
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
306
|
-
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
307
|
-
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
308
|
-
|
|
309
|
-
if (!baseProps && !this.hasEvents) {
|
|
222
|
+
options = options || {};
|
|
223
|
+
var components = options.components || defaultComponents;
|
|
224
|
+
var stateChanges = components.map(function (component) {
|
|
225
|
+
if (!props.standalone && component.name === "parent") {
|
|
226
|
+
// don't check for changes on parent props for non-standalone components
|
|
310
227
|
return undefined;
|
|
228
|
+
} else {
|
|
229
|
+
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
230
|
+
return getState(key, component.name);
|
|
231
|
+
}).filter(Boolean);
|
|
311
232
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
233
|
+
}).filter(Boolean);
|
|
234
|
+
return stateChanges;
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "applyExternalMutations",
|
|
238
|
+
value: function applyExternalMutations(props, externalMutations) {
|
|
239
|
+
if (!(0, _isEmpty2.default)(externalMutations)) {
|
|
240
|
+
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
241
|
+
memo = (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
242
|
+
return memo;
|
|
243
|
+
}, []);
|
|
244
|
+
var compiledCallbacks = callbacks.length ? function () {
|
|
245
|
+
callbacks.forEach(function (c) {
|
|
246
|
+
return c();
|
|
324
247
|
});
|
|
325
|
-
}
|
|
248
|
+
} : undefined;
|
|
249
|
+
this.setState(externalMutations, compiledCallbacks);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
253
|
+
key: "getCalculatedValues",
|
|
254
|
+
value: function getCalculatedValues(props) {
|
|
255
|
+
var sharedEvents = props.sharedEvents;
|
|
256
|
+
var components = WrappedComponent.expectedComponents;
|
|
257
|
+
var componentEvents = Events.getComponentEvents(props, components);
|
|
258
|
+
var getSharedEventState = sharedEvents && (0, _isFunction2.default)(sharedEvents.getEventState) ? sharedEvents.getEventState : function () {
|
|
259
|
+
return undefined;
|
|
260
|
+
};
|
|
261
|
+
var baseProps = this.getBaseProps(props, getSharedEventState);
|
|
262
|
+
var dataKeys = (0, _keys2.default)(baseProps).filter(function (key) {
|
|
263
|
+
return key !== "parent";
|
|
264
|
+
});
|
|
265
|
+
var hasEvents = props.events || props.sharedEvents || componentEvents;
|
|
266
|
+
var events = this.getAllEvents(props);
|
|
267
|
+
return {
|
|
268
|
+
componentEvents: componentEvents,
|
|
269
|
+
getSharedEventState: getSharedEventState,
|
|
270
|
+
baseProps: baseProps,
|
|
271
|
+
dataKeys: dataKeys,
|
|
272
|
+
hasEvents: hasEvents,
|
|
273
|
+
events: events
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
key: "getExternalMutations",
|
|
278
|
+
value: function getExternalMutations(props) {
|
|
279
|
+
var sharedEvents = props.sharedEvents,
|
|
280
|
+
externalEventMutations = props.externalEventMutations;
|
|
281
|
+
return (0, _isEmpty2.default)(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "cacheValues",
|
|
285
|
+
value: function cacheValues(obj) {
|
|
286
|
+
var _this7 = this;
|
|
287
|
+
|
|
288
|
+
(0, _keys2.default)(obj).forEach(function (key) {
|
|
289
|
+
_this7[key] = obj[key];
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
key: "getBaseProps",
|
|
294
|
+
value: function getBaseProps(props, getSharedEventState) {
|
|
295
|
+
getSharedEventState = getSharedEventState || this.getSharedEventState;
|
|
296
|
+
var sharedParentState = getSharedEventState("parent", "parent");
|
|
297
|
+
var parentState = this.getEventState("parent", "parent");
|
|
298
|
+
var baseParentProps = (0, _defaults2.default)({}, parentState, sharedParentState);
|
|
299
|
+
var parentPropsList = baseParentProps.parentControlledProps;
|
|
300
|
+
var parentProps = parentPropsList ? (0, _pick2.default)(baseParentProps, parentPropsList) : {};
|
|
301
|
+
var modifiedProps = (0, _defaults2.default)({}, parentProps, props);
|
|
302
|
+
return (0, _isFunction2.default)(WrappedComponent.getBaseProps) ? WrappedComponent.getBaseProps(modifiedProps) : {};
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "getAllEvents",
|
|
306
|
+
value: function getAllEvents(props) {
|
|
307
|
+
if (Array.isArray(this.componentEvents)) {
|
|
308
|
+
var _this$componentEvents;
|
|
309
|
+
|
|
310
|
+
return Array.isArray(props.events) ? (_this$componentEvents = this.componentEvents).concat.apply(_this$componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return props.events;
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "getComponentProps",
|
|
317
|
+
value: function getComponentProps(component, type, index) {
|
|
318
|
+
var name = this.props.name || WrappedComponent.role;
|
|
319
|
+
var key = this.dataKeys && this.dataKeys[index] || index;
|
|
320
|
+
var id = "".concat(name, "-").concat(type, "-").concat(key);
|
|
321
|
+
var baseProps = this.baseProps[key] && this.baseProps[key][type] || this.baseProps[key];
|
|
322
|
+
|
|
323
|
+
if (!baseProps && !this.hasEvents) {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
326
|
|
|
327
|
-
|
|
327
|
+
if (this.hasEvents) {
|
|
328
|
+
var baseEvents = this.getEvents(this.props, type, key);
|
|
329
|
+
var componentProps = (0, _defaults2.default)({
|
|
328
330
|
index: index,
|
|
329
331
|
key: id
|
|
330
|
-
}, component.props, baseProps, {
|
|
332
|
+
}, this.getEventState(key, type), this.getSharedEventState(key, type), component.props, baseProps, {
|
|
331
333
|
id: id
|
|
332
334
|
});
|
|
335
|
+
var events = (0, _defaults2.default)({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
|
|
336
|
+
return (0, _assign2.default)({}, componentProps, {
|
|
337
|
+
events: events
|
|
338
|
+
});
|
|
333
339
|
}
|
|
334
|
-
}, {
|
|
335
|
-
key: "renderContainer",
|
|
336
|
-
value: function renderContainer(component, children) {
|
|
337
|
-
var isContainer = component.type && component.type.role === "container";
|
|
338
|
-
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
339
|
-
|
|
340
|
-
if (parentProps.events) {
|
|
341
|
-
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
342
|
-
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
343
|
-
}
|
|
344
340
|
|
|
345
|
-
|
|
341
|
+
return (0, _defaults2.default)({
|
|
342
|
+
index: index,
|
|
343
|
+
key: id
|
|
344
|
+
}, component.props, baseProps, {
|
|
345
|
+
id: id
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
key: "renderContainer",
|
|
350
|
+
value: function renderContainer(component, children) {
|
|
351
|
+
var isContainer = component.type && component.type.role === "container";
|
|
352
|
+
var parentProps = isContainer ? this.getComponentProps(component, "parent", "parent") : {};
|
|
353
|
+
|
|
354
|
+
if (parentProps.events) {
|
|
355
|
+
this.globalEvents = Events.getGlobalEvents(parentProps.events);
|
|
356
|
+
parentProps.events = Events.omitGlobalEvents(parentProps.events);
|
|
346
357
|
}
|
|
347
|
-
}, {
|
|
348
|
-
key: "animateComponent",
|
|
349
|
-
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
350
|
-
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
351
|
-
return _react.default.createElement(_victoryTransition.default, {
|
|
352
|
-
animate: props.animate,
|
|
353
|
-
animationWhitelist: animationWhitelist
|
|
354
|
-
}, _react.default.createElement(this.constructor, props));
|
|
355
|
-
} // Used by `VictoryLine` and `VictoryArea`
|
|
356
|
-
|
|
357
|
-
}, {
|
|
358
|
-
key: "renderContinuousData",
|
|
359
|
-
value: function renderContinuousData(props) {
|
|
360
|
-
var _this8 = this;
|
|
361
|
-
|
|
362
|
-
var dataComponent = props.dataComponent,
|
|
363
|
-
labelComponent = props.labelComponent,
|
|
364
|
-
groupComponent = props.groupComponent;
|
|
365
|
-
var dataKeys = (0, _without2.default)(this.dataKeys, "all");
|
|
366
|
-
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
367
|
-
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
368
|
-
|
|
369
|
-
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
370
|
-
memo = memo.concat(_react.default.cloneElement(labelComponent, labelProps));
|
|
371
|
-
}
|
|
372
358
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
359
|
+
return /*#__PURE__*/_react.default.cloneElement(component, parentProps, children);
|
|
360
|
+
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "animateComponent",
|
|
363
|
+
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
364
|
+
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
365
|
+
return /*#__PURE__*/_react.default.createElement(_victoryTransition.default, {
|
|
366
|
+
animate: props.animate,
|
|
367
|
+
animationWhitelist: animationWhitelist
|
|
368
|
+
}, /*#__PURE__*/_react.default.createElement(this.constructor, props));
|
|
369
|
+
} // Used by `VictoryLine` and `VictoryArea`
|
|
370
|
+
|
|
371
|
+
}, {
|
|
372
|
+
key: "renderContinuousData",
|
|
373
|
+
value: function renderContinuousData(props) {
|
|
374
|
+
var _this8 = this;
|
|
375
|
+
|
|
376
|
+
var dataComponent = props.dataComponent,
|
|
377
|
+
labelComponent = props.labelComponent,
|
|
378
|
+
groupComponent = props.groupComponent;
|
|
379
|
+
var dataKeys = (0, _without2.default)(this.dataKeys, "all");
|
|
380
|
+
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
381
|
+
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
382
|
+
|
|
383
|
+
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
384
|
+
memo = memo.concat( /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps));
|
|
385
|
+
}
|
|
400
386
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
387
|
+
return memo;
|
|
388
|
+
}, []);
|
|
389
|
+
var dataProps = this.getComponentProps(dataComponent, "data", "all");
|
|
390
|
+
var children = [/*#__PURE__*/_react.default.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
|
|
391
|
+
return this.renderContainer(groupComponent, children);
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "renderData",
|
|
395
|
+
value: function renderData(props) {
|
|
396
|
+
var _this9 = this;
|
|
397
|
+
|
|
398
|
+
var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
|
|
399
|
+
var dataComponent = props.dataComponent,
|
|
400
|
+
labelComponent = props.labelComponent,
|
|
401
|
+
groupComponent = props.groupComponent;
|
|
402
|
+
var userProps = UserProps.getSafeUserProps(props);
|
|
403
|
+
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
404
|
+
var dataProps = _this9.getComponentProps(dataComponent, "data", index);
|
|
405
|
+
|
|
406
|
+
if (shouldRenderDatum(dataProps.datum)) {
|
|
407
|
+
validDataComponents.push( /*#__PURE__*/_react.default.cloneElement(dataComponent, dataProps));
|
|
408
|
+
}
|
|
404
409
|
|
|
405
|
-
|
|
406
|
-
|
|
410
|
+
return validDataComponents;
|
|
411
|
+
}, []);
|
|
412
|
+
var labelComponents = this.dataKeys.map(function (_dataKey, index) {
|
|
413
|
+
var labelProps = _this9.getComponentProps(labelComponent, "labels", index);
|
|
407
414
|
|
|
408
|
-
|
|
415
|
+
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
416
|
+
return /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps);
|
|
417
|
+
}
|
|
409
418
|
|
|
410
|
-
|
|
419
|
+
return undefined;
|
|
420
|
+
}).filter(Boolean);
|
|
421
|
+
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
|
|
411
422
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
423
|
+
var group = /*#__PURE__*/_react.default.cloneElement(groupComponent, userProps, children);
|
|
424
|
+
|
|
425
|
+
return this.renderContainer(group, children);
|
|
426
|
+
}
|
|
427
|
+
}]);
|
|
415
428
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
);
|
|
429
|
+
return addEvents;
|
|
430
|
+
}(WrappedComponent);
|
|
419
431
|
};
|
|
420
432
|
|
|
421
433
|
exports.default = _default;
|