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.
@@ -6,265 +6,222 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getCalculatedProps = getCalculatedProps;
7
7
  exports.getChildren = getChildren;
8
8
  exports.useMemoizedProps = useMemoizedProps;
9
-
10
9
  var _react = _interopRequireDefault(require("react"));
11
-
12
10
  var _victoryCore = require("victory-core");
13
-
14
11
  var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
15
-
16
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ /* eslint-disable no-use-before-define */
17
14
 
18
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
19
-
20
- 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."); }
21
-
22
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
-
24
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
-
26
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
-
28
- 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."); }
29
-
30
- 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); }
31
-
32
- 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; }
33
-
34
- 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; }
35
-
36
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- 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; }
39
-
40
- 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; }
41
-
42
- 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; }
43
-
44
- var fallbackProps = {
15
+ const fallbackProps = {
45
16
  width: 450,
46
17
  height: 300,
47
18
  padding: 50,
48
19
  offset: 0
49
- }; // eslint-disable-next-line max-statements
20
+ };
50
21
 
22
+ // eslint-disable-next-line max-statements
51
23
  function getCalculatedProps(initialProps, childComponents) {
52
- var role = "group";
53
-
54
- var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, role);
55
-
56
- var style = _victoryCore.Wrapper.getStyle(props.theme, props.style, role);
57
-
58
- var offset = props.offset,
59
- colorScale = props.colorScale,
60
- color = props.color,
61
- polar = props.polar,
62
- horizontal = props.horizontal;
63
-
64
- var categories = props.categories || _victoryCore.Wrapper.getCategories(props, childComponents, null);
65
-
66
- var datasets = props.datasets || _victoryCore.Wrapper.getDataFromChildren(props, null);
67
-
68
- var domain = {
24
+ const role = "group";
25
+ const props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, role);
26
+ const style = _victoryCore.Wrapper.getStyle(props.theme, props.style, role);
27
+ const {
28
+ offset,
29
+ colorScale,
30
+ color,
31
+ polar,
32
+ horizontal
33
+ } = props;
34
+ const categories = props.categories || _victoryCore.Wrapper.getCategories(props, childComponents, null);
35
+ const datasets = props.datasets || _victoryCore.Wrapper.getDataFromChildren(props, null);
36
+ const domain = {
69
37
  x: _victoryCore.Wrapper.getDomain(Object.assign({}, props, {
70
- categories: categories
38
+ categories
71
39
  }), "x", childComponents),
72
40
  y: _victoryCore.Wrapper.getDomain(Object.assign({}, props, {
73
- categories: categories
41
+ categories
74
42
  }), "y", childComponents)
75
43
  };
