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