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