76
- var range = props.range || {
44
+ const range = props.range || {
77
45
  x: _victoryCore.Helpers.getRange(props, "x"),
78
46
  y: _victoryCore.Helpers.getRange(props, "y")
79
47
  };
80
- var baseScale = {
48
+ const baseScale = {
81
49
  x: _victoryCore.Scale.getScaleFromProps(props, "x") || _victoryCore.Wrapper.getScale(props, "x"),
82
50
  y: _victoryCore.Scale.getScaleFromProps(props, "y") || _victoryCore.Wrapper.getScale(props, "y")
83
51
  };
84
- var scale = {
52
+ const scale = {
85
53
  x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
86
54
  y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
87
55
  };
88
- var origin = polar ? props.origin : _victoryCore.Helpers.getPolarOrigin(props);
89
-
90
- var padding = _victoryCore.Helpers.getPadding(props);
91
-
56
+ const origin = polar ? props.origin : _victoryCore.Helpers.getPolarOrigin(props);
57
+ const padding = _victoryCore.Helpers.getPadding(props);
92
58
  return {
93
- datasets: datasets,
94
- categories: categories,
95
- range: range,
96
- domain: domain,
97
- horizontal: horizontal,
98
- scale: scale,
99
- style: style,
100
- colorScale: colorScale,
101
- color: color,
102
- offset: offset,
103
- origin: origin,
104
- padding: padding
59
+ datasets,
60
+ categories,
61
+ range,
62
+ domain,
63
+ horizontal,
64
+ scale,
65
+ style,
66
+ colorScale,
67
+ color,
68
+ offset,
69
+ origin,
70
+ padding
105
71
  };
106
- } // We need to remove sharedEvents in order to memoize the calculated data
107
- // With shared events, the props change on every event, and every value is re-calculated
108
-
109
-
110
- var withoutSharedEvents = function (props) {
111
- var children = props.children;
72
+ }
112
73
 
113
- var modifiedChildren = _react.default.Children.toArray(children).map(function (child) {
114
- return _objectSpread(_objectSpread({}, child), {}, {
74
+ // We need to remove sharedEvents in order to memoize the calculated data
75
+ // With shared events, the props change on every event, and every value is re-calculated
76
+ const withoutSharedEvents = props => {
77
+ const {
78
+ children
79
+ } = props;
80
+ const modifiedChildren = _react.default.Children.toArray(children).map(child => {
81
+ return {
82
+ ...child,
115
83
  props: _victoryCore.Helpers.omit(child.props, ["sharedEvents"])
116
- });
84
+ };
117
85
  });
118
-
119
86
  props.children = modifiedChildren;
120
87
  return props;
121
88
  };
122
-
123
89
  function useMemoizedProps(initialProps) {
124
- var modifiedProps = withoutSharedEvents(initialProps);
90
+ const modifiedProps = withoutSharedEvents(initialProps);
91
+ const [props, setProps] = _react.default.useState(modifiedProps);
125
92
 
126
- var _React$useState = _react.default.useState(modifiedProps),
127
- _React$useState2 = _slicedToArray(_React$useState, 2),
128
- props = _React$useState2[0],
129
- setProps = _React$useState2[1]; // React.memo uses shallow equality to compare objects. This way props
93
+ // React.memo uses shallow equality to compare objects. This way props
130
94
  // will only be re-calculated when they change.
131
-
132
-
133
- _react.default.useEffect(function () {
95
+ _react.default.useEffect(() => {
134
96
  if (!(0, _reactFastCompare.default)(modifiedProps, props)) {
135
97
  setProps(modifiedProps);
136
98
  }
137
99
  }, [props, setProps, modifiedProps]);
138
-
139
- return _react.default.useMemo(function () {
100
+ return _react.default.useMemo(() => {
140
101
  return getCalculatedProps(props, props.children);
141
102
  }, [props]);
142
103
  }
143
-
144
104
  function pixelsToValue(props, axis, calculatedProps) {
145
105
  if (!props.offset) {
146
106
  return 0;
147
107
  }
148
-
149
- var currentAxis = _victoryCore.Helpers.getCurrentAxis(axis, props.horizontal);
150
-
151
- var domain = calculatedProps.domain[axis];
152
- var range = calculatedProps.range[currentAxis];
153
- var domainExtent = Math.max.apply(Math, _toConsumableArray(domain)) - Math.min.apply(Math, _toConsumableArray(domain));
154
- var rangeExtent = Math.max.apply(Math, _toConsumableArray(range)) - Math.min.apply(Math, _toConsumableArray(range));
108
+ const currentAxis = _victoryCore.Helpers.getCurrentAxis(axis, props.horizontal);
109
+ const domain = calculatedProps.domain[axis];
110
+ const range = calculatedProps.range[currentAxis];
111
+ const domainExtent = Math.max(...domain) - Math.min(...domain);
112
+ const rangeExtent = Math.max(...range) - Math.min(...range);
155
113
  return domainExtent / rangeExtent * props.offset;
156
- } // eslint-disable-next-line max-params
157
-
114
+ }
158
115
 
116
+ // eslint-disable-next-line max-params
159
117
  function getX0(props, calculatedProps, index, role) {
160
- var groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
161
- var center = (groupLength - 1) / 2;
162
- var totalWidth = pixelsToValue(props, "x", calculatedProps);
118
+ const groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
119
+ const center = (groupLength - 1) / 2;
120
+ const totalWidth = pixelsToValue(props, "x", calculatedProps);
163
121
  return (index - center) * totalWidth;
164
- } // eslint-disable-next-line max-params
165
-
122
+ }
166
123
 
124
+ // eslint-disable-next-line max-params
167
125
  function getPolarX0(props, calculatedProps, index, role) {
168
- var groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
169
- var center = (groupLength - 1) / 2;
170
- var width = getAngularWidth(props, calculatedProps);
126
+ const groupLength = role === "stack" ? calculatedProps.datasets[0].length : calculatedProps.datasets.length;
127
+ const center = (groupLength - 1) / 2;
128
+ const width = getAngularWidth(props, calculatedProps);
171
129
  return (index - center) * width;
172
130
  }
173
-
174
131
  function getAngularWidth(props, calculatedProps) {
175
- var range = calculatedProps.range;
176
- var angularRange = Math.abs(range.x[1] - range.x[0]);
177
- var r = Math.max.apply(Math, _toConsumableArray(range.y));
132
+ const {
133
+ range
134
+ } = calculatedProps;
135
+ const angularRange = Math.abs(range.x[1] - range.x[0]);
136
+ const r = Math.max(...range.y);
178
137
  return props.offset / (2 * Math.PI * r) * angularRange;
179
138
  }
180
-
181
139
  function getLabels(props, datasets, index) {
182
140
  if (!props.labels) {
183
141
  return undefined;
184
142
  }
185
-
186
143
  return Math.floor(datasets.length / 2) === index ? props.labels : undefined;
187
144
  }
188
-
189
145
  function getChildProps(props, calculatedProps) {
190
- var categories = calculatedProps.categories,
191
- domain = calculatedProps.domain,
192
- range = calculatedProps.range,
193
- scale = calculatedProps.scale,
194
- horizontal = calculatedProps.horizontal,
195
- origin = calculatedProps.origin,
196
- padding = calculatedProps.padding;
197
- var width = props.width,
198
- height = props.height,
199
- theme = props.theme,
200
- polar = props.polar;
146
+ const {
147
+ categories,
148
+ domain,
149
+ range,
150
+ scale,
151
+ horizontal,
152
+ origin,
153
+ padding
154
+ } = calculatedProps;
155
+ const {
156
+ width,
157
+ height,
158
+ theme,
159
+ polar
160
+ } = props;
201
161
  return {
202
- height: height,
203
- width: width,
204
- theme: theme,
205
- polar: polar,
206
- origin: origin,
207
- categories: categories,
208
- domain: domain,
209
- range: range,
210
- scale: scale,
211
- horizontal: horizontal,
212
- padding: padding,
162
+ height,
163
+ width,
164
+ theme,
165
+ polar,
166
+ origin,
167
+ categories,
168
+ domain,
169
+ range,
170
+ scale,
171
+ horizontal,
172
+ padding,
213
173
  standalone: false
214
174
  };
215
175
  }
216
-
217
176
  function getColorScale(props, child) {
218
- var role = child.type && child.type.role;
219
- var colorScaleOptions = child.props.colorScale || props.colorScale;
220
-
177
+ const role = child.type && child.type.role;
178
+ const colorScaleOptions = child.props.colorScale || props.colorScale;
221
179
  if (role !== "group" && role !== "stack") {
222
180
  return undefined;
223
181
  }
224
-
225
182
  return props.theme && props.theme.group ? colorScaleOptions || props.theme.group.colorScale : colorScaleOptions;
226
183
  }
227
-
228
- function getDataWithOffset(props) {
229
- var defaultDataset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
230
- var offset = arguments.length > 2 ? arguments[2] : undefined;
231
- var dataset = props.data || props.y ? _victoryCore.Data.getData(props) : defaultDataset;
232
- var xOffset = offset || 0;
233
- return dataset.map(function (datum) {
234
- var _x1 = datum._x instanceof Date ? new Date(datum._x.getTime() + xOffset) : datum._x + xOffset;
235
-
184
+ function getDataWithOffset(props, defaultDataset, offset) {
185
+ if (defaultDataset === void 0) {
186
+ defaultDataset = [];
187
+ }
188
+ const dataset = props.data || props.y ? _victoryCore.Data.getData(props) : defaultDataset;
189
+ const xOffset = offset || 0;
190
+ return dataset.map(datum => {
191
+ const _x1 = datum._x instanceof Date ? new Date(datum._x.getTime() + xOffset) : datum._x + xOffset;
236
192
  return Object.assign({}, datum, {
237
- _x1: _x1
193
+ _x1
238
194
  });
239
195
  });
240
196
  }
241
-
242
197
  function getChildren(initialProps, childComponents, calculatedProps) {
243
- var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "stack");
244
-
245
- var children = childComponents || _react.default.Children.toArray(props.children);
246
-
247
- var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
248
- var datasets = newCalculatedProps.datasets;
249
- var labelComponent = props.labelComponent,
250
- polar = props.polar;
251
- var childProps = getChildProps(props, newCalculatedProps);
252
- var parentName = props.name || "group";
253
- return children.map(function (child, index) {
254
- var role = child.type && child.type.role;
255
- var xOffset = polar ? getPolarX0(props, newCalculatedProps, index, role) : getX0(props, newCalculatedProps, index, role);
256
- var style = role === "voronoi" || role === "tooltip" || role === "label" ? child.props.style : _victoryCore.Wrapper.getChildStyle(child, index, newCalculatedProps);
257
- var labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
258
- var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
198
+ const props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "stack");
199
+ const children = childComponents || _react.default.Children.toArray(props.children);
200
+ const newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
201
+ const {
202
+ datasets
203
+ } = newCalculatedProps;
204
+ const {
205
+ labelComponent,
206
+ polar
207
+ } = props;
208
+ const childProps = getChildProps(props, newCalculatedProps);
209
+ const parentName = props.name || "group";
210
+ return children.map((child, index) => {
211
+ const role = child.type && child.type.role;
212
+ const xOffset = polar ? getPolarX0(props, newCalculatedProps, index, role) : getX0(props, newCalculatedProps, index, role);
213
+ const style = role === "voronoi" || role === "tooltip" || role === "label" ? child.props.style : _victoryCore.Wrapper.getChildStyle(child, index, newCalculatedProps);
214
+ const labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
215
+ const name = child.props.name || `${parentName}-${role}-${index}`;
259
216
  return /*#__PURE__*/_react.default.cloneElement(child, Object.assign({
260
- labels: labels,
261
- style: style,
262
- key: "".concat(name, "-key-").concat(index),
263
- name: name,
217
+ labels,
218
+ style,
219
+ key: `${name}-key-${index}`,
220
+ name,
264
221
  data: getDataWithOffset(props, datasets[index], xOffset),
265
222
  colorScale: getColorScale(props, child),
266
223
  labelComponent: labelComponent || child.props.labelComponent,
267
- xOffset: xOffset
224
+ xOffset
268
225
  }, childProps));
269
226
  });
270
227
  }
package/lib/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _victoryGroup = require("./victory-group");
8
-
9
7
  Object.keys(_victoryGroup).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _victoryGroup[key]) return;
@@ -4,138 +4,109 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VictoryGroup = void 0;
7
-
8
7
  var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
9
-
10
8
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  var _victoryCore = require("victory-core");
15
-
16
11
  var _victorySharedEvents = require("victory-shared-events");
17
-
18
12
  var _helperMethods = require("./helper-methods");
19
-
20
13
  var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
28
- 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; }
29
-
30
- var fallbackProps = {
15
+ const fallbackProps = {
31
16
  width: 450,
32
17
  height: 300,
33
18
  padding: 50,
34
19
  offset: 0
35
20
  };
36
- var defaultProps = {
21
+ const defaultProps = {
37
22
  containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
38
23
  groupComponent: /*#__PURE__*/_react.default.createElement("g", null),
39
24
  samples: 50,
40
25
  standalone: true,
41
26
  theme: _victoryCore.VictoryTheme.grayscale
42
27
  };
43
-
44
- var VictoryGroupBase = function (initialProps) {
28
+ const VictoryGroupBase = initialProps => {
45
29
  // eslint-disable-next-line no-use-before-define
46
- var role = VictoryGroup === null || VictoryGroup === void 0 ? void 0 : VictoryGroup.role;
47
-
48
- var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
49
- getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
50
- setAnimationState = _Hooks$useAnimationSt.setAnimationState,
51
- getProps = _Hooks$useAnimationSt.getProps;
52
-
53
- var propsWithDefaults = _react.default.useMemo(function () {
54
- return _objectSpread(_objectSpread({}, defaultProps), initialProps);
55
- }, [initialProps]);
56
-
57
- var props = getProps(propsWithDefaults);
58
-
59
- var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
60
-
61
- var eventKey = modifiedProps.eventKey,
62
- containerComponent = modifiedProps.containerComponent,
63
- standalone = modifiedProps.standalone,
64
- groupComponent = modifiedProps.groupComponent,
65
- externalEventMutations = modifiedProps.externalEventMutations,
66
- width = modifiedProps.width,
67
- height = modifiedProps.height,
68
- theme = modifiedProps.theme,
69
- polar = modifiedProps.polar,
70
- horizontal = modifiedProps.horizontal,
71
- name = modifiedProps.name;
72
-
73
- var childComponents = _react.default.Children.toArray(modifiedProps.children);
74
-
75
- var calculatedProps = (0, _helperMethods.useMemoizedProps)(modifiedProps);
76
- var domain = calculatedProps.domain,
77
- scale = calculatedProps.scale,
78
- style = calculatedProps.style,
79
- origin = calculatedProps.origin;
80
-
81
- var newChildren = _react.default.useMemo(function () {
82
- var children = (0, _helperMethods.getChildren)(props, childComponents, calculatedProps);
83
- return children.map(function (child, index) {
84
- var childProps = Object.assign({
30
+ const role = VictoryGroup?.role;
31
+ const {
32
+ getAnimationProps,
33
+ setAnimationState,
34
+ getProps
35
+ } = _victoryCore.Hooks.useAnimationState();
36
+ const propsWithDefaults = _react.default.useMemo(() => ({
37
+ ...defaultProps,
38
+ ...initialProps
39
+ }), [initialProps]);
40
+ const props = getProps(propsWithDefaults);
41
+ const modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
42
+ const {
43
+ eventKey,
44
+ containerComponent,
45
+ standalone,
46
+ groupComponent,
47
+ externalEventMutations,
48
+ width,
49
+ height,
50
+ theme,
51
+ polar,
52
+ horizontal,
53
+ name
54
+ } = modifiedProps;
55
+ const childComponents = _react.default.Children.toArray(modifiedProps.children);
56
+ const calculatedProps = (0, _helperMethods.useMemoizedProps)(modifiedProps);
57
+ const {
58
+ domain,
59
+ scale,
60
+ style,
61
+ origin
62
+ } = calculatedProps;
63
+ const newChildren = _react.default.useMemo(() => {
64
+ const children = (0, _helperMethods.getChildren)(props, childComponents, calculatedProps);
65
+ return children.map((child, index) => {
66
+ const childProps = Object.assign({
85
67
  animate: getAnimationProps(props, child, index)
86
68
  }, child.props);
87
69
  return /*#__PURE__*/_react.default.cloneElement(child, childProps);
88
70
  });
89
71
  }, [props, childComponents, calculatedProps, getAnimationProps]);
90
-
91
- var containerProps = _react.default.useMemo(function () {
72
+ const containerProps = _react.default.useMemo(() => {
92
73
  if (standalone) {
93
74
  return {
94
- domain: domain,
95
- scale: scale,
96
- width: width,
97
- height: height,
98
- standalone: standalone,
99
- theme: theme,
75
+ domain,
76
+ scale,
77
+ width,
78
+ height,
79
+ standalone,
80
+ theme,
100
81
  style: style.parent,
101
- horizontal: horizontal,
102
- polar: polar,
103
- origin: origin,
104
- name: name
82
+ horizontal,
83
+ polar,
84
+ origin,
85
+ name
105
86
  };
106
87
  }
107
-
108
88
  return {};
109
89
  }, [standalone, domain, scale, width, height, theme, style, horizontal, polar, origin, name]);
110
-
111
- var userProps = _react.default.useMemo(function () {
112
- return _victoryCore.UserProps.getSafeUserProps(propsWithDefaults);
113
- }, [propsWithDefaults]);
114
-
115
- var container = _react.default.useMemo(function () {
90
+ const userProps = _react.default.useMemo(() => _victoryCore.UserProps.getSafeUserProps(propsWithDefaults), [propsWithDefaults]);
91
+ const container = _react.default.useMemo(() => {
116
92
  if (standalone) {
117
- var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, userProps);
93
+ const defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, userProps);
118
94
  return /*#__PURE__*/_react.default.cloneElement(containerComponent, defaultContainerProps);
119
95
  }
120
-
121
96
  return /*#__PURE__*/_react.default.cloneElement(groupComponent, userProps);
122
97
  }, [groupComponent, standalone, containerComponent, containerProps, userProps]);
123
-
124
- var events = _react.default.useMemo(function () {
98
+ const events = _react.default.useMemo(() => {
125
99
  return _victoryCore.Wrapper.getAllEvents(props);
126
100
  }, [props]);
127
-
128
- var previousProps = _victoryCore.Hooks.usePreviousProps(propsWithDefaults);
129
-
130
- _react.default.useEffect(function () {
101
+ const previousProps = _victoryCore.Hooks.usePreviousProps(propsWithDefaults);
102
+ _react.default.useEffect(() => {
131
103
  // This is called before dismount to keep state in sync
132
- return function () {
104
+ return () => {
133
105
  if (propsWithDefaults.animate) {
134
106
  setAnimationState(previousProps, props);
135
107
  }
136
108
  };
137
109
  }, [setAnimationState, previousProps, propsWithDefaults, props]);
138
-
139
110
  if (!(0, _isEmpty2.default)(events)) {
140
111
  return /*#__PURE__*/_react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
141
112
  container: container,
@@ -144,15 +115,12 @@ var VictoryGroupBase = function (initialProps) {
144
115
  externalEventMutations: externalEventMutations
145
116
  }, newChildren);
146
117
  }
147
-
148
118
  return /*#__PURE__*/_react.default.cloneElement(container, container.props, newChildren);
149
119
  };
150
-
151
- var componentConfig = {
120
+ const componentConfig = {
152
121
  role: "group",
153
122
  expectedComponents: ["groupComponent", "containerComponent", "labelComponent"],
154
123
  getChildren: _helperMethods.getChildren
155
124
  };
156
- var VictoryGroup = Object.assign( /*#__PURE__*/_react.default.memo(VictoryGroupBase, _reactFastCompare.default), componentConfig);
157
- exports.VictoryGroup = VictoryGroup;
125
+ const VictoryGroup = exports.VictoryGroup = Object.assign( /*#__PURE__*/_react.default.memo(VictoryGroupBase, _reactFastCompare.default), componentConfig);
158
126
  VictoryGroup.displayName = "VictoryGroup";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-group",
3
- "version": "36.9.2",
3
+ "version": "37.0.0",
4
4
  "description": "Group Layout Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
24
  "react-fast-compare": "^3.2.0",
25
- "victory-core": "^36.9.2",
26
- "victory-shared-events": "^36.9.2"
25
+ "victory-core": "^37.0.0",
26
+ "victory-shared-events": "^37.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "victory-bar": "*"