victory-core 36.9.2-next.3 → 37.0.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/CHANGELOG.md +28 -10
- package/README.md +1 -1
- package/dist/victory-core.js +4449 -6196
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +17 -17
- package/es/types/callbacks.d.ts +36 -36
- package/es/types/prop-types.d.ts +129 -129
- package/es/victory-accessible-group/victory-accessible-group.d.ts +10 -10
- package/es/victory-accessible-group/victory-accessible-group.js +9 -15
- package/es/victory-animation/util.d.ts +66 -66
- package/es/victory-animation/util.js +28 -47
- package/es/victory-animation/victory-animation.d.ts +34 -34
- package/es/victory-animation/victory-animation.js +51 -67
- package/es/victory-clip-container/victory-clip-container.d.ts +46 -46
- package/es/victory-clip-container/victory-clip-container.js +153 -229
- package/es/victory-container/victory-container.d.ts +68 -68
- package/es/victory-container/victory-container.js +157 -216
- package/es/victory-label/victory-label.d.ts +58 -58
- package/es/victory-label/victory-label.js +246 -323
- package/es/victory-portal/portal-context.d.ts +11 -11
- package/es/victory-portal/portal-context.js +1 -2
- package/es/victory-portal/portal.d.ts +20 -20
- package/es/victory-portal/portal.js +30 -76
- package/es/victory-portal/victory-portal.d.ts +26 -26
- package/es/victory-portal/victory-portal.js +47 -104
- package/es/victory-primitives/arc.d.ts +14 -14
- package/es/victory-primitives/arc.js +44 -47
- package/es/victory-primitives/background.d.ts +13 -13
- package/es/victory-primitives/background.js +14 -17
- package/es/victory-primitives/border.d.ts +10 -10
- package/es/victory-primitives/border.js +20 -24
- package/es/victory-primitives/circle.d.ts +3 -3
- package/es/victory-primitives/circle.js +13 -27
- package/es/victory-primitives/clip-path.d.ts +7 -7
- package/es/victory-primitives/clip-path.js +3 -7
- package/es/victory-primitives/index.d.ts +14 -14
- package/es/victory-primitives/line-segment.d.ts +11 -11
- package/es/victory-primitives/line-segment.js +20 -24
- package/es/victory-primitives/line.d.ts +3 -3
- package/es/victory-primitives/line.js +13 -27
- package/es/victory-primitives/path.d.ts +3 -3
- package/es/victory-primitives/path.js +13 -27
- package/es/victory-primitives/point.d.ts +13 -13
- package/es/victory-primitives/point.js +36 -40
- package/es/victory-primitives/rect.d.ts +3 -3
- package/es/victory-primitives/rect.js +13 -27
- package/es/victory-primitives/text.d.ts +8 -8
- package/es/victory-primitives/text.js +15 -28
- package/es/victory-primitives/tspan.d.ts +3 -3
- package/es/victory-primitives/tspan.js +13 -26
- package/es/victory-primitives/types.d.ts +7 -7
- package/es/victory-primitives/whisker.d.ts +15 -15
- package/es/victory-primitives/whisker.js +43 -47
- package/es/victory-theme/grayscale.d.ts +2 -2
- package/es/victory-theme/grayscale.js +22 -22
- package/es/victory-theme/material.d.ts +2 -2
- package/es/victory-theme/material.js +46 -46
- package/es/victory-theme/types.d.ts +238 -238
- package/es/victory-theme/victory-theme.d.ts +5 -5
- package/es/victory-theme/victory-theme.js +3 -3
- package/es/victory-transition/victory-transition.d.ts +53 -53
- package/es/victory-transition/victory-transition.js +126 -206
- package/es/victory-util/add-events.d.ts +126 -126
- package/es/victory-util/add-events.js +265 -380
- package/es/victory-util/axis.d.ts +50 -50
- package/es/victory-util/axis.js +133 -222
- package/es/victory-util/collection.d.ts +15 -8
- package/es/victory-util/collection.js +24 -36
- package/es/victory-util/common-props.d.ts +79 -79
- package/es/victory-util/data.d.ts +74 -74
- package/es/victory-util/data.js +159 -214
- package/es/victory-util/default-transitions.d.ts +4 -4
- package/es/victory-util/default-transitions.js +33 -51
- package/es/victory-util/domain.d.ts +90 -90
- package/es/victory-util/domain.js +122 -171
- package/es/victory-util/events.d.ts +64 -64
- package/es/victory-util/events.js +168 -258
- package/es/victory-util/helpers.d.ts +96 -91
- package/es/victory-util/helpers.js +162 -176
- package/es/victory-util/hooks/index.d.ts +2 -2
- package/es/victory-util/hooks/use-animation-state.d.ts +21 -21
- package/es/victory-util/hooks/use-animation-state.js +61 -99
- package/es/victory-util/hooks/use-previous-props.d.ts +1 -1
- package/es/victory-util/hooks/use-previous-props.js +2 -2
- package/es/victory-util/immutable.d.ts +11 -11
- package/es/victory-util/immutable.js +6 -8
- package/es/victory-util/index.d.ts +26 -26
- package/es/victory-util/label-helpers.d.ts +26 -26
- package/es/victory-util/label-helpers.js +128 -130
- package/es/victory-util/line-helpers.d.ts +4 -4
- package/es/victory-util/line-helpers.js +29 -41
- package/es/victory-util/log.d.ts +1 -1
- package/es/victory-util/log.js +1 -1
- package/es/victory-util/point-path-helpers.d.ts +9 -9
- package/es/victory-util/point-path-helpers.js +89 -49
- package/es/victory-util/scale.d.ts +9 -9
- package/es/victory-util/scale.js +24 -42
- package/es/victory-util/selection.d.ts +28 -28
- package/es/victory-util/selection.js +39 -40
- package/es/victory-util/style.d.ts +18 -18
- package/es/victory-util/style.js +8 -13
- package/es/victory-util/textsize.d.ts +35 -35
- package/es/victory-util/textsize.js +80 -154
- package/es/victory-util/timer-context.d.ts +11 -11
- package/es/victory-util/timer-context.js +2 -2
- package/es/victory-util/timer.d.ts +16 -16
- package/es/victory-util/timer.js +40 -76
- package/es/victory-util/transitions.d.ts +48 -48
- package/es/victory-util/transitions.js +110 -150
- package/es/victory-util/type-helpers.d.ts +9 -9
- package/es/victory-util/type-helpers.js +2 -3
- package/es/victory-util/user-props.d.ts +26 -26
- package/es/victory-util/user-props.js +24 -49
- package/es/victory-util/wrapper.d.ts +33 -37
- package/es/victory-util/wrapper.js +182 -245
- package/lib/index.d.ts +17 -17
- package/lib/index.js +0 -30
- package/lib/types/callbacks.d.ts +36 -36
- package/lib/types/prop-types.d.ts +129 -129
- package/lib/victory-accessible-group/victory-accessible-group.d.ts +10 -10
- package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
- package/lib/victory-animation/util.d.ts +66 -66
- package/lib/victory-animation/util.js +28 -63
- package/lib/victory-animation/victory-animation.d.ts +34 -34
- package/lib/victory-animation/victory-animation.js +54 -83
- package/lib/victory-clip-container/victory-clip-container.d.ts +46 -46
- package/lib/victory-clip-container/victory-clip-container.js +156 -243
- package/lib/victory-container/victory-container.d.ts +68 -68
- package/lib/victory-container/victory-container.js +160 -232
- package/lib/victory-label/victory-label.d.ts +58 -58
- package/lib/victory-label/victory-label.js +248 -344
- package/lib/victory-portal/portal-context.d.ts +11 -11
- package/lib/victory-portal/portal-context.js +1 -6
- package/lib/victory-portal/portal.d.ts +20 -20
- package/lib/victory-portal/portal.js +31 -81
- package/lib/victory-portal/victory-portal.d.ts +26 -26
- package/lib/victory-portal/victory-portal.js +50 -116
- package/lib/victory-primitives/arc.d.ts +14 -14
- package/lib/victory-primitives/arc.js +48 -57
- package/lib/victory-primitives/background.d.ts +13 -13
- package/lib/victory-primitives/background.js +16 -28
- package/lib/victory-primitives/border.d.ts +10 -10
- package/lib/victory-primitives/border.js +22 -34
- package/lib/victory-primitives/circle.d.ts +3 -3
- package/lib/victory-primitives/circle.js +16 -36
- package/lib/victory-primitives/clip-path.d.ts +7 -7
- package/lib/victory-primitives/clip-path.js +3 -11
- package/lib/victory-primitives/index.d.ts +14 -14
- package/lib/victory-primitives/index.js +0 -28
- package/lib/victory-primitives/line-segment.d.ts +11 -11
- package/lib/victory-primitives/line-segment.js +22 -34
- package/lib/victory-primitives/line.d.ts +3 -3
- package/lib/victory-primitives/line.js +16 -36
- package/lib/victory-primitives/path.d.ts +3 -3
- package/lib/victory-primitives/path.js +16 -36
- package/lib/victory-primitives/point.d.ts +13 -13
- package/lib/victory-primitives/point.js +38 -52
- package/lib/victory-primitives/rect.d.ts +3 -3
- package/lib/victory-primitives/rect.js +16 -36
- package/lib/victory-primitives/text.d.ts +8 -8
- package/lib/victory-primitives/text.js +15 -33
- package/lib/victory-primitives/tspan.d.ts +3 -3
- package/lib/victory-primitives/tspan.js +13 -31
- package/lib/victory-primitives/types.d.ts +7 -7
- package/lib/victory-primitives/whisker.d.ts +15 -15
- package/lib/victory-primitives/whisker.js +45 -57
- package/lib/victory-theme/grayscale.d.ts +2 -2
- package/lib/victory-theme/grayscale.js +23 -24
- package/lib/victory-theme/material.d.ts +2 -2
- package/lib/victory-theme/material.js +47 -48
- package/lib/victory-theme/types.d.ts +238 -238
- package/lib/victory-theme/victory-theme.d.ts +5 -5
- package/lib/victory-theme/victory-theme.js +2 -7
- package/lib/victory-transition/victory-transition.d.ts +53 -53
- package/lib/victory-transition/victory-transition.js +129 -224
- package/lib/victory-util/add-events.d.ts +126 -126
- package/lib/victory-util/add-events.js +265 -382
- package/lib/victory-util/axis.d.ts +50 -50
- package/lib/victory-util/axis.js +135 -242
- package/lib/victory-util/collection.d.ts +15 -8
- package/lib/victory-util/collection.js +24 -43
- package/lib/victory-util/common-props.d.ts +79 -79
- package/lib/victory-util/data.d.ts +74 -74
- package/lib/victory-util/data.js +160 -239
- package/lib/victory-util/default-transitions.d.ts +4 -4
- package/lib/victory-util/default-transitions.js +33 -54
- package/lib/victory-util/domain.d.ts +90 -90
- package/lib/victory-util/domain.js +123 -193
- package/lib/victory-util/events.d.ts +64 -64
- package/lib/victory-util/events.js +167 -274
- package/lib/victory-util/helpers.d.ts +96 -91
- package/lib/victory-util/helpers.js +166 -204
- package/lib/victory-util/hooks/index.d.ts +2 -2
- package/lib/victory-util/hooks/index.js +0 -2
- package/lib/victory-util/hooks/use-animation-state.d.ts +21 -21
- package/lib/victory-util/hooks/use-animation-state.js +63 -113
- package/lib/victory-util/hooks/use-previous-props.d.ts +1 -1
- package/lib/victory-util/hooks/use-previous-props.js +2 -7
- package/lib/victory-util/immutable.d.ts +11 -11
- package/lib/victory-util/immutable.js +6 -18
- package/lib/victory-util/index.d.ts +26 -26
- package/lib/victory-util/index.js +2 -51
- package/lib/victory-util/label-helpers.d.ts +26 -26
- package/lib/victory-util/label-helpers.js +130 -141
- package/lib/victory-util/line-helpers.d.ts +4 -4
- package/lib/victory-util/line-helpers.js +31 -49
- package/lib/victory-util/log.d.ts +1 -1
- package/lib/victory-util/log.js +1 -2
- package/lib/victory-util/point-path-helpers.d.ts +9 -9
- package/lib/victory-util/point-path-helpers.js +91 -63
- package/lib/victory-util/scale.d.ts +9 -9
- package/lib/victory-util/scale.js +26 -57
- package/lib/victory-util/selection.d.ts +28 -28
- package/lib/victory-util/selection.js +41 -49
- package/lib/victory-util/style.d.ts +18 -18
- package/lib/victory-util/style.js +8 -16
- package/lib/victory-util/textsize.d.ts +35 -35
- package/lib/victory-util/textsize.js +80 -157
- package/lib/victory-util/timer-context.d.ts +11 -11
- package/lib/victory-util/timer-context.js +2 -8
- package/lib/victory-util/timer.d.ts +16 -16
- package/lib/victory-util/timer.js +40 -76
- package/lib/victory-util/transitions.d.ts +48 -48
- package/lib/victory-util/transitions.js +110 -152
- package/lib/victory-util/type-helpers.d.ts +9 -9
- package/lib/victory-util/type-helpers.js +2 -9
- package/lib/victory-util/user-props.d.ts +26 -26
- package/lib/victory-util/user-props.js +25 -59
- package/lib/victory-util/wrapper.d.ts +33 -37
- package/lib/victory-util/wrapper.js +184 -279
- package/package.json +6 -3
- package/src/types/prop-types.ts +0 -7
- package/src/victory-container/victory-container.tsx +195 -171
- package/src/victory-portal/portal-context.ts +4 -5
- package/src/victory-portal/portal.tsx +42 -5
- package/src/victory-portal/victory-portal.tsx +71 -34
- package/src/victory-util/add-events.tsx +6 -4
- package/src/victory-util/axis.tsx +12 -3
- package/src/victory-util/collection.tsx +13 -0
- package/src/victory-util/helpers.ts +11 -0
- package/src/victory-util/index.ts +0 -1
- package/src/victory-util/wrapper.tsx +1 -0
- package/src/victory-util/merge-refs.ts +0 -13
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import _pick from "lodash/pick";
|
|
2
2
|
import _property from "lodash/property";
|
|
3
3
|
import _defaults from "lodash/defaults";
|
|
4
|
-
|
|
5
4
|
/* eslint-disable no-use-before-define */
|
|
6
5
|
import React, { isValidElement } from "react";
|
|
7
|
-
|
|
8
6
|
// Private Functions
|
|
7
|
+
|
|
9
8
|
function getCartesianRange(props, axis) {
|
|
10
9
|
// determine how to lay the axis and what direction positive and negative are
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const vertical = axis !== "x";
|
|
11
|
+
const padding = getPadding(props);
|
|
14
12
|
if (vertical) {
|
|
15
13
|
return [props.height - padding.bottom, padding.top];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return [padding.left, props.width - padding.right];
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
function getPolarRange(props, axis) {
|
|
22
18
|
if (axis === "x") {
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const startAngle = degreesToRadians(props.startAngle || 0);
|
|
20
|
+
const endAngle = degreesToRadians(props.endAngle || 360);
|
|
25
21
|
return [startAngle, endAngle];
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
return [props.innerRadius || 0, getRadius(props)];
|
|
29
|
-
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Exported Functions
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates an object composed of the inverted keys and values of object.
|
|
30
|
+
* If object contains duplicate values, subsequent values overwrite property assignments of previous values.
|
|
31
|
+
*/
|
|
32
|
+
export function invert(original) {
|
|
33
|
+
return Object.entries(original).reduce((acc, current) => {
|
|
34
|
+
acc[current[1]] = current[0];
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
}
|
|
30
38
|
|
|
31
39
|
/**
|
|
32
40
|
* creates an object with some keys excluded
|
|
@@ -35,44 +43,39 @@ function getPolarRange(props, axis) {
|
|
|
35
43
|
* @param {Array<String>} ks: an array of keys to omit from the new object
|
|
36
44
|
* @returns {Object} new object with same properties as originalObject
|
|
37
45
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
export function omit(originalObject, ks) {
|
|
47
|
+
if (ks === void 0) {
|
|
48
|
+
ks = [];
|
|
49
|
+
}
|
|
42
50
|
// code based on babel's _objectWithoutProperties
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (var key in originalObject) {
|
|
51
|
+
const newObject = {};
|
|
52
|
+
for (const key in originalObject) {
|
|
46
53
|
// @ts-expect-error String is not assignable to Key
|
|
47
54
|
if (ks.indexOf(key) >= 0) {
|
|
48
55
|
continue;
|
|
49
56
|
}
|
|
50
|
-
|
|
51
57
|
if (!Object.prototype.hasOwnProperty.call(originalObject, key)) {
|
|
52
58
|
continue;
|
|
53
59
|
}
|
|
54
|
-
|
|
55
60
|
newObject[key] = originalObject[key];
|
|
56
61
|
}
|
|
57
|
-
|
|
58
62
|
return newObject;
|
|
59
63
|
}
|
|
60
64
|
export function getPoint(datum) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var point = {
|
|
65
|
+
const exists = val => val !== undefined;
|
|
66
|
+
const {
|
|
67
|
+
_x,
|
|
68
|
+
_x1,
|
|
69
|
+
_x0,
|
|
70
|
+
_voronoiX,
|
|
71
|
+
_y,
|
|
72
|
+
_y1,
|
|
73
|
+
_y0,
|
|
74
|
+
_voronoiY
|
|
75
|
+
} = datum;
|
|
76
|
+
const defaultX = exists(_x1) ? _x1 : _x;
|
|
77
|
+
const defaultY = exists(_y1) ? _y1 : _y;
|
|
78
|
+
const point = {
|
|
76
79
|
x: exists(_voronoiX) ? _voronoiX : defaultX,
|
|
77
80
|
x0: exists(_x0) ? _x0 : _x,
|
|
78
81
|
y: exists(_voronoiY) ? _voronoiY : defaultY,
|
|
@@ -81,18 +84,20 @@ export function getPoint(datum) {
|
|
|
81
84
|
return _defaults({}, point, datum);
|
|
82
85
|
}
|
|
83
86
|
export function scalePoint(props, datum) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
const {
|
|
88
|
+
scale,
|
|
89
|
+
polar,
|
|
90
|
+
horizontal
|
|
91
|
+
} = props;
|
|
92
|
+
const d = getPoint(datum);
|
|
93
|
+
const origin = props.origin || {
|
|
89
94
|
x: 0,
|
|
90
95
|
y: 0
|
|
91
96
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
const x = horizontal ? scale.y(d.y) : scale.x(d.x);
|
|
98
|
+
const x0 = horizontal ? scale.y(d.y0) : scale.x(d.x0);
|
|
99
|
+
const y = horizontal ? scale.x(d.x) : scale.y(d.y);
|
|
100
|
+
const y0 = horizontal ? scale.x(d.x0) : scale.y(d.y0);
|
|
96
101
|
return {
|
|
97
102
|
x: polar ? y * Math.cos(x) + origin.x : x,
|
|
98
103
|
x0: polar ? y0 * Math.cos(x0) + origin.x : x0,
|
|
@@ -100,11 +105,13 @@ export function scalePoint(props, datum) {
|
|
|
100
105
|
y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
|
|
101
106
|
};
|
|
102
107
|
}
|
|
103
|
-
export function getPadding(props) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
export function getPadding(props, name) {
|
|
109
|
+
if (name === void 0) {
|
|
110
|
+
name = "padding";
|
|
111
|
+
}
|
|
112
|
+
const padding = props[name];
|
|
113
|
+
const paddingVal = typeof padding === "number" ? padding : 0;
|
|
114
|
+
const paddingObj = typeof padding === "object" ? padding : {};
|
|
108
115
|
return {
|
|
109
116
|
top: paddingObj.top || paddingVal,
|
|
110
117
|
bottom: paddingObj.bottom || paddingVal,
|
|
@@ -113,50 +120,47 @@ export function getPadding(props) {
|
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
122
|
export function isTooltip(component) {
|
|
116
|
-
|
|
123
|
+
const labelRole = component && component.type && component.type.role;
|
|
117
124
|
return labelRole === "tooltip";
|
|
118
125
|
}
|
|
119
126
|
export function getDefaultStyles(props, role) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
const {
|
|
128
|
+
theme = {},
|
|
129
|
+
labelComponent
|
|
130
|
+
} = props;
|
|
131
|
+
const defaultStyles = theme[role] && theme[role].style || {};
|
|
125
132
|
if (!isTooltip(labelComponent)) {
|
|
126
133
|
return defaultStyles;
|
|
127
134
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var labelStyle = _defaults({}, tooltipStyle, defaultStyles.labels);
|
|
132
|
-
|
|
135
|
+
const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
|
|
136
|
+
const labelStyle = _defaults({}, tooltipStyle, defaultStyles.labels);
|
|
133
137
|
return _defaults({}, {
|
|
134
138
|
labels: labelStyle
|
|
135
139
|
}, defaultStyles);
|
|
136
140
|
}
|
|
137
141
|
export function getStyles(style, defaultStyles) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
const width = "100%";
|
|
143
|
+
const height = "100%";
|
|
141
144
|
if (!style) {
|
|
142
145
|
return _defaults({
|
|
143
146
|
parent: {
|
|
144
|
-
height
|
|
145
|
-
width
|
|
147
|
+
height,
|
|
148
|
+
width
|
|
146
149
|
}
|
|
147
150
|
}, defaultStyles);
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
const {
|
|
153
|
+
data,
|
|
154
|
+
labels,
|
|
155
|
+
parent
|
|
156
|
+
} = style;
|
|
157
|
+
const defaultParent = defaultStyles && defaultStyles.parent || {};
|
|
158
|
+
const defaultLabels = defaultStyles && defaultStyles.labels || {};
|
|
159
|
+
const defaultData = defaultStyles && defaultStyles.data || {};
|
|
156
160
|
return {
|
|
157
161
|
parent: _defaults({}, parent, defaultParent, {
|
|
158
|
-
width
|
|
159
|
-
height
|
|
162
|
+
width,
|
|
163
|
+
height
|
|
160
164
|
}),
|
|
161
165
|
labels: _defaults({}, labels, defaultLabels),
|
|
162
166
|
data: _defaults({}, data, defaultData)
|
|
@@ -169,14 +173,10 @@ export function evaluateStyle(style, props) {
|
|
|
169
173
|
if (props.disableInlineStyles) {
|
|
170
174
|
return {};
|
|
171
175
|
}
|
|
172
|
-
|
|
173
|
-
if (!style || !Object.keys(style).some(function (value) {
|
|
174
|
-
return isFunction(style[value]);
|
|
175
|
-
})) {
|
|
176
|
+
if (!style || !Object.keys(style).some(value => isFunction(style[value]))) {
|
|
176
177
|
return style;
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
return Object.keys(style).reduce(function (prev, curr) {
|
|
179
|
+
return Object.keys(style).reduce((prev, curr) => {
|
|
180
180
|
prev[curr] = evaluateProp(style[curr], props);
|
|
181
181
|
return prev;
|
|
182
182
|
}, {});
|
|
@@ -188,29 +188,32 @@ export function radiansToDegrees(radians) {
|
|
|
188
188
|
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
|
|
189
189
|
}
|
|
190
190
|
export function getRadius(props) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
const {
|
|
192
|
+
left,
|
|
193
|
+
right,
|
|
194
|
+
top,
|
|
195
|
+
bottom
|
|
196
|
+
} = getPadding(props);
|
|
197
|
+
const {
|
|
198
|
+
width,
|
|
199
|
+
height
|
|
200
|
+
} = props;
|
|
199
201
|
return Math.min(width - left - right, height - top - bottom) / 2;
|
|
200
202
|
}
|
|
201
203
|
export function getPolarOrigin(props) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
const {
|
|
205
|
+
width,
|
|
206
|
+
height
|
|
207
|
+
} = props;
|
|
208
|
+
const {
|
|
209
|
+
top,
|
|
210
|
+
bottom,
|
|
211
|
+
left,
|
|
212
|
+
right
|
|
213
|
+
} = getPadding(props);
|
|
214
|
+
const radius = Math.min(width - left - right, height - top - bottom) / 2;
|
|
215
|
+
const offsetWidth = width / 2 + left - right;
|
|
216
|
+
const offsetHeight = height / 2 + top - bottom;
|
|
214
217
|
return {
|
|
215
218
|
x: offsetWidth + radius > width ? radius + left - right : offsetWidth,
|
|
216
219
|
y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
|
|
@@ -222,18 +225,18 @@ export function getRange(props, axis) {
|
|
|
222
225
|
} else if (props.range && Array.isArray(props.range)) {
|
|
223
226
|
return props.range;
|
|
224
227
|
}
|
|
225
|
-
|
|
226
228
|
return props.polar ? getPolarRange(props, axis) : getCartesianRange(props, axis);
|
|
227
229
|
}
|
|
230
|
+
|
|
228
231
|
/**
|
|
229
232
|
* Checks if `value` is `null` or `undefined`.
|
|
230
233
|
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
231
234
|
*/
|
|
232
|
-
|
|
233
235
|
export function isNil(value) {
|
|
234
236
|
// eslint-disable-next-line eqeqeq
|
|
235
237
|
return value == null;
|
|
236
238
|
}
|
|
239
|
+
|
|
237
240
|
/**
|
|
238
241
|
* Checks if `value` is classified as a `Function` object.
|
|
239
242
|
*
|
|
@@ -241,7 +244,6 @@ export function isNil(value) {
|
|
|
241
244
|
* @param {*} value The value to check.
|
|
242
245
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
243
246
|
*/
|
|
244
|
-
|
|
245
247
|
export function isFunction(value) {
|
|
246
248
|
return typeof value === "function";
|
|
247
249
|
}
|
|
@@ -252,47 +254,45 @@ export function createAccessor(key) {
|
|
|
252
254
|
return key;
|
|
253
255
|
} else if (key === null || key === undefined) {
|
|
254
256
|
// null/undefined means "return the data item itself"
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
} // otherwise, assume it is an array index, property key or path (_.property handles all three)
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
return x => x;
|
|
258
|
+
}
|
|
259
|
+
// otherwise, assume it is an array index, property key or path (_.property handles all three)
|
|
261
260
|
return _property(key);
|
|
262
261
|
}
|
|
263
262
|
export function modifyProps(props, fallbackProps, role) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
horizontal
|
|
263
|
+
const theme = props.theme && props.theme[role] ? props.theme[role] : {};
|
|
264
|
+
const themeProps = omit(theme, ["style"]);
|
|
265
|
+
const horizontal = isHorizontal(props);
|
|
266
|
+
const defaultObject = horizontal === undefined ? {} : {
|
|
267
|
+
horizontal
|
|
269
268
|
};
|
|
270
269
|
return _defaults(defaultObject, props, themeProps, fallbackProps);
|
|
271
270
|
}
|
|
271
|
+
|
|
272
272
|
/**
|
|
273
273
|
* Returns the given axis or the opposite axis when horizontal
|
|
274
274
|
* @param {string} axis: the given axis, either "x" pr "y"
|
|
275
275
|
* @param {Boolean} horizontal: true when the chart is flipped to the horizontal orientation
|
|
276
276
|
* @returns {String} the dimension appropriate for the axis given its props "x" or "y"
|
|
277
277
|
*/
|
|
278
|
-
|
|
279
278
|
export function getCurrentAxis(axis, horizontal) {
|
|
280
|
-
|
|
279
|
+
const otherAxis = axis === "x" ? "y" : "x";
|
|
281
280
|
return horizontal ? otherAxis : axis;
|
|
282
281
|
}
|
|
282
|
+
|
|
283
283
|
/**
|
|
284
284
|
* Creates an object with the same keys as object and values generated by running
|
|
285
285
|
* each own enumerable string keyed property of object through the function fn
|
|
286
286
|
*/
|
|
287
|
-
|
|
288
287
|
export function mapValues(values, fn) {
|
|
289
288
|
if (values) {
|
|
290
|
-
return Object.keys(values).reduce(
|
|
289
|
+
return Object.keys(values).reduce((acc, key) => {
|
|
291
290
|
acc[key] = fn(values[key]);
|
|
292
291
|
return acc;
|
|
293
292
|
}, {});
|
|
294
293
|
}
|
|
295
294
|
}
|
|
295
|
+
|
|
296
296
|
/**
|
|
297
297
|
* Creates an array of numbers (positive and/or negative) progressing
|
|
298
298
|
* from start up to, but not including, end.
|
|
@@ -303,28 +303,25 @@ export function mapValues(values, fn) {
|
|
|
303
303
|
* @param end [The end value] If this is defined, start is the start value
|
|
304
304
|
* @returns An array of the given length
|
|
305
305
|
*/
|
|
306
|
-
|
|
307
306
|
export function range(start, end, increment) {
|
|
308
307
|
// when the end index is not given, start from 0
|
|
309
|
-
|
|
308
|
+
const startIndex = end ? start : 0;
|
|
310
309
|
|
|
311
|
-
|
|
310
|
+
// when the end index is not given, the end of the range is the start index
|
|
311
|
+
let endIndex = end ? end : start;
|
|
312
312
|
|
|
313
|
+
// ensure endIndex is not a falsy value
|
|
313
314
|
if (!endIndex) endIndex = 0;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
var sign = k / length || 1; // the sign of the range (negative or positive)
|
|
315
|
+
const k = endIndex - startIndex; // the value range
|
|
316
|
+
const length = Math.abs(k); // the length of the range
|
|
317
|
+
const sign = k / length || 1; // the sign of the range (negative or positive)
|
|
318
|
+
const inc = increment || 1; // the step size of each increment
|
|
319
319
|
|
|
320
|
-
var inc = increment || 1; // the step size of each increment
|
|
321
320
|
// normalize the array length when dealing with floating point values
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return Array.from(Array(arrayLength), function (_, i) {
|
|
325
|
-
return startIndex + i * sign * inc;
|
|
326
|
-
});
|
|
321
|
+
const arrayLength = Math.max(Math.ceil(length / inc), 0);
|
|
322
|
+
return Array.from(Array(arrayLength), (_, i) => startIndex + i * sign * inc);
|
|
327
323
|
}
|
|
324
|
+
|
|
328
325
|
/**
|
|
329
326
|
* @param {Array} children: an array of child components
|
|
330
327
|
* @param {Function} iteratee: a function with arguments "child", "childName", and "parent"
|
|
@@ -334,78 +331,67 @@ export function range(start, end, increment) {
|
|
|
334
331
|
* to the memo for the next iteration step
|
|
335
332
|
* @returns {Array} returns an array of results from calling the iteratee on all nested children
|
|
336
333
|
*/
|
|
337
|
-
|
|
338
334
|
/* eslint-disable max-params */
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
335
|
+
export function reduceChildren(children, iteratee, parentProps,
|
|
336
|
+
// @ts-expect-error These defaults are hard to type
|
|
337
|
+
initialMemo, combine) {
|
|
338
|
+
if (parentProps === void 0) {
|
|
339
|
+
parentProps = {};
|
|
340
|
+
}
|
|
341
|
+
if (initialMemo === void 0) {
|
|
342
|
+
initialMemo = [];
|
|
343
|
+
}
|
|
344
|
+
if (combine === void 0) {
|
|
345
|
+
combine = (memo, item) =>
|
|
346
|
+
// @ts-expect-error These defaults are hard to type
|
|
347
|
+
memo.concat(item);
|
|
348
|
+
}
|
|
349
|
+
const sharedProps = ["data", "domain", "categories", "polar", "startAngle", "endAngle", "minDomain", "maxDomain", "horizontal"];
|
|
350
|
+
const traverseChildren = (childArray, names, parent) => {
|
|
351
|
+
return childArray.reduce((memo, child, index) => {
|
|
352
|
+
let newMemo = memo;
|
|
353
|
+
const childRole = child.type && child.type.role;
|
|
354
|
+
const childName = child.props.name || `${childRole}-${names[index]}`;
|
|
356
355
|
if (child.props && child.props.children) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
const childProps = Object.assign({}, child.props, _pick(parentProps, sharedProps));
|
|
357
|
+
const nestedChildren = child.type && child.type.role === "stack" && isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : React.Children.toArray(child.props.children).map(c => {
|
|
358
|
+
const nestedChildProps = Object.assign({}, c.props, _pick(childProps, sharedProps));
|
|
360
359
|
return /*#__PURE__*/React.cloneElement(c, nestedChildProps);
|
|
361
360
|
});
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return "".concat(childName, "-").concat(i);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
var nestedResults = traverseChildren(nestedChildren, _childNames, child);
|
|
361
|
+
const childNames = nestedChildren.map((c, i) => `${childName}-${i}`);
|
|
362
|
+
const nestedResults = traverseChildren(nestedChildren, childNames, child);
|
|
368
363
|
newMemo = combine(newMemo, nestedResults);
|
|
369
364
|
} else {
|
|
370
|
-
|
|
371
|
-
|
|
365
|
+
const result = iteratee(child, childName, parent);
|
|
372
366
|
if (result) {
|
|
373
367
|
newMemo = combine(newMemo, result);
|
|
374
368
|
}
|
|
375
369
|
}
|
|
376
|
-
|
|
377
370
|
return newMemo;
|
|
378
371
|
}, initialMemo);
|
|
379
372
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
var childNames = validChildren.map(function (c, i) {
|
|
383
|
-
return i;
|
|
384
|
-
});
|
|
373
|
+
const validChildren = children.filter(isValidElement);
|
|
374
|
+
const childNames = validChildren.map((c, i) => i);
|
|
385
375
|
return traverseChildren(validChildren, childNames);
|
|
386
376
|
}
|
|
377
|
+
|
|
387
378
|
/**
|
|
388
379
|
* @param {Object} props: the props object
|
|
389
380
|
* @returns {Boolean} returns true if the props object contains `horizontal: true` of if any
|
|
390
381
|
* children or nested children are horizontal
|
|
391
382
|
*/
|
|
392
|
-
|
|
393
383
|
export function isHorizontal(props) {
|
|
394
384
|
if (props.horizontal !== undefined || !props.children) {
|
|
395
385
|
return props.horizontal;
|
|
396
386
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var childProps = child.props || {};
|
|
401
|
-
|
|
387
|
+
const traverseChildren = childArray => {
|
|
388
|
+
return childArray.reduce((memo, child) => {
|
|
389
|
+
const childProps = child.props || {};
|
|
402
390
|
if (memo || childProps.horizontal || !childProps.children) {
|
|
403
391
|
return memo || childProps.horizontal;
|
|
404
392
|
}
|
|
405
|
-
|
|
406
393
|
return traverseChildren(React.Children.toArray(childProps.children));
|
|
407
394
|
}, false);
|
|
408
395
|
};
|
|
409
|
-
|
|
410
396
|
return traverseChildren(React.Children.toArray(props.children));
|
|
411
397
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { usePreviousProps } from "./use-previous-props";
|
|
2
|
-
export { useAnimationState } from "./use-animation-state";
|
|
1
|
+
export { usePreviousProps } from "./use-previous-props";
|
|
2
|
+
export { useAnimationState } from "./use-animation-state";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
declare type AnyObject = Record<string, any>;
|
|
2
|
-
export declare type AnimationState = {
|
|
3
|
-
nodesShouldLoad?: boolean;
|
|
4
|
-
nodesDoneLoad?: boolean;
|
|
5
|
-
animating?: boolean;
|
|
6
|
-
childrenTransitions?: any[];
|
|
7
|
-
nodesWillExit?: boolean;
|
|
8
|
-
nodesWillEnter?: boolean;
|
|
9
|
-
nodesShouldEnter?: boolean;
|
|
10
|
-
oldProps?: AnyObject;
|
|
11
|
-
nextProps?: AnyObject;
|
|
12
|
-
continuous?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare const useAnimationState: (initialState?: AnimationState) => {
|
|
15
|
-
state: AnimationState;
|
|
16
|
-
setState: (newState: AnimationState) => void;
|
|
17
|
-
getAnimationProps: (props: AnyObject | undefined, child: any, index: any) => any;
|
|
18
|
-
setAnimationState: (props: AnyObject | undefined, nextProps: any) => void;
|
|
19
|
-
getProps: (initialProps: AnyObject) => AnyObject;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
1
|
+
declare type AnyObject = Record<string, any>;
|
|
2
|
+
export declare type AnimationState = {
|
|
3
|
+
nodesShouldLoad?: boolean;
|
|
4
|
+
nodesDoneLoad?: boolean;
|
|
5
|
+
animating?: boolean;
|
|
6
|
+
childrenTransitions?: any[];
|
|
7
|
+
nodesWillExit?: boolean;
|
|
8
|
+
nodesWillEnter?: boolean;
|
|
9
|
+
nodesShouldEnter?: boolean;
|
|
10
|
+
oldProps?: AnyObject;
|
|
11
|
+
nextProps?: AnyObject;
|
|
12
|
+
continuous?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const useAnimationState: (initialState?: AnimationState) => {
|
|
15
|
+
state: AnimationState;
|
|
16
|
+
setState: (newState: AnimationState) => void;
|
|
17
|
+
getAnimationProps: (props: AnyObject | undefined, child: any, index: any) => any;
|
|
18
|
+
setAnimationState: (props: AnyObject | undefined, nextProps: any) => void;
|
|
19
|
+
getProps: (initialProps: AnyObject) => AnyObject;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
22
|
//# sourceMappingURL=use-animation-state.d.ts.map
|