victory-core 37.3.1 → 37.3.3
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/CHANGELOG.md +20 -0
- package/dist/victory-core.js +436 -405
- package/dist/victory-core.min.js +1 -1
- package/es/types/callbacks.d.ts +11 -11
- package/es/types/prop-types.d.ts +28 -28
- package/es/victory-animation/util.js +7 -7
- package/es/victory-animation/victory-animation.d.ts +3 -3
- package/es/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/es/victory-clip-container/victory-clip-container.js +20 -12
- package/es/victory-container/victory-container.js +5 -5
- package/es/victory-label/victory-label.d.ts +3 -3
- package/es/victory-label/victory-label.js +12 -16
- package/es/victory-portal/victory-portal.js +4 -4
- package/es/victory-primitives/arc.js +2 -2
- package/es/victory-primitives/background.js +2 -2
- package/es/victory-primitives/border.js +2 -2
- package/es/victory-primitives/line-segment.js +2 -2
- package/es/victory-primitives/point.js +2 -2
- package/es/victory-primitives/tspan.d.ts +0 -1
- package/es/victory-primitives/types.d.ts +1 -1
- package/es/victory-primitives/whisker.d.ts +1 -1
- package/es/victory-primitives/whisker.js +2 -2
- package/es/victory-theme/types.d.ts +11 -11
- package/es/victory-transition/victory-transition.d.ts +1 -1
- package/es/victory-transition/victory-transition.js +8 -8
- package/es/victory-util/add-events.d.ts +8 -8
- package/es/victory-util/add-events.js +14 -14
- package/es/victory-util/axis.js +12 -12
- package/es/victory-util/data.js +16 -20
- package/es/victory-util/domain.js +13 -16
- package/es/victory-util/events.d.ts +5 -5
- package/es/victory-util/events.js +17 -23
- package/es/victory-util/helpers.d.ts +94 -19
- package/es/victory-util/helpers.js +95 -50
- package/es/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/es/victory-util/hooks/use-animation-state.js +4 -4
- package/es/victory-util/label-helpers.d.ts +4 -3
- package/es/victory-util/label-helpers.js +3 -3
- package/es/victory-util/line-helpers.d.ts +1 -1
- package/es/victory-util/log.js +3 -2
- package/es/victory-util/merge-refs.d.ts +2 -2
- package/es/victory-util/scale.js +2 -3
- package/es/victory-util/selection.d.ts +3 -3
- package/es/victory-util/textsize.js +7 -5
- package/es/victory-util/timer.d.ts +1 -1
- package/es/victory-util/transitions.d.ts +1 -1
- package/es/victory-util/transitions.js +15 -19
- package/es/victory-util/type-helpers.d.ts +0 -1
- package/es/victory-util/type-helpers.js +0 -5
- package/es/victory-util/user-props.d.ts +2 -2
- package/es/victory-util/wrapper.js +12 -13
- package/lib/types/callbacks.d.ts +11 -11
- package/lib/types/prop-types.d.ts +28 -28
- package/lib/victory-animation/util.js +7 -7
- package/lib/victory-animation/victory-animation.d.ts +3 -3
- package/lib/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/lib/victory-clip-container/victory-clip-container.js +20 -12
- package/lib/victory-container/victory-container.js +6 -6
- package/lib/victory-label/victory-label.d.ts +3 -3
- package/lib/victory-label/victory-label.js +12 -16
- package/lib/victory-portal/victory-portal.js +5 -5
- package/lib/victory-primitives/arc.js +2 -2
- package/lib/victory-primitives/background.js +2 -2
- package/lib/victory-primitives/border.js +2 -2
- package/lib/victory-primitives/line-segment.js +2 -2
- package/lib/victory-primitives/point.js +2 -2
- package/lib/victory-primitives/tspan.d.ts +0 -1
- package/lib/victory-primitives/types.d.ts +1 -1
- package/lib/victory-primitives/whisker.d.ts +1 -1
- package/lib/victory-primitives/whisker.js +2 -2
- package/lib/victory-theme/types.d.ts +11 -11
- package/lib/victory-transition/victory-transition.d.ts +1 -1
- package/lib/victory-transition/victory-transition.js +8 -8
- package/lib/victory-util/add-events.d.ts +8 -8
- package/lib/victory-util/add-events.js +14 -14
- package/lib/victory-util/axis.js +12 -12
- package/lib/victory-util/data.js +16 -21
- package/lib/victory-util/domain.js +13 -17
- package/lib/victory-util/events.d.ts +5 -5
- package/lib/victory-util/events.js +17 -24
- package/lib/victory-util/helpers.d.ts +94 -19
- package/lib/victory-util/helpers.js +96 -52
- package/lib/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/lib/victory-util/hooks/use-animation-state.js +4 -4
- package/lib/victory-util/label-helpers.d.ts +4 -3
- package/lib/victory-util/label-helpers.js +3 -5
- package/lib/victory-util/line-helpers.d.ts +1 -1
- package/lib/victory-util/log.js +3 -2
- package/lib/victory-util/merge-refs.d.ts +2 -2
- package/lib/victory-util/scale.js +2 -4
- package/lib/victory-util/selection.d.ts +3 -3
- package/lib/victory-util/textsize.js +5 -5
- package/lib/victory-util/timer.d.ts +1 -1
- package/lib/victory-util/transitions.d.ts +1 -1
- package/lib/victory-util/transitions.js +15 -19
- package/lib/victory-util/type-helpers.d.ts +0 -1
- package/lib/victory-util/type-helpers.js +0 -6
- package/lib/victory-util/user-props.d.ts +2 -2
- package/lib/victory-util/wrapper.js +12 -13
- package/package.json +6 -38
- package/src/victory-animation/util.ts +4 -2
- package/src/victory-clip-container/victory-clip-container.tsx +26 -11
- package/src/victory-container/victory-container.tsx +4 -4
- package/src/victory-label/victory-label.tsx +5 -3
- package/src/victory-portal/victory-portal.tsx +3 -1
- package/src/victory-primitives/arc.tsx +1 -1
- package/src/victory-primitives/background.tsx +1 -1
- package/src/victory-primitives/border.tsx +1 -1
- package/src/victory-primitives/line-segment.tsx +1 -1
- package/src/victory-primitives/point.tsx +3 -3
- package/src/victory-primitives/whisker.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +5 -3
- package/src/victory-util/add-events.tsx +6 -3
- package/src/victory-util/axis.tsx +8 -4
- package/src/victory-util/common-props.tsx +3 -3
- package/src/victory-util/data.ts +9 -13
- package/src/victory-util/domain.ts +8 -6
- package/src/victory-util/events.ts +18 -13
- package/src/victory-util/helpers.ts +155 -40
- package/src/victory-util/hooks/use-animation-state.ts +1 -1
- package/src/victory-util/label-helpers.ts +1 -2
- package/src/victory-util/log.ts +3 -2
- package/src/victory-util/merge-refs.ts +2 -0
- package/src/victory-util/scale.ts +1 -2
- package/src/victory-util/textsize.ts +2 -1
- package/src/victory-util/transitions.ts +6 -6
- package/src/victory-util/type-helpers.ts +0 -5
- package/src/victory-util/user-props.ts +1 -1
- package/src/victory-util/wrapper.tsx +5 -2
|
@@ -27,37 +27,40 @@ exports.radiansToDegrees = radiansToDegrees;
|
|
|
27
27
|
exports.range = range;
|
|
28
28
|
exports.reduceChildren = reduceChildren;
|
|
29
29
|
exports.scalePoint = scalePoint;
|
|
30
|
-
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
31
|
-
var _property2 = _interopRequireDefault(require("lodash/property"));
|
|
32
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
33
30
|
var _react = _interopRequireWildcard(require("react"));
|
|
31
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
32
|
+
var _property = _interopRequireDefault(require("lodash/property"));
|
|
33
|
+
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
35
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
35
36
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function getCartesianRange(props, axis) {
|
|
42
|
-
// determine how to lay the axis and what direction positive and negative are
|
|
43
|
-
const vertical = axis !== "x";
|
|
44
|
-
const padding = getPadding(props);
|
|
37
|
+
/**
|
|
38
|
+
* Determine the range of a cartesian axis
|
|
39
|
+
*/
|
|
40
|
+
function getCartesianRange(options) {
|
|
41
|
+
const vertical = options.axis !== "x";
|
|
45
42
|
if (vertical) {
|
|
46
|
-
return [
|
|
43
|
+
return [options.height - options.padding.bottom, options.padding.top];
|
|
47
44
|
}
|
|
48
|
-
return [padding.left,
|
|
45
|
+
return [options.padding.left, options.width - options.padding.right];
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Determine the range of a polar axis in radians
|
|
50
|
+
*/
|
|
51
|
+
function getPolarRange(options) {
|
|
52
|
+
if (options.axis === "x") {
|
|
53
|
+
const startAngle = degreesToRadians(options.startAngle || 0);
|
|
54
|
+
const endAngle = degreesToRadians(options.endAngle || 360);
|
|
54
55
|
return [startAngle, endAngle];
|
|
55
56
|
}
|
|
56
|
-
return [
|
|
57
|
+
return [options.innerRadius || 0, getRadius({
|
|
58
|
+
height: options.height,
|
|
59
|
+
width: options.width,
|
|
60
|
+
padding: options.padding
|
|
61
|
+
})];
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
// Exported Functions
|
|
60
|
-
|
|
61
64
|
/**
|
|
62
65
|
* Creates an object composed of the inverted keys and values of object.
|
|
63
66
|
* If object contains duplicate values, subsequent values overwrite property assignments of previous values.
|
|
@@ -94,8 +97,11 @@ function omit(originalObject, ks) {
|
|
|
94
97
|
}
|
|
95
98
|
return newObject;
|
|
96
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Coalesce the x and y values from a data point
|
|
103
|
+
*/
|
|
97
104
|
function getPoint(datum) {
|
|
98
|
-
const exists = val => val !== undefined;
|
|
99
105
|
const {
|
|
100
106
|
_x,
|
|
101
107
|
_x1,
|
|
@@ -106,16 +112,20 @@ function getPoint(datum) {
|
|
|
106
112
|
_y0,
|
|
107
113
|
_voronoiY
|
|
108
114
|
} = datum;
|
|
109
|
-
const defaultX =
|
|
110
|
-
const defaultY =
|
|
115
|
+
const defaultX = _x1 ?? _x;
|
|
116
|
+
const defaultY = _y1 ?? _y;
|
|
111
117
|
const point = {
|
|
112
|
-
x:
|
|
113
|
-
x0:
|
|
114
|
-
y:
|
|
115
|
-
y0:
|
|
118
|
+
x: _voronoiX ?? defaultX,
|
|
119
|
+
x0: _x0 ?? _x,
|
|
120
|
+
y: _voronoiY ?? defaultY,
|
|
121
|
+
y0: _y0 ?? _y
|
|
116
122
|
};
|
|
117
|
-
return (0,
|
|
123
|
+
return (0, _defaults.default)({}, point, datum);
|
|
118
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Scale a point based on the origin, direction, and given scale function
|
|
128
|
+
*/
|
|
119
129
|
function scalePoint(props, datum) {
|
|
120
130
|
const {
|
|
121
131
|
scale,
|
|
@@ -138,11 +148,11 @@ function scalePoint(props, datum) {
|
|
|
138
148
|
y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
|
|
139
149
|
};
|
|
140
150
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns a padding value from a number or partial padding values
|
|
154
|
+
*/
|
|
155
|
+
function getPadding(padding) {
|
|
146
156
|
const paddingVal = typeof padding === "number" ? padding : 0;
|
|
147
157
|
const paddingObj = typeof padding === "object" ? padding : {};
|
|
148
158
|
return {
|
|
@@ -152,6 +162,10 @@ function getPadding(props, name) {
|
|
|
152
162
|
right: paddingObj.right || paddingVal
|
|
153
163
|
};
|
|
154
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Returns true if the component is defined as a tooltip
|
|
168
|
+
*/
|
|
155
169
|
function isTooltip(component) {
|
|
156
170
|
const labelRole = component && component.type && component.type.role;
|
|
157
171
|
return labelRole === "tooltip";
|
|
@@ -166,8 +180,8 @@ function getDefaultStyles(props, role) {
|
|
|
166
180
|
return defaultStyles;
|
|
167
181
|
}
|
|
168
182
|
const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
|
|
169
|
-
const labelStyle = (0,
|
|
170
|
-
return (0,
|
|
183
|
+
const labelStyle = (0, _defaults.default)({}, tooltipStyle, defaultStyles.labels);
|
|
184
|
+
return (0, _defaults.default)({}, {
|
|
171
185
|
labels: labelStyle
|
|
172
186
|
}, defaultStyles);
|
|
173
187
|
}
|
|
@@ -175,7 +189,7 @@ function getStyles(style, defaultStyles) {
|
|
|
175
189
|
const width = "100%";
|
|
176
190
|
const height = "100%";
|
|
177
191
|
if (!style) {
|
|
178
|
-
return (0,
|
|
192
|
+
return (0, _defaults.default)({
|
|
179
193
|
parent: {
|
|
180
194
|
height,
|
|
181
195
|
width
|
|
@@ -191,14 +205,18 @@ function getStyles(style, defaultStyles) {
|
|
|
191
205
|
const defaultLabels = defaultStyles && defaultStyles.labels || {};
|
|
192
206
|
const defaultData = defaultStyles && defaultStyles.data || {};
|
|
193
207
|
return {
|
|
194
|
-
parent: (0,
|
|
208
|
+
parent: (0, _defaults.default)({}, parent, defaultParent, {
|
|
195
209
|
width,
|
|
196
210
|
height
|
|
197
211
|
}),
|
|
198
|
-
labels: (0,
|
|
199
|
-
data: (0,
|
|
212
|
+
labels: (0, _defaults.default)({}, labels, defaultLabels),
|
|
213
|
+
data: (0, _defaults.default)({}, data, defaultData)
|
|
200
214
|
};
|
|
201
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the value of a prop or accessor function with the given props
|
|
219
|
+
*/
|
|
202
220
|
function evaluateProp(prop, props) {
|
|
203
221
|
return isFunction(prop) ? prop(props) : prop;
|
|
204
222
|
}
|
|
@@ -220,19 +238,28 @@ function degreesToRadians(degrees) {
|
|
|
220
238
|
function radiansToDegrees(radians) {
|
|
221
239
|
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
|
|
222
240
|
}
|
|
223
|
-
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Get the maximum radius that will fit in the container
|
|
244
|
+
*/
|
|
245
|
+
function getRadius(options) {
|
|
246
|
+
const {
|
|
247
|
+
width,
|
|
248
|
+
height,
|
|
249
|
+
padding
|
|
250
|
+
} = options;
|
|
224
251
|
const {
|
|
225
252
|
left,
|
|
226
253
|
right,
|
|
227
254
|
top,
|
|
228
255
|
bottom
|
|
229
|
-
} =
|
|
230
|
-
const {
|
|
231
|
-
width,
|
|
232
|
-
height
|
|
233
|
-
} = props;
|
|
256
|
+
} = padding;
|
|
234
257
|
return Math.min(width - left - right, height - top - bottom) / 2;
|
|
235
258
|
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns the origin for a polar chart within the padded area
|
|
262
|
+
*/
|
|
236
263
|
function getPolarOrigin(props) {
|
|
237
264
|
const {
|
|
238
265
|
width,
|
|
@@ -243,7 +270,7 @@ function getPolarOrigin(props) {
|
|
|
243
270
|
bottom,
|
|
244
271
|
left,
|
|
245
272
|
right
|
|
246
|
-
} = getPadding(props);
|
|
273
|
+
} = getPadding(props.padding);
|
|
247
274
|
const radius = Math.min(width - left - right, height - top - bottom) / 2;
|
|
248
275
|
const offsetWidth = width / 2 + left - right;
|
|
249
276
|
const offsetHeight = height / 2 + top - bottom;
|
|
@@ -252,13 +279,30 @@ function getPolarOrigin(props) {
|
|
|
252
279
|
y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
|
|
253
280
|
};
|
|
254
281
|
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Determine the range of an axis based on the given props
|
|
285
|
+
*/
|
|
255
286
|
function getRange(props, axis) {
|
|
256
287
|
if (props.range && props.range[axis]) {
|
|
257
288
|
return props.range[axis];
|
|
258
289
|
} else if (props.range && Array.isArray(props.range)) {
|
|
259
290
|
return props.range;
|
|
260
291
|
}
|
|
261
|
-
return props.polar ? getPolarRange(
|
|
292
|
+
return props.polar ? getPolarRange({
|
|
293
|
+
axis,
|
|
294
|
+
innerRadius: props.innerRadius,
|
|
295
|
+
startAngle: props.startAngle,
|
|
296
|
+
endAngle: props.endAngle,
|
|
297
|
+
height: props.height,
|
|
298
|
+
width: props.width,
|
|
299
|
+
padding: getPadding(props.padding)
|
|
300
|
+
}) : getCartesianRange({
|
|
301
|
+
axis,
|
|
302
|
+
height: props.height,
|
|
303
|
+
width: props.width,
|
|
304
|
+
padding: getPadding(props.padding)
|
|
305
|
+
});
|
|
262
306
|
}
|
|
263
307
|
|
|
264
308
|
/**
|
|
@@ -290,7 +334,7 @@ function createAccessor(key) {
|
|
|
290
334
|
return x => x;
|
|
291
335
|
}
|
|
292
336
|
// otherwise, assume it is an array index, property key or path (_.property handles all three)
|
|
293
|
-
return (0,
|
|
337
|
+
return (0, _property.default)(key);
|
|
294
338
|
}
|
|
295
339
|
function modifyProps(props, fallbackProps, role) {
|
|
296
340
|
const theme = props.theme && props.theme[role] ? props.theme[role] : {};
|
|
@@ -299,7 +343,7 @@ function modifyProps(props, fallbackProps, role) {
|
|
|
299
343
|
const defaultObject = horizontal === undefined ? {} : {
|
|
300
344
|
horizontal
|
|
301
345
|
};
|
|
302
|
-
return (0,
|
|
346
|
+
return (0, _defaults.default)(defaultObject, props, themeProps, fallbackProps);
|
|
303
347
|
}
|
|
304
348
|
|
|
305
349
|
/**
|
|
@@ -386,9 +430,9 @@ initialMemo, combine) {
|
|
|
386
430
|
const childRole = child.type && child.type.role;
|
|
387
431
|
const childName = child.props.name || `${childRole}-${names[index]}`;
|
|
388
432
|
if (child.props && child.props.children) {
|
|
389
|
-
const childProps = Object.assign({}, child.props, (0,
|
|
433
|
+
const childProps = Object.assign({}, child.props, (0, _pick.default)(parentProps, sharedProps));
|
|
390
434
|
const nestedChildren = child.type && child.type.role === "stack" && isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : _react.default.Children.toArray(child.props.children).map(c => {
|
|
391
|
-
const nestedChildProps = Object.assign({}, c.props, (0,
|
|
435
|
+
const nestedChildProps = Object.assign({}, c.props, (0, _pick.default)(childProps, sharedProps));
|
|
392
436
|
return /*#__PURE__*/_react.default.cloneElement(c, nestedChildProps);
|
|
393
437
|
});
|
|
394
438
|
const childNames = nestedChildren.map((c, i) => `${childName}-${i}`);
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimationState = void 0;
|
|
7
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
9
9
|
var Collection = _interopRequireWildcard(require("../collection"));
|
|
10
10
|
var Transitions = _interopRequireWildcard(require("../transitions"));
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -38,7 +38,7 @@ const useAnimationState = function (initialState) {
|
|
|
38
38
|
const getFilteredState = () => {
|
|
39
39
|
let childrenTransitions = state && state.childrenTransitions;
|
|
40
40
|
childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, _defaults.default)({
|
|
42
42
|
childrenTransitions
|
|
43
43
|
}, state);
|
|
44
44
|
};
|
|
@@ -49,7 +49,7 @@ const useAnimationState = function (initialState) {
|
|
|
49
49
|
const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
|
|
50
50
|
getTransitions = childComponent => getTransitionProps(childComponent, index);
|
|
51
51
|
}
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, _defaults.default)({
|
|
53
53
|
getTransitions,
|
|
54
54
|
parentState
|
|
55
55
|
}, props.animate, child.props.animate);
|
|
@@ -63,7 +63,7 @@ const useAnimationState = function (initialState) {
|
|
|
63
63
|
if (props.animate.parentState) {
|
|
64
64
|
const nodesWillExit = props.animate.parentState.nodesWillExit;
|
|
65
65
|
const oldProps = nodesWillExit ? props : null;
|
|
66
|
-
const newState = (0,
|
|
66
|
+
const newState = (0, _defaults.default)({
|
|
67
67
|
oldProps,
|
|
68
68
|
nextProps
|
|
69
69
|
}, props.animate.parentState);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { VictoryLabelProps } from "../victory-label/victory-label";
|
|
2
|
+
export declare function getText(props: any, datum: VictoryLabelProps["datum"], index: any): any;
|
|
2
3
|
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
3
4
|
export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
4
5
|
export declare function getPolarAngle(props: any, baseAngle?: any): number;
|
|
@@ -16,8 +17,8 @@ export declare function getProps(props: any, index: any): {
|
|
|
16
17
|
text: any;
|
|
17
18
|
textAnchor: any;
|
|
18
19
|
verticalAnchor: any;
|
|
19
|
-
x:
|
|
20
|
-
y:
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
21
22
|
dx: number | undefined;
|
|
22
23
|
dy: number | undefined;
|
|
23
24
|
width: any;
|
|
@@ -9,13 +9,11 @@ exports.getPolarTextAnchor = getPolarTextAnchor;
|
|
|
9
9
|
exports.getPolarVerticalAnchor = getPolarVerticalAnchor;
|
|
10
10
|
exports.getProps = getProps;
|
|
11
11
|
exports.getText = getText;
|
|
12
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
13
12
|
var Helpers = _interopRequireWildcard(require("./helpers"));
|
|
13
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
/* eslint-disable no-use-before-define */
|
|
18
|
-
|
|
19
17
|
// Private Functions
|
|
20
18
|
|
|
21
19
|
function getVerticalAnchor(props, datum) {
|
|
@@ -243,5 +241,5 @@ function getProps(props, index) {
|
|
|
243
241
|
return labelProps;
|
|
244
242
|
}
|
|
245
243
|
const tooltipTheme = theme && theme.tooltip || {};
|
|
246
|
-
return (0,
|
|
244
|
+
return (0, _defaults.default)({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
|
|
247
245
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as d3Shape from "victory-vendor/d3-shape";
|
|
2
|
-
export
|
|
2
|
+
export type CurveName = "basis" | "cardinal" | "bumpX" | "bumpY" | "bundle" | "catmullRom" | "linear" | "monotoneX" | "monotoneY" | "step" | "stepAfter" | "stepBefore" | "natural";
|
|
3
3
|
export declare const getInterpolationFunction: (props: any) => any;
|
|
4
4
|
export declare const getLineFunction: (props: any) => d3Shape.LineRadial<[number, number]> | d3Shape.Line<[number, number]>;
|
|
5
5
|
//# sourceMappingURL=line-helpers.d.ts.map
|
package/lib/victory-util/log.js
CHANGED
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warn = warn;
|
|
7
|
-
/* global console */
|
|
7
|
+
/* global console process */
|
|
8
8
|
/* eslint-disable no-console */
|
|
9
9
|
|
|
10
|
-
// TODO: Use "warning" npm module like React is switching to.
|
|
11
10
|
function warn(message) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
+
// @ts-ignore - Webpack DefinePlugin will replace process.env.NODE_ENV
|
|
12
13
|
if (process.env.NODE_ENV !== "production") {
|
|
13
14
|
if (console && console.warn) {
|
|
14
15
|
console.warn(message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
|
|
3
3
|
/**
|
|
4
4
|
* Used to merge multiple React refs into a single callback ref.
|
|
5
5
|
*
|
|
@@ -10,15 +10,13 @@ exports.getScaleFromProps = getScaleFromProps;
|
|
|
10
10
|
exports.getScaleType = getScaleType;
|
|
11
11
|
exports.getType = getType;
|
|
12
12
|
exports.validScale = validScale;
|
|
13
|
-
var
|
|
13
|
+
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
14
14
|
var Helpers = _interopRequireWildcard(require("./helpers"));
|
|
15
15
|
var Collection = _interopRequireWildcard(require("./collection"));
|
|
16
16
|
var d3Scale = _interopRequireWildcard(require("victory-vendor/d3-scale"));
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
/* eslint-disable no-use-before-define */
|
|
21
|
-
|
|
22
20
|
const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
|
|
23
21
|
// Private Functions
|
|
24
22
|
|
|
@@ -68,7 +66,7 @@ function getScaleTypeFromData(props, axis) {
|
|
|
68
66
|
}
|
|
69
67
|
const accessor = Helpers.createAccessor(props[axis]);
|
|
70
68
|
const axisData = props.data.map(datum => {
|
|
71
|
-
const processedData = (0,
|
|
69
|
+
const processedData = (0, _isPlainObject.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
|
|
72
70
|
return processedData !== undefined ? processedData : datum[axis];
|
|
73
71
|
});
|
|
74
72
|
return Collection.containsDates(axisData) ? "time" : "linear";
|
|
@@ -9,15 +9,15 @@ export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "sc
|
|
|
9
9
|
};
|
|
10
10
|
export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
|
|
11
11
|
export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
|
|
12
|
-
export
|
|
12
|
+
export type SVGCoordinateType = {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type SVGCoordinateBounds = {
|
|
17
17
|
x: readonly [number, number];
|
|
18
18
|
y: readonly [number, number];
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type ComputedCommonProps = {
|
|
21
21
|
scale: ScaleXYPropType;
|
|
22
22
|
x1: number;
|
|
23
23
|
x2: number;
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertLengthToPixels = exports.approximateTextSize = exports._approximateTextSizeInternal = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
8
|
+
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
// http://www.pearsonified.com/2012/01/characters-per-line.php
|
|
11
11
|
/* eslint-disable no-magic-numbers */
|
|
@@ -189,7 +189,7 @@ const convertLengthToPixels = (length, fontSize) => {
|
|
|
189
189
|
exports.convertLengthToPixels = convertLengthToPixels;
|
|
190
190
|
const _prepareParams = (inputStyle, index) => {
|
|
191
191
|
const lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
|
|
192
|
-
const style = (0,
|
|
192
|
+
const style = (0, _defaults.default)({}, lineStyle, defaultStyle);
|
|
193
193
|
return Object.assign({}, style, {
|
|
194
194
|
fontFamily: style.fontFamily,
|
|
195
195
|
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
|
|
@@ -237,7 +237,7 @@ const _approximateDimensionsInternal = (text, style) => {
|
|
|
237
237
|
height: heightWithRotate * coefficients.heightOverlapCoef
|
|
238
238
|
};
|
|
239
239
|
};
|
|
240
|
-
const _getMeasurementContainer = (0,
|
|
240
|
+
const _getMeasurementContainer = (0, _memoize.default)(() => {
|
|
241
241
|
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
242
242
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
243
243
|
element.setAttribute("width", "300");
|
|
@@ -258,7 +258,7 @@ const styleToKeyComponent = style => {
|
|
|
258
258
|
}
|
|
259
259
|
return `${style.angle}:${style.fontFamily}:${style.fontSize}:${style.letterSpacing}:${style.lineHeight}`;
|
|
260
260
|
};
|
|
261
|
-
const _measureDimensionsInternal = (0,
|
|
261
|
+
const _measureDimensionsInternal = (0, _memoize.default)((text, style) => {
|
|
262
262
|
let containerElement = _getMeasurementContainer();
|
|
263
263
|
if (!containerElement.isConnected) {
|
|
264
264
|
_getMeasurementContainer.cache.clear?.();
|
|
@@ -21,7 +21,7 @@ export declare function getInitialTransitionState(oldChildren: any, nextChildren
|
|
|
21
21
|
childrenTransitions: any;
|
|
22
22
|
nodesShouldEnter: boolean;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type TransitionProps = {
|
|
25
25
|
data: any;
|
|
26
26
|
animate?: AnimatePropTypeInterface;
|
|
27
27
|
clipWidth?: number;
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getInitialTransitionState = getInitialTransitionState;
|
|
7
7
|
exports.getTransitionPropsFactory = getTransitionPropsFactory;
|
|
8
|
-
var _identity2 = _interopRequireDefault(require("lodash/identity"));
|
|
9
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
10
|
+
var _identity = _interopRequireDefault(require("lodash/identity"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function getDatumKey(datum, idx) {
|
|
13
13
|
return (datum.key || idx).toString();
|
|
@@ -116,7 +116,7 @@ function getInitialTransitionState(oldChildren, nextChildren) {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
function getInitialChildProps(animate, data) {
|
|
119
|
-
const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after :
|
|
119
|
+
const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity.default;
|
|
120
120
|
return {
|
|
121
121
|
data: data.map((datum, idx) => Object.assign({}, datum, after(datum, idx, data)))
|
|
122
122
|
};
|
|
@@ -133,7 +133,7 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
133
133
|
data
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before :
|
|
136
|
+
const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity.default;
|
|
137
137
|
// If nodes need to exit, transform them with the provided onLoad.before function.
|
|
138
138
|
const newData = data.map((datum, idx) => {
|
|
139
139
|
return Object.assign({}, datum, before(datum, idx, data));
|
|
@@ -144,8 +144,6 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
144
144
|
clipWidth: 0
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
// eslint-disable-next-line max-params
|
|
149
147
|
function getChildOnLoad(animate, data, cb) {
|
|
150
148
|
const newAnimate = Object.assign({}, animate, {
|
|
151
149
|
onEnd: cb
|
|
@@ -157,7 +155,7 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
157
155
|
data
|
|
158
156
|
};
|
|
159
157
|
}
|
|
160
|
-
const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after :
|
|
158
|
+
const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity.default;
|
|
161
159
|
// If nodes need to exit, transform them with the provided onLoad.after function.
|
|
162
160
|
newData = data.map((datum, idx) => {
|
|
163
161
|
return Object.assign({}, datum, after(datum, idx, data));
|
|
@@ -168,7 +166,7 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
168
166
|
};
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
// eslint-disable-next-line max-params
|
|
169
|
+
// eslint-disable-next-line max-params
|
|
172
170
|
function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
173
171
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
174
172
|
// transition for all children to have the same duration, delay, etc.
|
|
@@ -179,7 +177,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
179
177
|
// After the exit transition occurs, trigger the animations for
|
|
180
178
|
// nodes that are neither exiting nor entering.
|
|
181
179
|
animate.onEnd = cb;
|
|
182
|
-
const before = animate.onExit && animate.onExit.before ? animate.onExit.before :
|
|
180
|
+
const before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity.default;
|
|
183
181
|
// If nodes need to exit, transform them with the provided onExit.before function.
|
|
184
182
|
newData = data.map((datum, idx) => {
|
|
185
183
|
const key = (datum.key || idx).toString();
|
|
@@ -192,7 +190,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
192
190
|
};
|
|
193
191
|
}
|
|
194
192
|
|
|
195
|
-
// eslint-disable-next-line max-params
|
|
193
|
+
// eslint-disable-next-line max-params
|
|
196
194
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
197
195
|
let newAnimate = animate;
|
|
198
196
|
let newData = data;
|
|
@@ -202,7 +200,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
202
200
|
newAnimate = Object.assign({}, animate, {
|
|
203
201
|
onEnd: cb
|
|
204
202
|
});
|
|
205
|
-
const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before :
|
|
203
|
+
const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity.default;
|
|
206
204
|
// We want the entering nodes to be included in the transition target
|
|
207
205
|
// domain. However, we may not want these nodes to be displayed initially,
|
|
208
206
|
// so perform the `onEnter.before` transformation on each node.
|
|
@@ -217,7 +215,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
217
215
|
};
|
|
218
216
|
}
|
|
219
217
|
|
|
220
|
-
// eslint-disable-next-line max-params
|
|
218
|
+
// eslint-disable-next-line max-params
|
|
221
219
|
function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
222
220
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
223
221
|
// transition for all children to have the same duration, delay, etc.
|
|
@@ -229,7 +227,7 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
|
229
227
|
// domain should encompass the nodes that will now enter. So perform
|
|
230
228
|
// the `onEnter.after` transformation on each node.
|
|
231
229
|
newAnimate.onEnd = cb;
|
|
232
|
-
const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after :
|
|
230
|
+
const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity.default;
|
|
233
231
|
newData = data.map((datum, idx) => {
|
|
234
232
|
const key = getDatumKey(datum, idx);
|
|
235
233
|
return enteringNodes[key] ? Object.assign({}, datum, after(datum, idx, data)) : datum;
|
|
@@ -324,15 +322,13 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
324
322
|
}
|
|
325
323
|
return {};
|
|
326
324
|
};
|
|
327
|
-
|
|
328
|
-
// eslint-disable-next-line max-statements, complexity, max-len
|
|
329
325
|
return function getTransitionProps(child, index) {
|
|
330
326
|
const data = getChildData(child) || [];
|
|
331
|
-
const animate = (0,
|
|
327
|
+
const animate = (0, _defaults.default)({}, props.animate, child.props.animate);
|
|
332
328
|
const defaultTransitions = child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
333
|
-
animate.onExit = (0,
|
|
334
|
-
animate.onEnter = (0,
|
|
335
|
-
animate.onLoad = (0,
|
|
329
|
+
animate.onExit = (0, _defaults.default)({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
|
|
330
|
+
animate.onEnter = (0, _defaults.default)({}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter);
|
|
331
|
+
animate.onLoad = (0, _defaults.default)({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
|
|
336
332
|
const childTransitions = childrenTransitions[index] || childrenTransitions[0];
|
|
337
333
|
if (!nodesDoneLoad) {
|
|
338
334
|
// should do onLoad animation
|
|
@@ -2,7 +2,6 @@ import { ForAxes, AxisType, Tuple, Datum, DatumValue } from "../types/prop-types
|
|
|
2
2
|
export declare function hasValueForAxis<T = unknown>(value: unknown | ForAxes<T>, axis: AxisType): value is ForAxes<T>;
|
|
3
3
|
export declare function isTuple<T = unknown>(value: unknown): value is Tuple<T>;
|
|
4
4
|
export declare function getValueForAxis<T = unknown>(value: T | ForAxes<T> | undefined, axis: AxisType): T | undefined;
|
|
5
|
-
export declare function isFunction<T = Function>(func?: unknown): func is T;
|
|
6
5
|
export declare function isDate(value: unknown): value is Date;
|
|
7
6
|
export declare function isKeyValueObject(datum: Datum): datum is {
|
|
8
7
|
[key: string]: DatumValue;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getValueForAxis = getValueForAxis;
|
|
7
7
|
exports.hasValueForAxis = hasValueForAxis;
|
|
8
8
|
exports.isDate = isDate;
|
|
9
|
-
exports.isFunction = isFunction;
|
|
10
9
|
exports.isKeyValueObject = isKeyValueObject;
|
|
11
10
|
exports.isTuple = isTuple;
|
|
12
11
|
function hasValueForAxis(value, axis) {
|
|
@@ -24,11 +23,6 @@ function getValueForAxis(value, axis) {
|
|
|
24
23
|
}
|
|
25
24
|
return value;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
29
|
-
function isFunction(func) {
|
|
30
|
-
return typeof func === "function";
|
|
31
|
-
}
|
|
32
26
|
function isDate(value) {
|
|
33
27
|
return value instanceof Date;
|
|
34
28
|
}
|