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