victory-core 36.9.2 → 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 +6 -0
- package/dist/victory-core.js +4371 -5749
- package/dist/victory-core.min.js +1 -1
- package/es/victory-accessible-group/victory-accessible-group.js +9 -15
- package/es/victory-animation/util.js +28 -47
- package/es/victory-animation/victory-animation.js +51 -67
- package/es/victory-clip-container/victory-clip-container.js +153 -229
- package/es/victory-container/victory-container.js +157 -216
- package/es/victory-label/victory-label.js +246 -323
- package/es/victory-portal/portal-context.js +1 -2
- package/es/victory-portal/portal.js +30 -76
- package/es/victory-portal/victory-portal.js +47 -104
- package/es/victory-primitives/arc.js +44 -47
- package/es/victory-primitives/background.js +14 -17
- package/es/victory-primitives/border.js +20 -24
- package/es/victory-primitives/circle.js +13 -27
- package/es/victory-primitives/clip-path.js +3 -7
- package/es/victory-primitives/line-segment.js +20 -24
- package/es/victory-primitives/line.js +13 -27
- package/es/victory-primitives/path.js +13 -27
- package/es/victory-primitives/point.js +36 -40
- package/es/victory-primitives/rect.js +13 -27
- package/es/victory-primitives/text.js +15 -28
- package/es/victory-primitives/tspan.js +13 -26
- package/es/victory-primitives/whisker.js +43 -47
- package/es/victory-theme/grayscale.js +22 -22
- package/es/victory-theme/material.js +46 -46
- package/es/victory-theme/victory-theme.js +3 -3
- package/es/victory-transition/victory-transition.js +126 -206
- package/es/victory-util/add-events.js +263 -374
- package/es/victory-util/axis.js +126 -222
- package/es/victory-util/collection.js +13 -41
- package/es/victory-util/data.js +159 -214
- package/es/victory-util/default-transitions.js +33 -51
- package/es/victory-util/domain.js +122 -171
- package/es/victory-util/events.js +168 -258
- package/es/victory-util/helpers.js +153 -178
- package/es/victory-util/hooks/use-animation-state.js +61 -99
- package/es/victory-util/hooks/use-previous-props.js +2 -2
- package/es/victory-util/immutable.js +6 -8
- package/es/victory-util/label-helpers.js +128 -130
- package/es/victory-util/line-helpers.js +29 -41
- package/es/victory-util/log.js +1 -1
- package/es/victory-util/point-path-helpers.js +89 -49
- package/es/victory-util/scale.js +24 -42
- package/es/victory-util/selection.js +39 -40
- package/es/victory-util/style.js +8 -13
- package/es/victory-util/textsize.js +80 -154
- package/es/victory-util/timer-context.js +2 -2
- package/es/victory-util/timer.js +40 -76
- package/es/victory-util/transitions.js +110 -150
- package/es/victory-util/type-helpers.js +2 -3
- package/es/victory-util/user-props.js +24 -49
- package/es/victory-util/wrapper.js +184 -247
- package/lib/index.js +0 -30
- package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
- package/lib/victory-animation/util.js +28 -63
- package/lib/victory-animation/victory-animation.js +54 -83
- package/lib/victory-clip-container/victory-clip-container.js +156 -243
- package/lib/victory-container/victory-container.js +160 -232
- package/lib/victory-label/victory-label.js +248 -344
- package/lib/victory-portal/portal-context.js +1 -6
- package/lib/victory-portal/portal.js +31 -81
- package/lib/victory-portal/victory-portal.js +50 -116
- package/lib/victory-primitives/arc.js +48 -57
- package/lib/victory-primitives/background.js +16 -28
- package/lib/victory-primitives/border.js +22 -34
- package/lib/victory-primitives/circle.js +16 -36
- package/lib/victory-primitives/clip-path.js +3 -11
- package/lib/victory-primitives/index.js +0 -28
- package/lib/victory-primitives/line-segment.js +22 -34
- package/lib/victory-primitives/line.js +16 -36
- package/lib/victory-primitives/path.js +16 -36
- package/lib/victory-primitives/point.js +38 -52
- package/lib/victory-primitives/rect.js +16 -36
- package/lib/victory-primitives/text.js +15 -33
- package/lib/victory-primitives/tspan.js +13 -31
- package/lib/victory-primitives/whisker.js +45 -57
- package/lib/victory-theme/grayscale.js +23 -24
- package/lib/victory-theme/material.js +47 -48
- package/lib/victory-theme/victory-theme.js +2 -7
- package/lib/victory-transition/victory-transition.js +129 -224
- package/lib/victory-util/add-events.js +263 -380
- package/lib/victory-util/axis.js +128 -241
- package/lib/victory-util/collection.js +13 -50
- package/lib/victory-util/data.js +160 -239
- package/lib/victory-util/default-transitions.js +33 -54
- package/lib/victory-util/domain.js +123 -193
- package/lib/victory-util/events.js +167 -274
- package/lib/victory-util/helpers.js +156 -207
- package/lib/victory-util/hooks/index.js +0 -2
- package/lib/victory-util/hooks/use-animation-state.js +63 -113
- package/lib/victory-util/hooks/use-previous-props.js +2 -7
- package/lib/victory-util/immutable.js +6 -18
- package/lib/victory-util/index.js +2 -51
- package/lib/victory-util/label-helpers.js +130 -141
- package/lib/victory-util/line-helpers.js +31 -49
- package/lib/victory-util/log.js +1 -2
- package/lib/victory-util/point-path-helpers.js +91 -63
- package/lib/victory-util/scale.js +26 -57
- package/lib/victory-util/selection.js +41 -49
- package/lib/victory-util/style.js +8 -16
- package/lib/victory-util/textsize.js +80 -157
- package/lib/victory-util/timer-context.js +2 -8
- package/lib/victory-util/timer.js +40 -76
- package/lib/victory-util/transitions.js +110 -152
- package/lib/victory-util/type-helpers.js +2 -9
- package/lib/victory-util/user-props.js +25 -59
- package/lib/victory-util/wrapper.js +186 -281
- package/package.json +2 -2
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
// *
|
|
2
2
|
// * Colors
|
|
3
3
|
// *
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
const yellow200 = "#FFF59D";
|
|
5
|
+
const deepOrange600 = "#F4511E";
|
|
6
|
+
const lime300 = "#DCE775";
|
|
7
|
+
const lightGreen500 = "#8BC34A";
|
|
8
|
+
const teal700 = "#00796B";
|
|
9
|
+
const cyan900 = "#006064";
|
|
10
|
+
const colors = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
|
|
11
|
+
const blueGrey50 = "#ECEFF1";
|
|
12
|
+
const blueGrey300 = "#90A4AE";
|
|
13
|
+
const blueGrey700 = "#455A64";
|
|
14
|
+
const grey900 = "#212121";
|
|
15
|
+
// *
|
|
15
16
|
// * Typography
|
|
16
17
|
// *
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif";
|
|
19
|
+
const letterSpacing = "normal";
|
|
20
|
+
const fontSize = 12;
|
|
21
|
+
// *
|
|
21
22
|
// * Layout
|
|
22
23
|
// *
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var baseProps = {
|
|
24
|
+
const padding = 8;
|
|
25
|
+
const baseProps = {
|
|
26
26
|
width: 350,
|
|
27
27
|
height: 350,
|
|
28
28
|
padding: 50
|
|
29
|
-
};
|
|
29
|
+
};
|
|
30
|
+
// *
|
|
30
31
|
// * Labels
|
|
31
32
|
// *
|
|
32
|
-
|
|
33
|
-
var baseLabelStyles = {
|
|
33
|
+
const baseLabelStyles = {
|
|
34
34
|
fontFamily: sansSerif,
|
|
35
|
-
fontSize
|
|
36
|
-
letterSpacing
|
|
37
|
-
padding
|
|
35
|
+
fontSize,
|
|
36
|
+
letterSpacing,
|
|
37
|
+
padding,
|
|
38
38
|
fill: blueGrey700,
|
|
39
39
|
stroke: "transparent",
|
|
40
40
|
strokeWidth: 0
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
const centeredLabelStyles = Object.assign({
|
|
43
43
|
textAnchor: "middle"
|
|
44
|
-
}, baseLabelStyles);
|
|
44
|
+
}, baseLabelStyles);
|
|
45
|
+
// *
|
|
45
46
|
// * Strokes
|
|
46
47
|
// *
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export var material = {
|
|
48
|
+
const strokeDasharray = "10, 5";
|
|
49
|
+
const strokeLinecap = "round";
|
|
50
|
+
const strokeLinejoin = "round";
|
|
51
|
+
export const material = {
|
|
52
52
|
area: Object.assign({
|
|
53
53
|
style: {
|
|
54
54
|
data: {
|
|
@@ -63,19 +63,19 @@ export var material = {
|
|
|
63
63
|
fill: "transparent",
|
|
64
64
|
stroke: blueGrey300,
|
|
65
65
|
strokeWidth: 2,
|
|
66
|
-
strokeLinecap
|
|
67
|
-
strokeLinejoin
|
|
66
|
+
strokeLinecap,
|
|
67
|
+
strokeLinejoin
|
|
68
68
|
},
|
|
69
69
|
axisLabel: Object.assign({}, centeredLabelStyles, {
|
|
70
|
-
padding
|
|
70
|
+
padding,
|
|
71
71
|
stroke: "transparent"
|
|
72
72
|
}),
|
|
73
73
|
grid: {
|
|
74
74
|
fill: "none",
|
|
75
75
|
stroke: blueGrey50,
|
|
76
|
-
strokeDasharray
|
|
77
|
-
strokeLinecap
|
|
78
|
-
strokeLinejoin
|
|
76
|
+
strokeDasharray,
|
|
77
|
+
strokeLinecap,
|
|
78
|
+
strokeLinejoin,
|
|
79
79
|
pointerEvents: "painted"
|
|
80
80
|
},
|
|
81
81
|
ticks: {
|
|
@@ -83,8 +83,8 @@ export var material = {
|
|
|
83
83
|
size: 5,
|
|
84
84
|
stroke: blueGrey300,
|
|
85
85
|
strokeWidth: 1,
|
|
86
|
-
strokeLinecap
|
|
87
|
-
strokeLinejoin
|
|
86
|
+
strokeLinecap,
|
|
87
|
+
strokeLinejoin
|
|
88
88
|
},
|
|
89
89
|
tickLabels: Object.assign({}, baseLabelStyles, {
|
|
90
90
|
fill: blueGrey700
|
|
@@ -104,7 +104,7 @@ export var material = {
|
|
|
104
104
|
style: {
|
|
105
105
|
data: {
|
|
106
106
|
fill: blueGrey700,
|
|
107
|
-
padding
|
|
107
|
+
padding,
|
|
108
108
|
strokeWidth: 0
|
|
109
109
|
},
|
|
110
110
|
labels: baseLabelStyles
|
|
@@ -113,7 +113,7 @@ export var material = {
|
|
|
113
113
|
boxplot: Object.assign({
|
|
114
114
|
style: {
|
|
115
115
|
max: {
|
|
116
|
-
padding
|
|
116
|
+
padding,
|
|
117
117
|
stroke: blueGrey700,
|
|
118
118
|
strokeWidth: 1
|
|
119
119
|
},
|
|
@@ -121,7 +121,7 @@ export var material = {
|
|
|
121
121
|
padding: 3
|
|
122
122
|
}),
|
|
123
123
|
median: {
|
|
124
|
-
padding
|
|
124
|
+
padding,
|
|
125
125
|
stroke: blueGrey700,
|
|
126
126
|
strokeWidth: 1
|
|
127
127
|
},
|
|
@@ -129,7 +129,7 @@ export var material = {
|
|
|
129
129
|
padding: 3
|
|
130
130
|
}),
|
|
131
131
|
min: {
|
|
132
|
-
padding
|
|
132
|
+
padding,
|
|
133
133
|
stroke: blueGrey700,
|
|
134
134
|
strokeWidth: 1
|
|
135
135
|
},
|
|
@@ -137,14 +137,14 @@ export var material = {
|
|
|
137
137
|
padding: 3
|
|
138
138
|
}),
|
|
139
139
|
q1: {
|
|
140
|
-
padding
|
|
140
|
+
padding,
|
|
141
141
|
fill: blueGrey700
|
|
142
142
|
},
|
|
143
143
|
q1Labels: Object.assign({}, baseLabelStyles, {
|
|
144
144
|
padding: 3
|
|
145
145
|
}),
|
|
146
146
|
q3: {
|
|
147
|
-
padding
|
|
147
|
+
padding,
|
|
148
148
|
fill: blueGrey700
|
|
149
149
|
},
|
|
150
150
|
q3Labels: Object.assign({}, baseLabelStyles, {
|
|
@@ -223,7 +223,7 @@ export var material = {
|
|
|
223
223
|
colorScale: colors,
|
|
224
224
|
style: {
|
|
225
225
|
data: {
|
|
226
|
-
padding
|
|
226
|
+
padding,
|
|
227
227
|
stroke: blueGrey50,
|
|
228
228
|
strokeWidth: 1
|
|
229
229
|
},
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import _pick from "lodash/pick";
|
|
2
2
|
import _defaults from "lodash/defaults";
|
|
3
|
-
|
|
4
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
-
|
|
6
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
-
|
|
8
|
-
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); } }
|
|
9
|
-
|
|
10
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
-
|
|
12
|
-
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); }
|
|
13
|
-
|
|
14
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
-
|
|
16
|
-
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); }; }
|
|
17
|
-
|
|
18
|
-
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); }
|
|
19
|
-
|
|
20
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
|
-
|
|
22
|
-
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; } }
|
|
23
|
-
|
|
24
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
-
|
|
26
4
|
import React from "react";
|
|
27
5
|
import { VictoryAnimation } from "../victory-animation/victory-animation";
|
|
28
6
|
import * as Collection from "../victory-util/collection";
|
|
@@ -30,201 +8,143 @@ import * as Helpers from "../victory-util/helpers";
|
|
|
30
8
|
import TimerContext from "../victory-util/timer-context";
|
|
31
9
|
import * as Transitions from "../victory-util/transitions";
|
|
32
10
|
import isEqual from "react-fast-compare";
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var _this;
|
|
40
|
-
|
|
41
|
-
_classCallCheck(this, VictoryTransition);
|
|
42
|
-
|
|
43
|
-
_this = _super.call(this, props, context);
|
|
44
|
-
_this.continuous = void 0;
|
|
45
|
-
_this.timer = void 0;
|
|
46
|
-
_this.transitionProps = void 0;
|
|
47
|
-
_this.state = {
|
|
11
|
+
export class VictoryTransition extends React.Component {
|
|
12
|
+
static displayName = "VictoryTransition";
|
|
13
|
+
static contextType = TimerContext;
|
|
14
|
+
constructor(props, context) {
|
|
15
|
+
super(props, context);
|
|
16
|
+
this.state = {
|
|
48
17
|
nodesShouldLoad: false,
|
|
49
18
|
nodesDoneLoad: false
|
|
50
19
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return _this;
|
|
20
|
+
const child = this.props.children;
|
|
21
|
+
const polar = child.props.polar;
|
|
22
|
+
this.continuous = !polar && child.type && child.type.continuous === true;
|
|
23
|
+
this.timer = this.context.transitionTimer;
|
|
56
24
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
key: "shouldComponentUpdate",
|
|
67
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
68
|
-
var _this2 = this;
|
|
69
|
-
|
|
70
|
-
if (!isEqual(this.props, nextProps)) {
|
|
71
|
-
this.timer.bypassAnimation();
|
|
72
|
-
this.setState(this.getTransitionState(this.props, nextProps), function () {
|
|
73
|
-
return _this2.timer.resumeAnimation();
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "componentWillUnmount",
|
|
81
|
-
value: function componentWillUnmount() {
|
|
82
|
-
this.timer.stop();
|
|
25
|
+
componentDidMount() {
|
|
26
|
+
this.setState({
|
|
27
|
+
nodesShouldLoad: true
|
|
28
|
+
}); // eslint-disable-line react/no-did-mount-set-state
|
|
29
|
+
}
|
|
30
|
+
shouldComponentUpdate(nextProps) {
|
|
31
|
+
if (!isEqual(this.props, nextProps)) {
|
|
32
|
+
this.timer.bypassAnimation();
|
|
33
|
+
this.setState(this.getTransitionState(this.props, nextProps), () => this.timer.resumeAnimation());
|
|
83
34
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var oldChildren = React.Children.toArray(props.children);
|
|
101
|
-
var nextChildren = React.Children.toArray(nextProps.children);
|
|
102
|
-
|
|
103
|
-
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
|
|
104
|
-
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
105
|
-
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
106
|
-
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
107
|
-
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
108
|
-
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
componentWillUnmount() {
|
|
38
|
+
this.timer.stop();
|
|
39
|
+
}
|
|
40
|
+
getTransitionState(props, nextProps) {
|
|
41
|
+
const {
|
|
42
|
+
animate
|
|
43
|
+
} = props;
|
|
44
|
+
if (!animate) {
|
|
45
|
+
return {};
|
|
46
|
+
} else if (animate.parentState) {
|
|
47
|
+
const state = animate.parentState;
|
|
48
|
+
const oldProps = state.nodesWillExit ? props : null;
|
|
109
49
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
childrenTransitions: childrenTransitions,
|
|
113
|
-
nodesShouldEnter: nodesShouldEnter,
|
|
114
|
-
oldProps: nodesWillExit ? props : null,
|
|
115
|
-
nextProps: nextProps
|
|
50
|
+
oldProps,
|
|
51
|
+
nextProps
|
|
116
52
|
};
|
|
117
53
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
|
|
54
|
+
const oldChildren = React.Children.toArray(props.children);
|
|
55
|
+
const nextChildren = React.Children.toArray(nextProps.children);
|
|
56
|
+
const {
|
|
57
|
+
nodesWillExit,
|
|
58
|
+
nodesWillEnter,
|
|
59
|
+
childrenTransitions,
|
|
60
|
+
nodesShouldEnter
|
|
61
|
+
} = Transitions.getInitialTransitionState(oldChildren, nextChildren);
|
|
62
|
+
return {
|
|
63
|
+
nodesWillExit,
|
|
64
|
+
nodesWillEnter,
|
|
65
|
+
childrenTransitions,
|
|
66
|
+
nodesShouldEnter,
|
|
67
|
+
oldProps: nodesWillExit ? props : null,
|
|
68
|
+
nextProps
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
getDomainFromChildren(props, axis) {
|
|
72
|
+
const getChildDomains = children => {
|
|
73
|
+
return children.reduce((memo, child) => {
|
|
74
|
+
if (child.type && Helpers.isFunction(child.type.getDomain)) {
|
|
75
|
+
const childDomain = child.props && child.type.getDomain(child.props, axis);
|
|
76
|
+
return childDomain ? memo.concat(childDomain) : memo;
|
|
77
|
+
} else if (child.props && child.props.children) {
|
|
78
|
+
return memo.concat(getChildDomains(React.Children.toArray(child.props.children)));
|
|
79
|
+
}
|
|
80
|
+
return memo;
|
|
81
|
+
}, []);
|
|
82
|
+
};
|
|
83
|
+
const child = React.Children.toArray(props.children)[0];
|
|
84
|
+
const childProps = child.props || {};
|
|
85
|
+
const domain = Array.isArray(childProps.domain) ? childProps.domain : childProps.domain && childProps.domain[axis];
|
|
86
|
+
if (!childProps.children && domain) {
|
|
87
|
+
return domain;
|
|
153
88
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (parentState && parentState.nodesWillExit) {
|
|
162
|
-
return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
|
|
89
|
+
const childDomains = getChildDomains([child]);
|
|
90
|
+
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
91
|
+
}
|
|
92
|
+
pickProps() {
|
|
93
|
+
if (!this.state) {
|
|
94
|
+
return this.props;
|
|
166
95
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
|
|
176
|
-
return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
|
|
96
|
+
return this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
|
|
97
|
+
}
|
|
98
|
+
pickDomainProps(props) {
|
|
99
|
+
const parentState = props.animate?.parentState;
|
|
100
|
+
if (parentState && parentState.nodesWillExit) {
|
|
101
|
+
return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
|
|
177
102
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
animate: null,
|
|
214
|
-
animating: true,
|
|
215
|
-
groupComponent: groupComponent
|
|
216
|
-
}, newProps, combinedProps));
|
|
217
|
-
}
|
|
218
|
-
|
|
103
|
+
return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
|
|
104
|
+
}
|
|
105
|
+
getClipWidth(props, child) {
|
|
106
|
+
const getDefaultClipWidth = () => {
|
|
107
|
+
const range = Helpers.getRange(child.props, "x");
|
|
108
|
+
return range ? Math.abs(range[1] - range[0]) : props.width;
|
|
109
|
+
};
|
|
110
|
+
const clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
|
|
111
|
+
return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
const props = this.pickProps();
|
|
115
|
+
const getTransitionProps = this.props.animate?.getTransitions ? this.props.animate.getTransitions : Transitions.getTransitionPropsFactory(props, this.state, newState => this.setState(newState));
|
|
116
|
+
const child = React.Children.toArray(props.children)[0];
|
|
117
|
+
const transitionProps = getTransitionProps(child);
|
|
118
|
+
this.transitionProps = transitionProps;
|
|
119
|
+
const domain = {
|
|
120
|
+
x: this.getDomainFromChildren(this.pickDomainProps(props), "x"),
|
|
121
|
+
y: this.getDomainFromChildren(props, "y")
|
|
122
|
+
};
|
|
123
|
+
const clipWidth = this.getClipWidth(props, child);
|
|
124
|
+
const combinedProps = _defaults({
|
|
125
|
+
domain,
|
|
126
|
+
clipWidth
|
|
127
|
+
}, transitionProps, child.props);
|
|
128
|
+
const animationWhitelist = props.animationWhitelist || [];
|
|
129
|
+
const whitelist = animationWhitelist.concat(["clipWidth"]);
|
|
130
|
+
const propsToAnimate = whitelist.length ? _pick(combinedProps, whitelist) : combinedProps;
|
|
131
|
+
return /*#__PURE__*/React.createElement(VictoryAnimation, _extends({}, combinedProps.animate, {
|
|
132
|
+
data: propsToAnimate
|
|
133
|
+
}), newProps => {
|
|
134
|
+
if (child.props.groupComponent) {
|
|
135
|
+
const groupComponent = this.continuous ? /*#__PURE__*/React.cloneElement(child.props.groupComponent, {
|
|
136
|
+
clipWidth: newProps.clipWidth || 0
|
|
137
|
+
}) : child.props.groupComponent;
|
|
219
138
|
return /*#__PURE__*/React.cloneElement(child, _defaults({
|
|
220
139
|
animate: null,
|
|
221
|
-
animating: true
|
|
140
|
+
animating: true,
|
|
141
|
+
groupComponent
|
|
222
142
|
}, newProps, combinedProps));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
143
|
+
}
|
|
144
|
+
return /*#__PURE__*/React.cloneElement(child, _defaults({
|
|
145
|
+
animate: null,
|
|
146
|
+
animating: true
|
|
147
|
+
}, newProps, combinedProps));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|