victory-group 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-group.js +2502 -3375
- package/dist/victory-group.min.js +1 -1
- package/es/helper-methods.js +131 -156
- package/es/victory-group.js +61 -73
- package/lib/helper-methods.js +132 -175
- package/lib/index.js +0 -2
- package/lib/victory-group.js +60 -92
- package/package.json +3 -3
package/es/helper-methods.js
CHANGED
|
@@ -1,242 +1,217 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
-
|
|
9
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
-
|
|
11
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
|
|
13
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
-
|
|
17
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
-
|
|
19
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
|
|
21
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
-
|
|
23
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
-
|
|
25
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
-
|
|
27
1
|
/* eslint-disable no-use-before-define */
|
|
28
2
|
import React from "react";
|
|
29
3
|
import { Data, Helpers, Scale, Wrapper } from "victory-core";
|
|
30
4
|
import isEqual from "react-fast-compare";
|
|
31
|
-
|
|
5
|
+
const fallbackProps = {
|
|
32
6
|
width: 450,
|
|
33
7
|
height: 300,
|
|
34
8
|
padding: 50,
|
|
35
9
|
offset: 0
|
|
36
|
-
};
|
|
10
|
+
};
|
|
37
11
|
|
|
12
|
+
// eslint-disable-next-line max-statements
|
|
38
13
|
export function getCalculatedProps(initialProps, childComponents) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
14
|
+
const role = "group";
|
|
15
|
+
const props = Helpers.modifyProps(initialProps, fallbackProps, role);
|
|
16
|
+
const style = Wrapper.getStyle(props.theme, props.style, role);
|
|
17
|
+
const {
|
|
18
|
+
offset,
|
|
19
|
+
colorScale,
|
|
20
|
+
color,
|
|
21
|
+
polar,
|
|
22
|
+
horizontal
|
|
23
|
+
} = props;
|
|
24
|
+
const categories = props.categories || Wrapper.getCategories(props, childComponents, null);
|
|
25
|
+
const datasets = props.datasets || Wrapper.getDataFromChildren(props, null);
|
|
26
|
+
const domain = {
|
|
50
27
|
x: Wrapper.getDomain(Object.assign({}, props, {
|
|
51
|
-
categories
|
|
28
|
+
categories
|
|
52
29
|
}), "x", childComponents),
|
|
53
30
|
y: Wrapper.getDomain(Object.assign({}, props, {
|
|
54
|
-
categories
|
|
31
|
+
categories
|
|
55
32
|
}), "y", childComponents)
|
|
56
33
|
};
|
|
57
|
-
|
|
34
|
+
const range = props.range || {
|
|
58
35
|
x: Helpers.getRange(props, "x"),
|
|
59
36
|
y: Helpers.getRange(props, "y")
|
|
60
37
|
};
|
|
61
|
-
|
|
38
|
+
const baseScale = {
|
|
62
39
|
x: Scale.getScaleFromProps(props, "x") || Wrapper.getScale(props, "x"),
|
|
63
40
|
y: Scale.getScaleFromProps(props, "y") || Wrapper.getScale(props, "y")
|
|
64
41
|
};
|
|
65
|
-
|
|
42
|
+
const scale = {
|
|
66
43
|
x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
|
|
67
44
|
y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
|
|
68
45
|
};
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
const origin = polar ? props.origin : Helpers.getPolarOrigin(props);
|
|
47
|
+
const padding = Helpers.getPadding(props);
|
|
71
48
|
return {
|
|
72
|
-
datasets
|
|
73
|
-
categories
|
|
74
|
-
range
|
|
75
|
-
domain
|
|
76
|
-
horizontal
|
|
77
|
-
scale
|
|
78
|
-
style
|
|
79
|
-
colorScale
|
|
80
|
-
color
|
|
81
|
-
offset
|
|
82
|
-
origin
|
|
83
|
-
padding
|
|
49
|
+
datasets,
|
|
50
|
+
categories,
|
|
51
|
+
range,
|
|
52
|
+
domain,
|
|
53
|
+
horizontal,
|
|
54
|
+
scale,
|
|
55
|
+
style,
|
|
56
|
+
colorScale,
|
|
57
|
+
color,
|
|
58
|
+
offset,
|
|
59
|
+
origin,
|
|
60
|
+
padding
|
|
84
61
|
};
|
|
85
|
-
}
|
|
86
|
-
// With shared events, the props change on every event, and every value is re-calculated
|
|
62
|
+
}
|
|
87
63
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
64
|
+
// We need to remove sharedEvents in order to memoize the calculated data
|
|
65
|
+
// With shared events, the props change on every event, and every value is re-calculated
|
|
66
|
+
const withoutSharedEvents = props => {
|
|
67
|
+
const {
|
|
68
|
+
children
|
|
69
|
+
} = props;
|
|
70
|
+
const modifiedChildren = React.Children.toArray(children).map(child => {
|
|
71
|
+
return {
|
|
72
|
+
...child,
|
|
92
73
|
props: Helpers.omit(child.props, ["sharedEvents"])
|
|
93
|
-
}
|
|
74
|
+
};
|
|
94
75
|
});
|
|
95
76
|
props.children = modifiedChildren;
|
|
96
77
|
return props;
|
|
97
78
|
};
|
|
98
|
-
|
|
99
79
|
export function useMemoizedProps(initialProps) {
|
|
100
|
-
|
|
80
|
+
const modifiedProps = withoutSharedEvents(initialProps);
|
|
81
|
+
const [props, setProps] = React.useState(modifiedProps);
|
|
101
82
|
|
|
102
|
-
|
|
103
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
104
|
-
props = _React$useState2[0],
|
|
105
|
-
setProps = _React$useState2[1]; // React.memo uses shallow equality to compare objects. This way props
|
|
83
|
+
// React.memo uses shallow equality to compare objects. This way props
|
|
106
84
|
// will only be re-calculated when they change.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
React.useEffect(function () {
|
|
85
|
+
React.useEffect(() => {
|
|
110
86
|
if (!isEqual(modifiedProps, props)) {
|
|
111
87
|
setProps(modifiedProps);
|
|
112
88
|
}
|
|
113
89
|
}, [props, setProps, modifiedProps]);
|
|
114
|
-
return React.useMemo(
|
|
90
|
+
return React.useMemo(() => {
|
|
115
91
|
return getCalculatedProps(props, props.children);
|
|
116
92
|
}, [props]);
|
|
117
93
|
}
|
|
118
|
-
|
|
119
94
|
function pixelsToValue(props, axis, calculatedProps) {
|
|
120
95
|
if (!props.offset) {
|
|
121
96
|
return 0;
|
|
122
97
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var rangeExtent = Math.max.apply(Math, _toConsumableArray(range)) - Math.min.apply(Math, _toConsumableArray(range));
|
|
98
|
+
const currentAxis = Helpers.getCurrentAxis(axis, props.horizontal);
|
|
99
|
+
const domain = calculatedProps.domain[axis];
|
|
100
|
+
const range = calculatedProps.range[currentAxis];
|
|
101
|
+
const domainExtent = Math.max(...domain) - Math.min(...domain);
|
|
102
|
+
const rangeExtent = Math.max(...range) - Math.min(...range);
|
|
129
103
|
return domainExtent / rangeExtent * props.offset;
|
|
130
|
-
}
|
|
131
|
-
|
|
104
|
+
}
|
|
132
105
|
|
|
106
|
+
// eslint-disable-next-line max-params
|
|
133
107
|
function getX0(props, calculatedProps, index, role) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
108
|
+
const groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
|
|
109
|
+
const center = (groupLength - 1) / 2;
|
|
110
|
+
const totalWidth = pixelsToValue(props, "x", calculatedProps);
|
|
137
111
|
return (index - center) * totalWidth;
|
|
138
|
-
}
|
|
139
|
-
|
|
112
|
+
}
|
|
140
113
|
|
|
114
|
+
// eslint-disable-next-line max-params
|
|
141
115
|
function getPolarX0(props, calculatedProps, index, role) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
116
|
+
const groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
|
|
117
|
+
const center = (groupLength - 1) / 2;
|
|
118
|
+
const width = getAngularWidth(props, calculatedProps);
|
|
145
119
|
return (index - center) * width;
|
|
146
120
|
}
|
|
147
|
-
|
|
148
121
|
function getAngularWidth(props, calculatedProps) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
122
|
+
const {
|
|
123
|
+
range
|
|
124
|
+
} = calculatedProps;
|
|
125
|
+
const angularRange = Math.abs(range.x[1] - range.x[0]);
|
|
126
|
+
const r = Math.max(...range.y);
|
|
152
127
|
return props.offset / (2 * Math.PI * r) * angularRange;
|
|
153
128
|
}
|
|
154
|
-
|
|
155
129
|
function getLabels(props, datasets, index) {
|
|
156
130
|
if (!props.labels) {
|
|
157
131
|
return undefined;
|
|
158
132
|
}
|
|
159
|
-
|
|
160
133
|
return Math.floor(datasets.length / 2) === index ? props.labels : undefined;
|
|
161
134
|
}
|
|
162
|
-
|
|
163
135
|
function getChildProps(props, calculatedProps) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
136
|
+
const {
|
|
137
|
+
categories,
|
|
138
|
+
domain,
|
|
139
|
+
range,
|
|
140
|
+
scale,
|
|
141
|
+
horizontal,
|
|
142
|
+
origin,
|
|
143
|
+
padding
|
|
144
|
+
} = calculatedProps;
|
|
145
|
+
const {
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
theme,
|
|
149
|
+
polar
|
|
150
|
+
} = props;
|
|
175
151
|
return {
|
|
176
|
-
height
|
|
177
|
-
width
|
|
178
|
-
theme
|
|
179
|
-
polar
|
|
180
|
-
origin
|
|
181
|
-
categories
|
|
182
|
-
domain
|
|
183
|
-
range
|
|
184
|
-
scale
|
|
185
|
-
horizontal
|
|
186
|
-
padding
|
|
152
|
+
height,
|
|
153
|
+
width,
|
|
154
|
+
theme,
|
|
155
|
+
polar,
|
|
156
|
+
origin,
|
|
157
|
+
categories,
|
|
158
|
+
domain,
|
|
159
|
+
range,
|
|
160
|
+
scale,
|
|
161
|
+
horizontal,
|
|
162
|
+
padding,
|
|
187
163
|
standalone: false
|
|
188
164
|
};
|
|
189
165
|
}
|
|
190
|
-
|
|
191
166
|
function getColorScale(props, child) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
167
|
+
const role = child.type && child.type.role;
|
|
168
|
+
const colorScaleOptions = child.props.colorScale || props.colorScale;
|
|
195
169
|
if (role !== "group" && role !== "stack") {
|
|
196
170
|
return undefined;
|
|
197
171
|
}
|
|
198
|
-
|
|
199
172
|
return props.theme && props.theme.group ? colorScaleOptions || props.theme.group.colorScale : colorScaleOptions;
|
|
200
173
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return dataset.map(
|
|
208
|
-
|
|
209
|
-
|
|
174
|
+
function getDataWithOffset(props, defaultDataset, offset) {
|
|
175
|
+
if (defaultDataset === void 0) {
|
|
176
|
+
defaultDataset = [];
|
|
177
|
+
}
|
|
178
|
+
const dataset = props.data || props.y ? Data.getData(props) : defaultDataset;
|
|
179
|
+
const xOffset = offset || 0;
|
|
180
|
+
return dataset.map(datum => {
|
|
181
|
+
const _x1 = datum._x instanceof Date ? new Date(datum._x.getTime() + xOffset) : datum._x + xOffset;
|
|
210
182
|
return Object.assign({}, datum, {
|
|
211
|
-
_x1
|
|
183
|
+
_x1
|
|
212
184
|
});
|
|
213
185
|
});
|
|
214
186
|
}
|
|
215
|
-
|
|
216
187
|
export function getChildren(initialProps, childComponents, calculatedProps) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
188
|
+
const props = Helpers.modifyProps(initialProps, fallbackProps, "stack");
|
|
189
|
+
const children = childComponents || React.Children.toArray(props.children);
|
|
190
|
+
const newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
|
|
191
|
+
const {
|
|
192
|
+
datasets
|
|
193
|
+
} = newCalculatedProps;
|
|
194
|
+
const {
|
|
195
|
+
labelComponent,
|
|
196
|
+
polar
|
|
197
|
+
} = props;
|
|
198
|
+
const childProps = getChildProps(props, newCalculatedProps);
|
|
199
|
+
const parentName = props.name || "group";
|
|
200
|
+
return children.map((child, index) => {
|
|
201
|
+
const role = child.type && child.type.role;
|
|
202
|
+
const xOffset = polar ? getPolarX0(props, newCalculatedProps, index, role) : getX0(props, newCalculatedProps, index, role);
|
|
203
|
+
const style = role === "voronoi" || role === "tooltip" || role === "label" ? child.props.style : Wrapper.getChildStyle(child, index, newCalculatedProps);
|
|
204
|
+
const labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
|
|
205
|
+
const name = child.props.name || `${parentName}-${role}-${index}`;
|
|
231
206
|
return /*#__PURE__*/React.cloneElement(child, Object.assign({
|
|
232
|
-
labels
|
|
233
|
-
style
|
|
234
|
-
key:
|
|
235
|
-
name
|
|
207
|
+
labels,
|
|
208
|
+
style,
|
|
209
|
+
key: `${name}-key-${index}`,
|
|
210
|
+
name,
|
|
236
211
|
data: getDataWithOffset(props, datasets[index], xOffset),
|
|
237
212
|
colorScale: getColorScale(props, child),
|
|
238
213
|
labelComponent: labelComponent || child.props.labelComponent,
|
|
239
|
-
xOffset
|
|
214
|
+
xOffset
|
|
240
215
|
}, childProps));
|
|
241
216
|
});
|
|
242
217
|
}
|
package/es/victory-group.js
CHANGED
|
@@ -1,115 +1,105 @@
|
|
|
1
1
|
import _isEmpty from "lodash/isEmpty";
|
|
2
2
|
import _defaults from "lodash/defaults";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
-
|
|
10
3
|
import React from "react";
|
|
11
4
|
import { Helpers, Hooks, UserProps, VictoryContainer, VictoryTheme, Wrapper } from "victory-core";
|
|
12
5
|
import { VictorySharedEvents } from "victory-shared-events";
|
|
13
6
|
import { getChildren, useMemoizedProps } from "./helper-methods";
|
|
14
7
|
import isEqual from "react-fast-compare";
|
|
15
|
-
|
|
8
|
+
const fallbackProps = {
|
|
16
9
|
width: 450,
|
|
17
10
|
height: 300,
|
|
18
11
|
padding: 50,
|
|
19
12
|
offset: 0
|
|
20
13
|
};
|
|
21
|
-
|
|
14
|
+
const defaultProps = {
|
|
22
15
|
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
23
16
|
groupComponent: /*#__PURE__*/React.createElement("g", null),
|
|
24
17
|
samples: 50,
|
|
25
18
|
standalone: true,
|
|
26
19
|
theme: VictoryTheme.grayscale
|
|
27
20
|
};
|
|
28
|
-
|
|
29
|
-
var VictoryGroupBase = function (initialProps) {
|
|
21
|
+
const VictoryGroupBase = initialProps => {
|
|
30
22
|
// eslint-disable-next-line no-use-before-define
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, [initialProps]);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
23
|
+
const role = VictoryGroup?.role;
|
|
24
|
+
const {
|
|
25
|
+
getAnimationProps,
|
|
26
|
+
setAnimationState,
|
|
27
|
+
getProps
|
|
28
|
+
} = Hooks.useAnimationState();
|
|
29
|
+
const propsWithDefaults = React.useMemo(() => ({
|
|
30
|
+
...defaultProps,
|
|
31
|
+
...initialProps
|
|
32
|
+
}), [initialProps]);
|
|
33
|
+
const props = getProps(propsWithDefaults);
|
|
34
|
+
const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
|
|
35
|
+
const {
|
|
36
|
+
eventKey,
|
|
37
|
+
containerComponent,
|
|
38
|
+
standalone,
|
|
39
|
+
groupComponent,
|
|
40
|
+
externalEventMutations,
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
theme,
|
|
44
|
+
polar,
|
|
45
|
+
horizontal,
|
|
46
|
+
name
|
|
47
|
+
} = modifiedProps;
|
|
48
|
+
const childComponents = React.Children.toArray(modifiedProps.children);
|
|
49
|
+
const calculatedProps = useMemoizedProps(modifiedProps);
|
|
50
|
+
const {
|
|
51
|
+
domain,
|
|
52
|
+
scale,
|
|
53
|
+
style,
|
|
54
|
+
origin
|
|
55
|
+
} = calculatedProps;
|
|
56
|
+
const newChildren = React.useMemo(() => {
|
|
57
|
+
const children = getChildren(props, childComponents, calculatedProps);
|
|
58
|
+
return children.map((child, index) => {
|
|
59
|
+
const childProps = Object.assign({
|
|
64
60
|
animate: getAnimationProps(props, child, index)
|
|
65
61
|
}, child.props);
|
|
66
62
|
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
67
63
|
});
|
|
68
64
|
}, [props, childComponents, calculatedProps, getAnimationProps]);
|
|
69
|
-
|
|
65
|
+
const containerProps = React.useMemo(() => {
|
|
70
66
|
if (standalone) {
|
|
71
67
|
return {
|
|
72
|
-
domain
|
|
73
|
-
scale
|
|
74
|
-
width
|
|
75
|
-
height
|
|
76
|
-
standalone
|
|
77
|
-
theme
|
|
68
|
+
domain,
|
|
69
|
+
scale,
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
standalone,
|
|
73
|
+
theme,
|
|
78
74
|
style: style.parent,
|
|
79
|
-
horizontal
|
|
80
|
-
polar
|
|
81
|
-
origin
|
|
82
|
-
name
|
|
75
|
+
horizontal,
|
|
76
|
+
polar,
|
|
77
|
+
origin,
|
|
78
|
+
name
|
|
83
79
|
};
|
|
84
80
|
}
|
|
85
|
-
|
|
86
81
|
return {};
|
|
87
82
|
}, [standalone, domain, scale, width, height, theme, style, horizontal, polar, origin, name]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, [propsWithDefaults]);
|
|
91
|
-
var container = React.useMemo(function () {
|
|
83
|
+
const userProps = React.useMemo(() => UserProps.getSafeUserProps(propsWithDefaults), [propsWithDefaults]);
|
|
84
|
+
const container = React.useMemo(() => {
|
|
92
85
|
if (standalone) {
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
const defaultContainerProps = _defaults({}, containerComponent.props, containerProps, userProps);
|
|
95
87
|
return /*#__PURE__*/React.cloneElement(containerComponent, defaultContainerProps);
|
|
96
88
|
}
|
|
97
|
-
|
|
98
89
|
return /*#__PURE__*/React.cloneElement(groupComponent, userProps);
|
|
99
90
|
}, [groupComponent, standalone, containerComponent, containerProps, userProps]);
|
|
100
|
-
|
|
91
|
+
const events = React.useMemo(() => {
|
|
101
92
|
return Wrapper.getAllEvents(props);
|
|
102
93
|
}, [props]);
|
|
103
|
-
|
|
104
|
-
React.useEffect(
|
|
94
|
+
const previousProps = Hooks.usePreviousProps(propsWithDefaults);
|
|
95
|
+
React.useEffect(() => {
|
|
105
96
|
// This is called before dismount to keep state in sync
|
|
106
|
-
return
|
|
97
|
+
return () => {
|
|
107
98
|
if (propsWithDefaults.animate) {
|
|
108
99
|
setAnimationState(previousProps, props);
|
|
109
100
|
}
|
|
110
101
|
};
|
|
111
102
|
}, [setAnimationState, previousProps, propsWithDefaults, props]);
|
|
112
|
-
|
|
113
103
|
if (!_isEmpty(events)) {
|
|
114
104
|
return /*#__PURE__*/React.createElement(VictorySharedEvents, {
|
|
115
105
|
container: container,
|
|
@@ -118,14 +108,12 @@ var VictoryGroupBase = function (initialProps) {
|
|
|
118
108
|
externalEventMutations: externalEventMutations
|
|
119
109
|
}, newChildren);
|
|
120
110
|
}
|
|
121
|
-
|
|
122
111
|
return /*#__PURE__*/React.cloneElement(container, container.props, newChildren);
|
|
123
112
|
};
|
|
124
|
-
|
|
125
|
-
var componentConfig = {
|
|
113
|
+
const componentConfig = {
|
|
126
114
|
role: "group",
|
|
127
115
|
expectedComponents: ["groupComponent", "containerComponent", "labelComponent"],
|
|
128
|
-
getChildren
|
|
116
|
+
getChildren
|
|
129
117
|
};
|
|
130
|
-
export
|
|
118
|
+
export const VictoryGroup = Object.assign( /*#__PURE__*/React.memo(VictoryGroupBase, isEqual), componentConfig);
|
|
131
119
|
VictoryGroup.displayName = "VictoryGroup";
|