victory-core 36.3.2 → 36.5.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 (253) hide show
  1. package/dist/victory-core.js +15084 -15018
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.d.ts +38 -941
  4. package/es/index.js +19 -28
  5. package/es/types.d.ts +33 -0
  6. package/es/types.js +1 -0
  7. package/es/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  8. package/es/victory-accessible-group/victory-accessible-group.js +35 -45
  9. package/es/victory-animation/util.d.ts +66 -0
  10. package/es/victory-animation/util.js +3 -2
  11. package/es/victory-animation/victory-animation.d.ts +69 -0
  12. package/es/victory-animation/victory-animation.js +92 -102
  13. package/es/victory-clip-container/victory-clip-container.d.ts +76 -0
  14. package/es/victory-clip-container/victory-clip-container.js +75 -82
  15. package/es/victory-container/victory-container.d.ts +99 -0
  16. package/es/victory-container/victory-container.js +97 -107
  17. package/es/victory-label/victory-label.d.ts +61 -0
  18. package/es/victory-label/victory-label.js +43 -31
  19. package/es/victory-portal/portal-context.d.ts +11 -0
  20. package/es/victory-portal/portal-context.js +3 -4
  21. package/es/victory-portal/portal.d.ts +28 -0
  22. package/es/victory-portal/portal.js +44 -50
  23. package/es/victory-portal/victory-portal.d.ts +31 -0
  24. package/es/victory-portal/victory-portal.js +38 -47
  25. package/es/victory-primitives/arc.d.ts +21 -0
  26. package/es/victory-primitives/arc.js +9 -9
  27. package/es/victory-primitives/background.d.ts +22 -0
  28. package/es/victory-primitives/background.js +12 -12
  29. package/es/victory-primitives/border.d.ts +18 -0
  30. package/es/victory-primitives/border.js +9 -9
  31. package/es/victory-primitives/circle.d.ts +2 -0
  32. package/es/victory-primitives/circle.js +17 -10
  33. package/es/victory-primitives/clip-path.d.ts +14 -0
  34. package/es/victory-primitives/clip-path.js +6 -6
  35. package/es/victory-primitives/index.d.ts +14 -0
  36. package/es/victory-primitives/index.js +14 -0
  37. package/es/victory-primitives/line-segment.d.ts +19 -0
  38. package/es/victory-primitives/line-segment.js +9 -9
  39. package/es/victory-primitives/line.d.ts +2 -0
  40. package/es/victory-primitives/line.js +17 -10
  41. package/es/victory-primitives/path.d.ts +2 -0
  42. package/es/victory-primitives/path.js +15 -8
  43. package/es/victory-primitives/point.d.ts +21 -0
  44. package/es/victory-primitives/point.js +15 -23
  45. package/es/victory-primitives/rect.d.ts +2 -0
  46. package/es/victory-primitives/rect.js +17 -10
  47. package/es/victory-primitives/text.d.ts +16 -0
  48. package/es/victory-primitives/text.js +13 -8
  49. package/es/victory-primitives/tspan.d.ts +2 -0
  50. package/es/victory-primitives/tspan.js +7 -6
  51. package/es/victory-primitives/types.d.ts +7 -0
  52. package/es/victory-primitives/types.js +1 -0
  53. package/es/victory-primitives/whisker.d.ts +24 -0
  54. package/es/victory-primitives/whisker.js +12 -12
  55. package/es/victory-theme/grayscale.d.ts +2 -0
  56. package/es/victory-theme/grayscale.js +1 -1
  57. package/es/victory-theme/material.d.ts +2 -0
  58. package/es/victory-theme/material.js +1 -1
  59. package/es/victory-theme/victory-theme-definition.d.ts +244 -0
  60. package/es/victory-theme/victory-theme-definition.js +1 -0
  61. package/es/victory-theme/victory-theme.d.ts +5 -0
  62. package/es/victory-theme/victory-theme.js +6 -5
  63. package/es/victory-transition/victory-transition.d.ts +59 -0
  64. package/es/victory-transition/victory-transition.js +38 -44
  65. package/es/victory-util/add-events.js +328 -319
  66. package/es/victory-util/axis.js +12 -6
  67. package/es/victory-util/collection.js +7 -5
  68. package/es/victory-util/common-props.js +2 -2
  69. package/es/victory-util/data.js +8 -6
  70. package/es/victory-util/default-transitions.js +0 -1
  71. package/es/victory-util/domain.js +7 -5
  72. package/es/victory-util/events.js +8 -4
  73. package/es/victory-util/helpers.js +1 -3
  74. package/es/victory-util/hooks/use-animation-state.js +11 -5
  75. package/es/victory-util/immutable.js +0 -1
  76. package/es/victory-util/label-helpers.js +0 -2
  77. package/es/victory-util/line-helpers.js +1 -1
  78. package/es/victory-util/log.js +0 -1
  79. package/es/victory-util/point-path-helpers.d.ts +9 -0
  80. package/es/victory-util/point-path-helpers.js +59 -61
  81. package/es/victory-util/scale.js +19 -19
  82. package/es/victory-util/selection.d.ts +23 -0
  83. package/es/victory-util/selection.js +0 -2
  84. package/es/victory-util/style.js +0 -2
  85. package/es/victory-util/textsize.d.ts +8 -0
  86. package/es/victory-util/textsize.js +11 -7
  87. package/es/victory-util/timer-context.d.ts +11 -0
  88. package/es/victory-util/timer-context.js +1 -1
  89. package/es/victory-util/timer.d.ts +16 -0
  90. package/es/victory-util/timer.js +16 -13
  91. package/es/victory-util/types.d.ts +188 -0
  92. package/es/victory-util/types.js +1 -0
  93. package/es/victory-util/user-props.js +44 -4
  94. package/es/victory-util/wrapper.js +18 -12
  95. package/lib/index.d.ts +38 -941
  96. package/lib/index.js +201 -189
  97. package/lib/types.d.ts +33 -0
  98. package/lib/types.js +1 -0
  99. package/lib/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  100. package/lib/victory-accessible-group/victory-accessible-group.js +37 -45
  101. package/lib/victory-animation/util.d.ts +66 -0
  102. package/lib/victory-animation/util.js +4 -3
  103. package/lib/victory-animation/victory-animation.d.ts +69 -0
  104. package/lib/victory-animation/victory-animation.js +97 -102
  105. package/lib/victory-clip-container/victory-clip-container.d.ts +76 -0
  106. package/lib/victory-clip-container/victory-clip-container.js +81 -82
  107. package/lib/victory-container/victory-container.d.ts +99 -0
  108. package/lib/victory-container/victory-container.js +102 -107
  109. package/lib/victory-label/victory-label.d.ts +61 -0
  110. package/lib/victory-label/victory-label.js +49 -32
  111. package/lib/victory-portal/portal-context.d.ts +11 -0
  112. package/lib/victory-portal/portal-context.js +4 -5
  113. package/lib/victory-portal/portal.d.ts +28 -0
  114. package/lib/victory-portal/portal.js +49 -50
  115. package/lib/victory-portal/victory-portal.d.ts +31 -0
  116. package/lib/victory-portal/victory-portal.js +43 -47
  117. package/lib/victory-primitives/arc.d.ts +21 -0
  118. package/lib/victory-primitives/arc.js +13 -10
  119. package/lib/victory-primitives/background.d.ts +22 -0
  120. package/lib/victory-primitives/background.js +16 -13
  121. package/lib/victory-primitives/border.d.ts +18 -0
  122. package/lib/victory-primitives/border.js +13 -10
  123. package/lib/victory-primitives/circle.d.ts +2 -0
  124. package/lib/victory-primitives/circle.js +17 -8
  125. package/lib/victory-primitives/clip-path.d.ts +14 -0
  126. package/lib/victory-primitives/clip-path.js +7 -5
  127. package/lib/victory-primitives/index.d.ts +14 -0
  128. package/lib/victory-primitives/index.js +187 -0
  129. package/lib/victory-primitives/line-segment.d.ts +19 -0
  130. package/lib/victory-primitives/line-segment.js +13 -10
  131. package/lib/victory-primitives/line.d.ts +2 -0
  132. package/lib/victory-primitives/line.js +17 -8
  133. package/lib/victory-primitives/path.d.ts +2 -0
  134. package/lib/victory-primitives/path.js +15 -6
  135. package/lib/victory-primitives/point.d.ts +21 -0
  136. package/lib/victory-primitives/point.js +21 -25
  137. package/lib/victory-primitives/rect.d.ts +2 -0
  138. package/lib/victory-primitives/rect.js +17 -8
  139. package/lib/victory-primitives/text.d.ts +16 -0
  140. package/lib/victory-primitives/text.js +14 -7
  141. package/lib/victory-primitives/tspan.d.ts +2 -0
  142. package/lib/victory-primitives/tspan.js +7 -4
  143. package/lib/victory-primitives/types.d.ts +7 -0
  144. package/lib/victory-primitives/types.js +1 -0
  145. package/lib/victory-primitives/whisker.d.ts +24 -0
  146. package/lib/victory-primitives/whisker.js +16 -13
  147. package/lib/victory-theme/grayscale.d.ts +2 -0
  148. package/lib/victory-theme/grayscale.js +3 -3
  149. package/lib/victory-theme/material.d.ts +2 -0
  150. package/lib/victory-theme/material.js +3 -3
  151. package/lib/victory-theme/victory-theme-definition.d.ts +244 -0
  152. package/lib/victory-theme/victory-theme-definition.js +1 -0
  153. package/lib/victory-theme/victory-theme.d.ts +5 -0
  154. package/lib/victory-theme/victory-theme.js +22 -8
  155. package/lib/victory-transition/victory-transition.d.ts +59 -0
  156. package/lib/victory-transition/victory-transition.js +43 -45
  157. package/lib/victory-util/add-events.js +326 -316
  158. package/lib/victory-util/axis.js +20 -11
  159. package/lib/victory-util/collection.js +10 -8
  160. package/lib/victory-util/common-props.js +6 -4
  161. package/lib/victory-util/data.js +13 -7
  162. package/lib/victory-util/default-transitions.js +1 -2
  163. package/lib/victory-util/domain.js +11 -5
  164. package/lib/victory-util/events.js +17 -11
  165. package/lib/victory-util/helpers.js +14 -16
  166. package/lib/victory-util/hooks/index.js +4 -4
  167. package/lib/victory-util/hooks/use-animation-state.js +14 -6
  168. package/lib/victory-util/immutable.js +3 -5
  169. package/lib/victory-util/label-helpers.js +6 -6
  170. package/lib/victory-util/line-helpers.js +4 -2
  171. package/lib/victory-util/log.js +0 -1
  172. package/lib/victory-util/point-path-helpers.d.ts +9 -0
  173. package/lib/victory-util/point-path-helpers.js +86 -73
  174. package/lib/victory-util/prop-types.js +5 -3
  175. package/lib/victory-util/scale.js +24 -21
  176. package/lib/victory-util/selection.d.ts +23 -0
  177. package/lib/victory-util/selection.js +5 -5
  178. package/lib/victory-util/style.js +0 -2
  179. package/lib/victory-util/textsize.d.ts +8 -0
  180. package/lib/victory-util/textsize.js +12 -8
  181. package/lib/victory-util/timer-context.d.ts +11 -0
  182. package/lib/victory-util/timer-context.js +1 -1
  183. package/lib/victory-util/timer.d.ts +16 -0
  184. package/lib/victory-util/timer.js +16 -13
  185. package/lib/victory-util/types.d.ts +188 -0
  186. package/lib/victory-util/types.js +1 -0
  187. package/lib/victory-util/user-props.js +53 -6
  188. package/lib/victory-util/wrapper.js +31 -23
  189. package/package.json +6 -13
  190. package/src/index.ts +42 -0
  191. package/src/types.ts +45 -0
  192. package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +10 -3
  193. package/src/victory-animation/{util.js → util.ts} +5 -4
  194. package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +90 -13
  195. package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +32 -6
  196. package/src/victory-container/{victory-container.js → victory-container.tsx} +70 -26
  197. package/src/victory-label/{victory-label.js → victory-label.tsx} +80 -19
  198. package/src/victory-portal/portal-context.ts +14 -0
  199. package/src/victory-portal/{portal.js → portal.tsx} +23 -12
  200. package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +21 -6
  201. package/src/victory-primitives/{arc.js → arc.tsx} +15 -5
  202. package/src/victory-primitives/{background.js → background.tsx} +17 -7
  203. package/src/victory-primitives/{border.js → border.tsx} +12 -5
  204. package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
  205. package/src/victory-primitives/clip-path.tsx +25 -0
  206. package/src/victory-primitives/index.ts +14 -0
  207. package/src/victory-primitives/{line-segment.js → line-segment.tsx} +13 -5
  208. package/src/victory-primitives/{line.js → line.tsx} +4 -3
  209. package/src/victory-primitives/{path.js → path.tsx} +4 -3
  210. package/src/victory-primitives/{point.js → point.tsx} +25 -20
  211. package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
  212. package/src/victory-primitives/{text.js → text.tsx} +9 -3
  213. package/src/victory-primitives/tspan.tsx +7 -0
  214. package/src/victory-primitives/types.ts +19 -0
  215. package/src/victory-primitives/{whisker.js → whisker.tsx} +20 -7
  216. package/src/victory-theme/{grayscale.js → grayscale.tsx} +2 -1
  217. package/src/victory-theme/{material.js → material.tsx} +2 -1
  218. package/src/victory-theme/victory-theme-definition.ts +261 -0
  219. package/src/victory-theme/victory-theme.tsx +5 -0
  220. package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +68 -19
  221. package/src/victory-util/add-events.js +7 -5
  222. package/src/victory-util/axis.js +3 -1
  223. package/src/victory-util/collection.js +0 -1
  224. package/src/victory-util/common-props.js +2 -2
  225. package/src/victory-util/data.js +0 -1
  226. package/src/victory-util/default-transitions.js +0 -1
  227. package/src/victory-util/domain.js +0 -1
  228. package/src/victory-util/events.js +1 -1
  229. package/src/victory-util/helpers.js +0 -1
  230. package/src/victory-util/immutable.js +0 -1
  231. package/src/victory-util/label-helpers.js +0 -1
  232. package/src/victory-util/line-helpers.js +1 -1
  233. package/src/victory-util/log.js +0 -1
  234. package/src/victory-util/point-path-helpers.ts +119 -0
  235. package/src/victory-util/prop-types.js +0 -1
  236. package/src/victory-util/scale.js +18 -10
  237. package/src/victory-util/selection.d.ts +23 -0
  238. package/src/victory-util/selection.js +0 -1
  239. package/src/victory-util/style.js +0 -1
  240. package/src/victory-util/textsize.d.ts +8 -0
  241. package/src/victory-util/{timer-context.js → timer-context.ts} +0 -0
  242. package/src/victory-util/{timer.js → timer.ts} +20 -5
  243. package/src/victory-util/transitions.js +0 -1
  244. package/src/victory-util/types.ts +247 -0
  245. package/src/victory-util/user-props.js +31 -1
  246. package/src/victory-util/wrapper.js +0 -1
  247. package/src/index.d.ts +0 -941
  248. package/src/index.js +0 -51
  249. package/src/victory-portal/portal-context.js +0 -10
  250. package/src/victory-primitives/clip-path.js +0 -18
  251. package/src/victory-primitives/tspan.js +0 -5
  252. package/src/victory-theme/victory-theme.js +0 -7
  253. package/src/victory-util/point-path-helpers.js +0 -121
