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
|
@@ -7,54 +7,54 @@ exports.material = void 0;
|
|
|
7
7
|
// *
|
|
8
8
|
// * Colors
|
|
9
9
|
// *
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
const yellow200 = "#FFF59D";
|
|
11
|
+
const deepOrange600 = "#F4511E";
|
|
12
|
+
const lime300 = "#DCE775";
|
|
13
|
+
const lightGreen500 = "#8BC34A";
|
|
14
|
+
const teal700 = "#00796B";
|
|
15
|
+
const cyan900 = "#006064";
|
|
16
|
+
const colors = [deepOrange600, yellow200, lime300, lightGreen500, teal700, cyan900];
|
|
17
|
+
const blueGrey50 = "#ECEFF1";
|
|
18
|
+
const blueGrey300 = "#90A4AE";
|
|
19
|
+
const blueGrey700 = "#455A64";
|
|
20
|
+
const grey900 = "#212121";
|
|
21
|
+
// *
|
|
21
22
|
// * Typography
|
|
22
23
|
// *
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const sansSerif = "'Helvetica Neue', 'Helvetica', sans-serif";
|
|
25
|
+
const letterSpacing = "normal";
|
|
26
|
+
const fontSize = 12;
|
|
27
|
+
// *
|
|
27
28
|
// * Layout
|
|
28
29
|
// *
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var baseProps = {
|
|
30
|
+
const padding = 8;
|
|
31
|
+
const baseProps = {
|
|
32
32
|
width: 350,
|
|
33
33
|
height: 350,
|
|
34
34
|
padding: 50
|
|
35
|
-
};
|
|
35
|
+
};
|
|
36
|
+
// *
|
|
36
37
|
// * Labels
|
|
37
38
|
// *
|
|
38
|
-
|
|
39
|
-
var baseLabelStyles = {
|
|
39
|
+
const baseLabelStyles = {
|
|
40
40
|
fontFamily: sansSerif,
|
|
41
|
-
fontSize
|
|
42
|
-
letterSpacing
|
|
43
|
-
padding
|
|
41
|
+
fontSize,
|
|
42
|
+
letterSpacing,
|
|
43
|
+
padding,
|
|
44
44
|
fill: blueGrey700,
|
|
45
45
|
stroke: "transparent",
|
|
46
46
|
strokeWidth: 0
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const centeredLabelStyles = Object.assign({
|
|
49
49
|
textAnchor: "middle"
|
|
50
|
-
}, baseLabelStyles);
|
|
50
|
+
}, baseLabelStyles);
|
|
51
|
+
// *
|
|
51
52
|
// * Strokes
|
|
52
53
|
// *
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var material = {
|
|
54
|
+
const strokeDasharray = "10, 5";
|
|
55
|
+
const strokeLinecap = "round";
|
|
56
|
+
const strokeLinejoin = "round";
|
|
57
|
+
const material = exports.material = {
|
|
58
58
|
area: Object.assign({
|
|
59
59
|
style: {
|
|
60
60
|
data: {
|
|
@@ -69,19 +69,19 @@ var material = {
|
|
|
69
69
|
fill: "transparent",
|
|
70
70
|
stroke: blueGrey300,
|
|
71
71
|
strokeWidth: 2,
|
|
72
|
-
strokeLinecap
|
|
73
|
-
strokeLinejoin
|
|
72
|
+
strokeLinecap,
|
|
73
|
+
strokeLinejoin
|
|
74
74
|
},
|
|
75
75
|
axisLabel: Object.assign({}, centeredLabelStyles, {
|
|
76
|
-
padding
|
|
76
|
+
padding,
|
|
77
77
|
stroke: "transparent"
|
|
78
78
|
}),
|
|
79
79
|
grid: {
|
|
80
80
|
fill: "none",
|
|
81
81
|
stroke: blueGrey50,
|
|
82
|
-
strokeDasharray
|
|
83
|
-
strokeLinecap
|
|
84
|
-
strokeLinejoin
|
|
82
|
+
strokeDasharray,
|
|
83
|
+
strokeLinecap,
|
|
84
|
+
strokeLinejoin,
|
|
85
85
|
pointerEvents: "painted"
|
|
86
86
|
},
|
|
87
87
|
ticks: {
|
|
@@ -89,8 +89,8 @@ var material = {
|
|
|
89
89
|
size: 5,
|
|
90
90
|
stroke: blueGrey300,
|
|
91
91
|
strokeWidth: 1,
|
|
92
|
-
strokeLinecap
|
|
93
|
-
strokeLinejoin
|
|
92
|
+
strokeLinecap,
|
|
93
|
+
strokeLinejoin
|
|
94
94
|
},
|
|
95
95
|
tickLabels: Object.assign({}, baseLabelStyles, {
|
|
96
96
|
fill: blueGrey700
|
|
@@ -110,7 +110,7 @@ var material = {
|
|
|
110
110
|
style: {
|
|
111
111
|
data: {
|
|
112
112
|
fill: blueGrey700,
|
|
113
|
-
padding
|
|
113
|
+
padding,
|
|
114
114
|
strokeWidth: 0
|
|
115
115
|
},
|
|
116
116
|
labels: baseLabelStyles
|
|
@@ -119,7 +119,7 @@ var material = {
|
|
|
119
119
|
boxplot: Object.assign({
|
|
120
120
|
style: {
|
|
121
121
|
max: {
|
|
122
|
-
padding
|
|
122
|
+
padding,
|
|
123
123
|
stroke: blueGrey700,
|
|
124
124
|
strokeWidth: 1
|
|
125
125
|
},
|
|
@@ -127,7 +127,7 @@ var material = {
|
|
|
127
127
|
padding: 3
|
|
128
128
|
}),
|
|
129
129
|
median: {
|
|
130
|
-
padding
|
|
130
|
+
padding,
|
|
131
131
|
stroke: blueGrey700,
|
|
132
132
|
strokeWidth: 1
|
|
133
133
|
},
|
|
@@ -135,7 +135,7 @@ var material = {
|
|
|
135
135
|
padding: 3
|
|
136
136
|
}),
|
|
137
137
|
min: {
|
|
138
|
-
padding
|
|
138
|
+
padding,
|
|
139
139
|
stroke: blueGrey700,
|
|
140
140
|
strokeWidth: 1
|
|
141
141
|
},
|
|
@@ -143,14 +143,14 @@ var material = {
|
|
|
143
143
|
padding: 3
|
|
144
144
|
}),
|
|
145
145
|
q1: {
|
|
146
|
-
padding
|
|
146
|
+
padding,
|
|
147
147
|
fill: blueGrey700
|
|
148
148
|
},
|
|
149
149
|
q1Labels: Object.assign({}, baseLabelStyles, {
|
|
150
150
|
padding: 3
|
|
151
151
|
}),
|
|
152
152
|
q3: {
|
|
153
|
-
padding
|
|
153
|
+
padding,
|
|
154
154
|
fill: blueGrey700
|
|
155
155
|
},
|
|
156
156
|
q3Labels: Object.assign({}, baseLabelStyles, {
|
|
@@ -229,7 +229,7 @@ var material = {
|
|
|
229
229
|
colorScale: colors,
|
|
230
230
|
style: {
|
|
231
231
|
data: {
|
|
232
|
-
padding
|
|
232
|
+
padding,
|
|
233
233
|
stroke: blueGrey50,
|
|
234
234
|
strokeWidth: 1
|
|
235
235
|
},
|
|
@@ -286,5 +286,4 @@ var material = {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
}, baseProps)
|
|
289
|
-
};
|
|
290
|
-
exports.material = material;
|
|
289
|
+
};
|
|
@@ -7,13 +7,9 @@ var _exportNames = {
|
|
|
7
7
|
VictoryTheme: true
|
|
8
8
|
};
|
|
9
9
|
exports.VictoryTheme = void 0;
|
|
10
|
-
|
|
11
10
|
var _grayscale = require("./grayscale");
|
|
12
|
-
|
|
13
11
|
var _material = require("./material");
|
|
14
|
-
|
|
15
12
|
var _types = require("./types");
|
|
16
|
-
|
|
17
13
|
Object.keys(_types).forEach(function (key) {
|
|
18
14
|
if (key === "default" || key === "__esModule") return;
|
|
19
15
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -25,8 +21,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
25
21
|
}
|
|
26
22
|
});
|
|
27
23
|
});
|
|
28
|
-
|
|
24
|
+
const VictoryTheme = exports.VictoryTheme = {
|
|
29
25
|
grayscale: _grayscale.grayscale,
|
|
30
26
|
material: _material.material
|
|
31
|
-
};
|
|
32
|
-
exports.VictoryTheme = VictoryTheme;
|
|
27
|
+
};
|
|
@@ -4,252 +4,157 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VictoryTransition = void 0;
|
|
7
|
-
|
|
8
7
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
9
|
-
|
|
10
8
|
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _victoryAnimation = require("../victory-animation/victory-animation");
|
|
15
|
-
|
|
16
11
|
var Collection = _interopRequireWildcard(require("../victory-util/collection"));
|
|
17
|
-
|
|
18
12
|
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
|
|
19
|
-
|
|
20
13
|
var _timerContext = _interopRequireDefault(require("../victory-util/timer-context"));
|
|
21
|
-
|
|
22
14
|
var Transitions = _interopRequireWildcard(require("../victory-util/transitions"));
|
|
23
|
-
|
|
24
15
|
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
30
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
19
|
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); }
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
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); }
|
|
41
|
-
|
|
42
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
43
|
-
|
|
44
|
-
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); }; }
|
|
45
|
-
|
|
46
|
-
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); }
|
|
47
|
-
|
|
48
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
|
-
|
|
50
|
-
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; } }
|
|
51
|
-
|
|
52
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
|
-
|
|
54
|
-
var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
55
|
-
_inherits(VictoryTransition, _React$Component);
|
|
56
|
-
|
|
57
|
-
var _super = _createSuper(VictoryTransition);
|
|
58
|
-
|
|
59
|
-
function VictoryTransition(props, context) {
|
|
60
|
-
var _this;
|
|
61
|
-
|
|
62
|
-
_classCallCheck(this, VictoryTransition);
|
|
63
|
-
|
|
64
|
-
_this = _super.call(this, props, context);
|
|
65
|
-
_this.continuous = void 0;
|
|
66
|
-
_this.timer = void 0;
|
|
67
|
-
_this.transitionProps = void 0;
|
|
68
|
-
_this.state = {
|
|
20
|
+
class VictoryTransition extends _react.default.Component {
|
|
21
|
+
static displayName = "VictoryTransition";
|
|
22
|
+
static contextType = _timerContext.default;
|
|
23
|
+
constructor(props, context) {
|
|
24
|
+
super(props, context);
|
|
25
|
+
this.state = {
|
|
69
26
|
nodesShouldLoad: false,
|
|
70
27
|
nodesDoneLoad: false
|
|
71
28
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return _this;
|
|
29
|
+
const child = this.props.children;
|
|
30
|
+
const polar = child.props.polar;
|
|
31
|
+
this.continuous = !polar && child.type && child.type.continuous === true;
|
|
32
|
+
this.timer = this.context.transitionTimer;
|
|
77
33
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
key: "shouldComponentUpdate",
|
|
88
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
89
|
-
var _this2 = this;
|
|
90
|
-
|
|
91
|
-
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
92
|
-
this.timer.bypassAnimation();
|
|
93
|
-
this.setState(this.getTransitionState(this.props, nextProps), function () {
|
|
94
|
-
return _this2.timer.resumeAnimation();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "componentWillUnmount",
|
|
102
|
-
value: function componentWillUnmount() {
|
|
103
|
-
this.timer.stop();
|
|
34
|
+
componentDidMount() {
|
|
35
|
+
this.setState({
|
|
36
|
+
nodesShouldLoad: true
|
|
37
|
+
}); // eslint-disable-line react/no-did-mount-set-state
|
|
38
|
+
}
|
|
39
|
+
shouldComponentUpdate(nextProps) {
|
|
40
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
41
|
+
this.timer.bypassAnimation();
|
|
42
|
+
this.setState(this.getTransitionState(this.props, nextProps), () => this.timer.resumeAnimation());
|
|
104
43
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var oldChildren = _react.default.Children.toArray(props.children);
|
|
122
|
-
|
|
123
|
-
var nextChildren = _react.default.Children.toArray(nextProps.children);
|
|
124
|
-
|
|
125
|
-
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
|
|
126
|
-
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
127
|
-
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
128
|
-
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
129
|
-
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
130
|
-
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
componentWillUnmount() {
|
|
47
|
+
this.timer.stop();
|
|
48
|
+
}
|
|
49
|
+
getTransitionState(props, nextProps) {
|
|
50
|
+
const {
|
|
51
|
+
animate
|
|
52
|
+
} = props;
|
|
53
|
+
if (!animate) {
|
|
54
|
+
return {};
|
|
55
|
+
} else if (animate.parentState) {
|
|
56
|
+
const state = animate.parentState;
|
|
57
|
+
const oldProps = state.nodesWillExit ? props : null;
|
|
131
58
|
return {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
childrenTransitions: childrenTransitions,
|
|
135
|
-
nodesShouldEnter: nodesShouldEnter,
|
|
136
|
-
oldProps: nodesWillExit ? props : null,
|
|
137
|
-
nextProps: nextProps
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "getDomainFromChildren",
|
|
142
|
-
value: function getDomainFromChildren(props, axis) {
|
|
143
|
-
var getChildDomains = function (children) {
|
|
144
|
-
return children.reduce(function (memo, child) {
|
|
145
|
-
if (child.type && Helpers.isFunction(child.type.getDomain)) {
|
|
146
|
-
var childDomain = child.props && child.type.getDomain(child.props, axis);
|
|
147
|
-
return childDomain ? memo.concat(childDomain) : memo;
|
|
148
|
-
} else if (child.props && child.props.children) {
|
|
149
|
-
return memo.concat(getChildDomains(_react.default.Children.toArray(child.props.children)));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return memo;
|
|
153
|
-
}, []);
|
|
59
|
+
oldProps,
|
|
60
|
+
nextProps
|
|
154
61
|
};
|
|
155
|
-
|
|
156
|
-
var child = _react.default.Children.toArray(props.children)[0];
|
|
157
|
-
|
|
158
|
-
var childProps = child.props || {};
|
|
159
|
-
var domain = Array.isArray(childProps.domain) ? childProps.domain : childProps.domain && childProps.domain[axis];
|
|
160
|
-
|
|
161
|
-
if (!childProps.children && domain) {
|
|
162
|
-
return domain;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
var childDomains = getChildDomains([child]);
|
|
166
|
-
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
167
62
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
63
|
+
const oldChildren = _react.default.Children.toArray(props.children);
|
|
64
|
+
const nextChildren = _react.default.Children.toArray(nextProps.children);
|
|
65
|
+
const {
|
|
66
|
+
nodesWillExit,
|
|
67
|
+
nodesWillEnter,
|
|
68
|
+
childrenTransitions,
|
|
69
|
+
nodesShouldEnter
|
|
70
|
+
} = Transitions.getInitialTransitionState(oldChildren, nextChildren);
|
|
71
|
+
return {
|
|
72
|
+
nodesWillExit,
|
|
73
|
+
nodesWillEnter,
|
|
74
|
+
childrenTransitions,
|
|
75
|
+
nodesShouldEnter,
|
|
76
|
+
oldProps: nodesWillExit ? props : null,
|
|
77
|
+
nextProps
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
getDomainFromChildren(props, axis) {
|
|
81
|
+
const getChildDomains = children => {
|
|
82
|
+
return children.reduce((memo, child) => {
|
|
83
|
+
if (child.type && Helpers.isFunction(child.type.getDomain)) {
|
|
84
|
+
const childDomain = child.props && child.type.getDomain(child.props, axis);
|
|
85
|
+
return childDomain ? memo.concat(childDomain) : memo;
|
|
86
|
+
} else if (child.props && child.props.children) {
|
|
87
|
+
return memo.concat(getChildDomains(_react.default.Children.toArray(child.props.children)));
|
|
88
|
+
}
|
|
89
|
+
return memo;
|
|
90
|
+
}, []);
|
|
91
|
+
};
|
|
92
|
+
const child = _react.default.Children.toArray(props.children)[0];
|
|
93
|
+
const childProps = child.props || {};
|
|
94
|
+
const domain = Array.isArray(childProps.domain) ? childProps.domain : childProps.domain && childProps.domain[axis];
|
|
95
|
+
if (!childProps.children && domain) {
|
|
96
|
+
return domain;
|
|
176
97
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (parentState && parentState.nodesWillExit) {
|
|
185
|
-
return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
|
|
98
|
+
const childDomains = getChildDomains([child]);
|
|
99
|
+
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
100
|
+
}
|
|
101
|
+
pickProps() {
|
|
102
|
+
if (!this.state) {
|
|
103
|
+
return this.props;
|
|
189
104
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
var clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
|
|
199
|
-
return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
|
|
105
|
+
return this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
|
|
106
|
+
}
|
|
107
|
+
pickDomainProps(props) {
|
|
108
|
+
const parentState = props.animate?.parentState;
|
|
109
|
+
if (parentState && parentState.nodesWillExit) {
|
|
110
|
+
return this.continuous || parentState.continuous ? parentState.nextProps || this.state.nextProps || props : props;
|
|
200
111
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
animate: null,
|
|
237
|
-
animating: true,
|
|
238
|
-
groupComponent: groupComponent
|
|
239
|
-
}, newProps, combinedProps));
|
|
240
|
-
}
|
|
241
|
-
|
|
112
|
+
return this.continuous && this.state.nodesWillExit ? this.state.nextProps || props : props;
|
|
113
|
+
}
|
|
114
|
+
getClipWidth(props, child) {
|
|
115
|
+
const getDefaultClipWidth = () => {
|
|
116
|
+
const range = Helpers.getRange(child.props, "x");
|
|
117
|
+
return range ? Math.abs(range[1] - range[0]) : props.width;
|
|
118
|
+
};
|
|
119
|
+
const clipWidth = this.transitionProps ? this.transitionProps.clipWidth : undefined;
|
|
120
|
+
return clipWidth !== undefined ? clipWidth : getDefaultClipWidth();
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
const props = this.pickProps();
|
|
124
|
+
const getTransitionProps = this.props.animate?.getTransitions ? this.props.animate.getTransitions : Transitions.getTransitionPropsFactory(props, this.state, newState => this.setState(newState));
|
|
125
|
+
const child = _react.default.Children.toArray(props.children)[0];
|
|
126
|
+
const transitionProps = getTransitionProps(child);
|
|
127
|
+
this.transitionProps = transitionProps;
|
|
128
|
+
const domain = {
|
|
129
|
+
x: this.getDomainFromChildren(this.pickDomainProps(props), "x"),
|
|
130
|
+
y: this.getDomainFromChildren(props, "y")
|
|
131
|
+
};
|
|
132
|
+
const clipWidth = this.getClipWidth(props, child);
|
|
133
|
+
const combinedProps = (0, _defaults2.default)({
|
|
134
|
+
domain,
|
|
135
|
+
clipWidth
|
|
136
|
+
}, transitionProps, child.props);
|
|
137
|
+
const animationWhitelist = props.animationWhitelist || [];
|
|
138
|
+
const whitelist = animationWhitelist.concat(["clipWidth"]);
|
|
139
|
+
const propsToAnimate = whitelist.length ? (0, _pick2.default)(combinedProps, whitelist) : combinedProps;
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement(_victoryAnimation.VictoryAnimation, _extends({}, combinedProps.animate, {
|
|
141
|
+
data: propsToAnimate
|
|
142
|
+
}), newProps => {
|
|
143
|
+
if (child.props.groupComponent) {
|
|
144
|
+
const groupComponent = this.continuous ? /*#__PURE__*/_react.default.cloneElement(child.props.groupComponent, {
|
|
145
|
+
clipWidth: newProps.clipWidth || 0
|
|
146
|
+
}) : child.props.groupComponent;
|
|
242
147
|
return /*#__PURE__*/_react.default.cloneElement(child, (0, _defaults2.default)({
|
|
243
148
|
animate: null,
|
|
244
|
-
animating: true
|
|
149
|
+
animating: true,
|
|
150
|
+
groupComponent
|
|
245
151
|
}, newProps, combinedProps));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
VictoryTransition
|
|
255
|
-
VictoryTransition.contextType = _timerContext.default;
|
|
152
|
+
}
|
|
153
|
+
return /*#__PURE__*/_react.default.cloneElement(child, (0, _defaults2.default)({
|
|
154
|
+
animate: null,
|
|
155
|
+
animating: true
|
|
156
|
+
}, newProps, combinedProps));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.VictoryTransition = VictoryTransition;
|