@@ -0,0 +1,66 @@
1
+ export declare const isInterpolatable: (obj: any) => boolean;
2
+ /**
3
+ * Interpolate immediately to the end value at the given step `when`.
4
+ * Some nicer default behavior might be to jump at the halfway point or return
5
+ * `a` if `t` is 0 (instead of always returning `b`). But d3's default
6
+ * interpolator does not do these things:
7
+ *
8
+ * d3.interpolate('aaa', 'bbb')(0) === 'bbb'
9
+ *
10
+ * ...and things might get wonky if we don't replicate that behavior.
11
+ *
12
+ * @param {any} a - Start value.
13
+ * @param {any} b - End value.
14
+ * @param {Number} when - Step value (0 to 1) at which to jump to `b`.
15
+ * @returns {Function} An interpolation function.
16
+ */
17
+ export declare const interpolateImmediate: (a: any, b: any, when?: number) => (t: any) => any;
18
+ /**
19
+ * Interpolate to or from a function. The interpolated value will be a function
20
+ * that calls `a` (if it's a function) and `b` (if it's a function) and calls
21
+ * `d3.interpolate` on the resulting values. Note that our function won't
22
+ * necessarily be called (that's up to the component this eventually gets
23
+ * passed to) - but if it does get called, it will return an appropriately
24
+ * interpolated value.
25
+ *
26
+ * @param {any} a - Start value.
27
+ * @param {any} b - End value.
28
+ * @returns {Function} An interpolation function.
29
+ */
30
+ export declare const interpolateFunction: (a: any, b: any) => (t: any) => any;
31
+ /**
32
+ * Interpolate to or from an object. This method is a modification of the object interpolator in
33
+ * d3-interpolate https://github.com/d3/d3-interpolate/blob/master/src/object.js. This interpolator
34
+ * differs in that it uses our custom interpolators when interpolating the value of each property in
35
+ * an object. This allows the correct interpolation of nested objects, including styles
36
+ *
37
+ * @param {any} a - Start value.
38
+ * @param {any} b - End value.
39
+ * @returns {Function} An interpolation function.
40
+ */
41
+ export declare const interpolateObject: (a: any, b: any) => (t: any) => {};
42
+ export declare const interpolateString: (a: any, b: any) => any;
43
+ /**
44
+ * By default, the list of interpolators used by `d3.interpolate` has a few
45
+ * downsides:
46
+ *
47
+ * - `null` values get turned into 0.
48
+ * - `undefined`, `function`, and some other value types get turned into NaN.
49
+ * - Boolean types get turned into numbers, which probably will be meaningless
50
+ * to whatever is consuming them.
51
+ * - It tries to interpolate between identical start and end values, doing
52
+ * unnecessary calculations that sometimes result in floating point rounding
53
+ * errors.
54
+ *
55
+ * If only the default interpolators are used, `VictoryAnimation` will happily
56
+ * pass down NaN (and other bad) values as props to the wrapped component.
57
+ * The component will then either use the incorrect values or complain that it
58
+ * was passed props of the incorrect type. This custom interpolator is added
59
+ * using the `d3.interpolators` API, and prevents such cases from happening
60
+ * for most values.
61
+ *
62
+ * @param {any} a - Start value.
63
+ * @param {any} b - End value.
64
+ * @returns {Function|undefined} An interpolation function, if necessary.
65
+ */
66
+ export declare const victoryInterpolator: <T>(a: T, b: T) => (t: number) => T;
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.victoryInterpolator = exports.interpolateString = exports.interpolateObject = exports.interpolateFunction = exports.interpolateImmediate = exports.isInterpolatable = void 0;
6
+ exports.victoryInterpolator = exports.isInterpolatable = exports.interpolateString = exports.interpolateObject = exports.interpolateImmediate = exports.interpolateFunction = void 0;
7
7
 
8
8
  var _orderBy2 = _interopRequireDefault(require("lodash/orderBy"));
9
9
 
10
10
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
11
11
 
12
- var _d3Interpolate = require("d3-interpolate");
12
+ var _d3Interpolate = require("victory-vendor/d3-interpolate");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
@@ -105,7 +105,7 @@ var interpolateFunction = function (a, b) {
105
105
  }
106
106
 
107
107
  return function () {
108
- /* eslint-disable no-invalid-this */
108
+ /* eslint-disable no-invalid-this, prefer-rest-params */
109
109
  var aval = typeof a === "function" ? a.apply(this, arguments) : a;
110
110
  var bval = typeof b === "function" ? b.apply(this, arguments) : b;
111
111
  return (0, _d3Interpolate.interpolate)(aval, bval)(t);
@@ -227,6 +227,7 @@ var victoryInterpolator = function (a, b) {
227
227
  }
228
228
 
229
229
  if ((0, _isPlainObject2.default)(a) || (0, _isPlainObject2.default)(b)) {
230
+ // @ts-expect-error These generics are tough, but they work ok?
230
231
  return interpolateObject(a, b);
231
232
  }
232
233
 
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import TimerContext from "../victory-util/timer-context";
4
+ import type Timer from "../victory-util/timer";
5
+ /**
6
+ * Single animation object to interpolate
7
+ */
8
+ export declare type AnimationStyle = {
9
+ [key: string]: string | number;
10
+ };
11
+ /**
12
+ * Animation styles to interpolate
13
+ */
14
+ export declare type AnimationData = AnimationStyle | AnimationStyle[];
15
+ export declare type AnimationEasing = "back" | "backIn" | "backOut" | "backInOut" | "bounce" | "bounceIn" | "bounceOut" | "bounceInOut" | "circle" | "circleIn" | "circleOut" | "circleInOut" | "linear" | "linearIn" | "linearOut" | "linearInOut" | "cubic" | "cubicIn" | "cubicOut" | "cubicInOut" | "elastic" | "elasticIn" | "elasticOut" | "elasticInOut" | "exp" | "expIn" | "expOut" | "expInOut" | "poly" | "polyIn" | "polyOut" | "polyInOut" | "quad" | "quadIn" | "quadOut" | "quadInOut" | "sin" | "sinIn" | "sinOut" | "sinInOut";
16
+ export interface VictoryAnimationProps {
17
+ children: (style: AnimationStyle, info: AnimationInfo) => React.ReactNode;
18
+ duration?: number;
19
+ easing?: AnimationEasing;
20
+ delay?: number;
21
+ onEnd?: () => void;
22
+ data: AnimationData;
23
+ }
24
+ export interface VictoryAnimationState {
25
+ data: AnimationStyle;
26
+ animationInfo: AnimationInfo;
27
+ }
28
+ export interface AnimationInfo {
29
+ progress: number;
30
+ animating: boolean;
31
+ terminating?: boolean;
32
+ }
33
+ export interface VictoryAnimation {
34
+ context: React.ContextType<typeof TimerContext>;
35
+ }
36
+ export declare class VictoryAnimation extends React.Component<VictoryAnimationProps, VictoryAnimationState> {
37
+ static displayName: string;
38
+ static propTypes: {
39
+ children: PropTypes.Requireable<(...args: any[]) => any>;
40
+ data: PropTypes.Requireable<object>;
41
+ delay: PropTypes.Requireable<number>;
42
+ duration: PropTypes.Requireable<number>;
43
+ easing: PropTypes.Requireable<string>;
44
+ onEnd: PropTypes.Requireable<(...args: any[]) => any>;
45
+ };
46
+ static defaultProps: {
47
+ data: {};
48
+ delay: number;
49
+ duration: number;
50
+ easing: string;
51
+ };
52
+ static contextType: React.Context<{
53
+ transitionTimer: Timer;
54
+ animationTimer: Timer;
55
+ }>;
56
+ private interpolator;
57
+ private queue;
58
+ private ease;
59
+ private timer;
60
+ private loopID?;
61
+ constructor(props: any, context: any);
62
+ componentDidMount(): void;
63
+ componentDidUpdate(prevProps: any): void;
64
+ componentWillUnmount(): void;
65
+ toNewName(ease: any): string;
66
+ traverseQueue(): void;
67
+ functionToBeRunEachFrame: (elapsed: any, duration: any) => void;
68
+ render(): React.ReactNode;
69
+ }
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.VictoryAnimation = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var d3Ease = _interopRequireWildcard(require("d3-ease"));
12
+ var d3Ease = _interopRequireWildcard(require("victory-vendor/d3-ease"));
13
13
 
14
14
  var _util = require("./util");
15
15
 
@@ -17,43 +17,107 @@ var _timerContext = _interopRequireDefault(require("../victory-util/timer-contex
17
17
 
18
18
  var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
19
19
 
20
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
26
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
27
+
28
+ 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."); }
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); }
25
31
 
26
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
32
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
33
 
28
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
34
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
35
 
30
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
36
+ 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; }
31
37
 
32
38
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
39
 
34
40
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
41
 
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
42
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
43
 
38
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
44
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
45
 
40
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
46
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
47
+
48
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
49
+
50
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
41
51
 
42
52
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
53
 
44
- var VictoryAnimation =
45
- /*#__PURE__*/
46
- function (_React$Component) {
54
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
55
+
56
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
57
+
58
+ var VictoryAnimation = /*#__PURE__*/function (_React$Component) {
47
59
  _inherits(VictoryAnimation, _React$Component);
48
60
 
61
+ var _super = _createSuper(VictoryAnimation);
62
+
49
63
  function VictoryAnimation(props, context) {
50
64
  var _this;
51
65
 
52
66
  _classCallCheck(this, VictoryAnimation);
53
67
 
54
- _this = _possibleConstructorReturn(this, (VictoryAnimation.__proto__ || Object.getPrototypeOf(VictoryAnimation)).call(this, props, context));
68
+ _this = _super.call(this, props, context);
55
69
  /* defaults */
56
70
 
71
+ _this.interpolator = void 0;
72
+ _this.queue = void 0;
73
+ _this.ease = void 0;
74
+ _this.timer = void 0;
75
+ _this.loopID = void 0;
76
+
77
+ _this.functionToBeRunEachFrame = function (elapsed, duration) {
78
+ /*
79
+ step can generate imprecise values, sometimes greater than 1
80
+ if this happens set the state to 1 and return, cancelling the timer
81
+ */
82
+ duration = duration !== undefined ? duration : _this.props.duration;
83
+ var step = duration ? elapsed / duration : 1;
84
+
85
+ if (step >= 1) {
86
+ _this.setState({
87
+ data: _this.interpolator(1),
88
+ animationInfo: {
89
+ progress: 1,
90
+ animating: false,
91
+ terminating: true
92
+ }
93
+ });
94
+
95
+ if (_this.loopID) {
96
+ _this.timer.unsubscribe(_this.loopID);
97
+ }
98
+
99
+ _this.queue.shift();
100
+
101
+ _this.traverseQueue();
102
+
103
+ return;
104
+ }
105
+ /*
106
+ if we're not at the end of the timer, set the state by passing
107
+ current step value that's transformed by the ease function to the
108
+ interpolator, which is cached for performance whenever props are received
109
+ */
110
+
111
+
112
+ _this.setState({
113
+ data: _this.interpolator(_this.ease(step)),
114
+ animationInfo: {
115
+ progress: step,
116
+ animating: step < 1
117
+ }
118
+ });
119
+ };
120
+
57
121
  _this.state = {
58
122
  data: Array.isArray(_this.props.data) ? _this.props.data[0] : _this.props.data,
59
123
  animationInfo: {
@@ -66,12 +130,6 @@ function (_React$Component) {
66
130
  /* build easing function */
67
131
 
68
132
  _this.ease = d3Ease[_this.toNewName(_this.props.easing)];
69
- /*
70
- There is no autobinding of this in ES6 classes
71
- so we bind functionToBeRunEachFrame to current instance of victory animation class
72
- */
73
-
74
- _this.functionToBeRunEachFrame = _this.functionToBeRunEachFrame.bind(_assertThisInitialized(_this));
75
133
  _this.timer = _this.context.animationTimer;
76
134
  return _this;
77
135
  }
@@ -113,10 +171,10 @@ function (_React$Component) {
113
171
  this.queue.push(this.props.data);
114
172
  /* If an array was supplied */
115
173
  } else {
116
- var _queue;
174
+ var _this$queue;
117
175
 
118
176
  /* Extend the tween queue */
119
- (_queue = this.queue).push.apply(_queue, _toConsumableArray(this.props.data));
177
+ (_this$queue = this.queue).push.apply(_this$queue, _toConsumableArray(this.props.data));
120
178
  }
121
179
  /* Start traversing the tween queue */
122
180
 
@@ -172,49 +230,6 @@ function (_React$Component) {
172
230
  }
173
231
  /* every frame we... */
174
232
 
175
- }, {
176
- key: "functionToBeRunEachFrame",
177
- value: function functionToBeRunEachFrame(elapsed, duration) {
178
- /*
179
- step can generate imprecise values, sometimes greater than 1
180
- if this happens set the state to 1 and return, cancelling the timer
181
- */
182
- duration = duration !== undefined ? duration : this.props.duration;
183
- var step = duration ? elapsed / duration : 1;
184
-
185
- if (step >= 1) {
186
- this.setState({
187
- data: this.interpolator(1),
188
- animationInfo: {
189
- progress: 1,
190
- animating: false,
191
- terminating: true
192
- }
193
- });
194
-
195
- if (this.loopID) {
196
- this.timer.unsubscribe(this.loopID);
197
- }
198
-
199
- this.queue.shift();
200
- this.traverseQueue();
201
- return;
202
- }
203
- /*
204
- if we're not at the end of the timer, set the state by passing
205
- current step value that's transformed by the ease function to the
206
- interpolator, which is cached for performance whenever props are received
207
- */
208
-
209
-
210
- this.setState({
211
- data: this.interpolator(this.ease(step)),
212
- animationInfo: {
213
- progress: step,
214
- animating: step < 1
215
- }
216
- });
217
- }
218
233
  }, {
219
234
  key: "render",
220
235
  value: function render() {
@@ -225,40 +240,20 @@ function (_React$Component) {
225
240
  return VictoryAnimation;
226
241
  }(_react.default.Component);
227
242
 
228
- exports.default = VictoryAnimation;
229
- Object.defineProperty(VictoryAnimation, "displayName", {
230
- configurable: true,
231
- enumerable: true,
232
- writable: true,
233
- value: "VictoryAnimation"
234
- });
235
- Object.defineProperty(VictoryAnimation, "propTypes", {
236
- configurable: true,
237
- enumerable: true,
238
- writable: true,
239
- value: {
240
- children: _propTypes.default.func,
241
- data: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]),
242
- delay: _propTypes.default.number,
243
- duration: _propTypes.default.number,
244
- easing: _propTypes.default.oneOf(["back", "backIn", "backOut", "backInOut", "bounce", "bounceIn", "bounceOut", "bounceInOut", "circle", "circleIn", "circleOut", "circleInOut", "linear", "linearIn", "linearOut", "linearInOut", "cubic", "cubicIn", "cubicOut", "cubicInOut", "elastic", "elasticIn", "elasticOut", "elasticInOut", "exp", "expIn", "expOut", "expInOut", "poly", "polyIn", "polyOut", "polyInOut", "quad", "quadIn", "quadOut", "quadInOut", "sin", "sinIn", "sinOut", "sinInOut"]),
245
- onEnd: _propTypes.default.func
246
- }
247
- });
248
- Object.defineProperty(VictoryAnimation, "defaultProps", {
249
- configurable: true,
250
- enumerable: true,
251
- writable: true,
252
- value: {
253
- data: {},
254
- delay: 0,
255
- duration: 1000,
256
- easing: "quadInOut"
257
- }
258
- });
259
- Object.defineProperty(VictoryAnimation, "contextType", {
260
- configurable: true,
261
- enumerable: true,
262
- writable: true,
263
- value: _timerContext.default
264
- });
243
+ exports.VictoryAnimation = VictoryAnimation;
244
+ VictoryAnimation.displayName = "VictoryAnimation";
245
+ VictoryAnimation.propTypes = {
246
+ children: _propTypes.default.func,
247
+ data: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]),
248
+ delay: _propTypes.default.number,
249
+ duration: _propTypes.default.number,
250
+ easing: _propTypes.default.oneOf(["back", "backIn", "backOut", "backInOut", "bounce", "bounceIn", "bounceOut", "bounceInOut", "circle", "circleIn", "circleOut", "circleInOut", "linear", "linearIn", "linearOut", "linearInOut", "cubic", "cubicIn", "cubicOut", "cubicInOut", "elastic", "elasticIn", "elasticOut", "elasticInOut", "exp", "expIn", "expOut", "expInOut", "poly", "polyIn", "polyOut", "polyInOut", "quad", "quadIn", "quadOut", "quadInOut", "sin", "sinIn", "sinOut", "sinInOut"]),
251
+ onEnd: _propTypes.default.func
252
+ };
253
+ VictoryAnimation.defaultProps = {
254
+ data: {},
255
+ delay: 0,
256
+ duration: 1000,
257
+ easing: "quadInOut"
258
+ };
259
+ VictoryAnimation.contextType = _timerContext.default;
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { BlockProps } from "../victory-theme/victory-theme";
4
+ import { OriginType } from "../victory-label/victory-label";
5
+ export interface VictoryClipContainerProps {
6
+ "aria-label"?: string;
7
+ children?: React.ReactElement | React.ReactElement[];
8
+ circleComponent?: React.ReactElement;
9
+ className?: string;
10
+ clipHeight?: number;
11
+ clipId?: number | string;
12
+ clipPadding?: BlockProps;
13
+ clipPathComponent?: React.ReactElement;
14
+ clipWidth?: number;
15
+ events?: React.DOMAttributes<any>;
16
+ groupComponent?: React.ReactElement;
17
+ origin?: OriginType;
18
+ polar?: boolean;
19
+ radius?: number;
20
+ rectComponent?: React.ReactElement;
21
+ translateX?: number;
22
+ translateY?: number;
23
+ }
24
+ export declare class VictoryClipContainer extends React.Component<VictoryClipContainerProps> {
25
+ static displayName: string;
26
+ static role: string;
27
+ static propTypes: {
28
+ "aria-label": PropTypes.Requireable<string>;
29
+ children: PropTypes.Requireable<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
30
+ circleComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
31
+ className: PropTypes.Requireable<string>;
32
+ clipHeight: any;
33
+ clipId: PropTypes.Requireable<string | number>;
34
+ clipPadding: PropTypes.Requireable<PropTypes.InferProps<{
35
+ top: PropTypes.Requireable<number>;
36
+ bottom: PropTypes.Requireable<number>;
37
+ left: PropTypes.Requireable<number>;
38
+ right: PropTypes.Requireable<number>;
39
+ }>>;
40
+ clipPathComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
41
+ clipWidth: any;
42
+ events: PropTypes.Requireable<object>;
43
+ groupComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
44
+ origin: PropTypes.Requireable<PropTypes.InferProps<{
45
+ x: any;
46
+ y: any;
47
+ }>>;
48
+ polar: PropTypes.Requireable<boolean>;
49
+ radius: any;
50
+ style: PropTypes.Requireable<object>;
51
+ tabIndex: PropTypes.Requireable<number>;
52
+ transform: PropTypes.Requireable<string>;
53
+ translateX: PropTypes.Requireable<number>;
54
+ translateY: PropTypes.Requireable<number>;
55
+ };
56
+ static defaultProps: {
57
+ circleComponent: JSX.Element;
58
+ rectComponent: JSX.Element;
59
+ clipPathComponent: JSX.Element;
60
+ groupComponent: JSX.Element;
61
+ };
62
+ private clipId;
63
+ constructor(props: VictoryClipContainerProps);
64
+ calculateAttributes(props: any): {
65
+ x: number;
66
+ y: number;
67
+ width: number;
68
+ height: number;
69
+ };
70
+ renderClippedGroup(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
71
+ renderGroup(props: any): React.DetailedReactHTMLElement<any, HTMLElement>;
72
+ renderClipComponent(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
73
+ getClipValue(props: any, axis: any): any;
74
+ getTranslateValue(props: any, axis: any): any;
75
+ render(): React.DetailedReactHTMLElement<any, HTMLElement>;
76
+ }