victory-core 37.3.1 → 37.3.3

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 (129) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/victory-core.js +436 -405
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/types/callbacks.d.ts +11 -11
  5. package/es/types/prop-types.d.ts +28 -28
  6. package/es/victory-animation/util.js +7 -7
  7. package/es/victory-animation/victory-animation.d.ts +3 -3
  8. package/es/victory-clip-container/victory-clip-container.d.ts +6 -1
  9. package/es/victory-clip-container/victory-clip-container.js +20 -12
  10. package/es/victory-container/victory-container.js +5 -5
  11. package/es/victory-label/victory-label.d.ts +3 -3
  12. package/es/victory-label/victory-label.js +12 -16
  13. package/es/victory-portal/victory-portal.js +4 -4
  14. package/es/victory-primitives/arc.js +2 -2
  15. package/es/victory-primitives/background.js +2 -2
  16. package/es/victory-primitives/border.js +2 -2
  17. package/es/victory-primitives/line-segment.js +2 -2
  18. package/es/victory-primitives/point.js +2 -2
  19. package/es/victory-primitives/tspan.d.ts +0 -1
  20. package/es/victory-primitives/types.d.ts +1 -1
  21. package/es/victory-primitives/whisker.d.ts +1 -1
  22. package/es/victory-primitives/whisker.js +2 -2
  23. package/es/victory-theme/types.d.ts +11 -11
  24. package/es/victory-transition/victory-transition.d.ts +1 -1
  25. package/es/victory-transition/victory-transition.js +8 -8
  26. package/es/victory-util/add-events.d.ts +8 -8
  27. package/es/victory-util/add-events.js +14 -14
  28. package/es/victory-util/axis.js +12 -12
  29. package/es/victory-util/data.js +16 -20
  30. package/es/victory-util/domain.js +13 -16
  31. package/es/victory-util/events.d.ts +5 -5
  32. package/es/victory-util/events.js +17 -23
  33. package/es/victory-util/helpers.d.ts +94 -19
  34. package/es/victory-util/helpers.js +95 -50
  35. package/es/victory-util/hooks/use-animation-state.d.ts +2 -2
  36. package/es/victory-util/hooks/use-animation-state.js +4 -4
  37. package/es/victory-util/label-helpers.d.ts +4 -3
  38. package/es/victory-util/label-helpers.js +3 -3
  39. package/es/victory-util/line-helpers.d.ts +1 -1
  40. package/es/victory-util/log.js +3 -2
  41. package/es/victory-util/merge-refs.d.ts +2 -2
  42. package/es/victory-util/scale.js +2 -3
  43. package/es/victory-util/selection.d.ts +3 -3
  44. package/es/victory-util/textsize.js +7 -5
  45. package/es/victory-util/timer.d.ts +1 -1
  46. package/es/victory-util/transitions.d.ts +1 -1
  47. package/es/victory-util/transitions.js +15 -19
  48. package/es/victory-util/type-helpers.d.ts +0 -1
  49. package/es/victory-util/type-helpers.js +0 -5
  50. package/es/victory-util/user-props.d.ts +2 -2
  51. package/es/victory-util/wrapper.js +12 -13
  52. package/lib/types/callbacks.d.ts +11 -11
  53. package/lib/types/prop-types.d.ts +28 -28
  54. package/lib/victory-animation/util.js +7 -7
  55. package/lib/victory-animation/victory-animation.d.ts +3 -3
  56. package/lib/victory-clip-container/victory-clip-container.d.ts +6 -1
  57. package/lib/victory-clip-container/victory-clip-container.js +20 -12
  58. package/lib/victory-container/victory-container.js +6 -6
  59. package/lib/victory-label/victory-label.d.ts +3 -3
  60. package/lib/victory-label/victory-label.js +12 -16
  61. package/lib/victory-portal/victory-portal.js +5 -5
  62. package/lib/victory-primitives/arc.js +2 -2
  63. package/lib/victory-primitives/background.js +2 -2
  64. package/lib/victory-primitives/border.js +2 -2
  65. package/lib/victory-primitives/line-segment.js +2 -2
  66. package/lib/victory-primitives/point.js +2 -2
  67. package/lib/victory-primitives/tspan.d.ts +0 -1
  68. package/lib/victory-primitives/types.d.ts +1 -1
  69. package/lib/victory-primitives/whisker.d.ts +1 -1
  70. package/lib/victory-primitives/whisker.js +2 -2
  71. package/lib/victory-theme/types.d.ts +11 -11
  72. package/lib/victory-transition/victory-transition.d.ts +1 -1
  73. package/lib/victory-transition/victory-transition.js +8 -8
  74. package/lib/victory-util/add-events.d.ts +8 -8
  75. package/lib/victory-util/add-events.js +14 -14
  76. package/lib/victory-util/axis.js +12 -12
  77. package/lib/victory-util/data.js +16 -21
  78. package/lib/victory-util/domain.js +13 -17
  79. package/lib/victory-util/events.d.ts +5 -5
  80. package/lib/victory-util/events.js +17 -24
  81. package/lib/victory-util/helpers.d.ts +94 -19
  82. package/lib/victory-util/helpers.js +96 -52
  83. package/lib/victory-util/hooks/use-animation-state.d.ts +2 -2
  84. package/lib/victory-util/hooks/use-animation-state.js +4 -4
  85. package/lib/victory-util/label-helpers.d.ts +4 -3
  86. package/lib/victory-util/label-helpers.js +3 -5
  87. package/lib/victory-util/line-helpers.d.ts +1 -1
  88. package/lib/victory-util/log.js +3 -2
  89. package/lib/victory-util/merge-refs.d.ts +2 -2
  90. package/lib/victory-util/scale.js +2 -4
  91. package/lib/victory-util/selection.d.ts +3 -3
  92. package/lib/victory-util/textsize.js +5 -5
  93. package/lib/victory-util/timer.d.ts +1 -1
  94. package/lib/victory-util/transitions.d.ts +1 -1
  95. package/lib/victory-util/transitions.js +15 -19
  96. package/lib/victory-util/type-helpers.d.ts +0 -1
  97. package/lib/victory-util/type-helpers.js +0 -6
  98. package/lib/victory-util/user-props.d.ts +2 -2
  99. package/lib/victory-util/wrapper.js +12 -13
  100. package/package.json +6 -38
  101. package/src/victory-animation/util.ts +4 -2
  102. package/src/victory-clip-container/victory-clip-container.tsx +26 -11
  103. package/src/victory-container/victory-container.tsx +4 -4
  104. package/src/victory-label/victory-label.tsx +5 -3
  105. package/src/victory-portal/victory-portal.tsx +3 -1
  106. package/src/victory-primitives/arc.tsx +1 -1
  107. package/src/victory-primitives/background.tsx +1 -1
  108. package/src/victory-primitives/border.tsx +1 -1
  109. package/src/victory-primitives/line-segment.tsx +1 -1
  110. package/src/victory-primitives/point.tsx +3 -3
  111. package/src/victory-primitives/whisker.tsx +1 -1
  112. package/src/victory-transition/victory-transition.tsx +5 -3
  113. package/src/victory-util/add-events.tsx +6 -3
  114. package/src/victory-util/axis.tsx +8 -4
  115. package/src/victory-util/common-props.tsx +3 -3
  116. package/src/victory-util/data.ts +9 -13
  117. package/src/victory-util/domain.ts +8 -6
  118. package/src/victory-util/events.ts +18 -13
  119. package/src/victory-util/helpers.ts +155 -40
  120. package/src/victory-util/hooks/use-animation-state.ts +1 -1
  121. package/src/victory-util/label-helpers.ts +1 -2
  122. package/src/victory-util/log.ts +3 -2
  123. package/src/victory-util/merge-refs.ts +2 -0
  124. package/src/victory-util/scale.ts +1 -2
  125. package/src/victory-util/textsize.ts +2 -1
  126. package/src/victory-util/transitions.ts +6 -6
  127. package/src/victory-util/type-helpers.ts +0 -5
  128. package/src/victory-util/user-props.ts +1 -1
  129. package/src/victory-util/wrapper.tsx +5 -2
@@ -1,6 +1,27 @@
1
1
  import React from "react";
2
- import { CallbackArgs } from "../types/callbacks";
3
2
  import { ValueOrAccessor } from "../types/prop-types";
3
+ export type ElementPadding = {
4
+ top: number;
5
+ bottom: number;
6
+ left: number;
7
+ right: number;
8
+ };
9
+ export type MaybePointData = {
10
+ x?: number;
11
+ x0?: number;
12
+ x1?: number;
13
+ y?: number;
14
+ y0?: number;
15
+ y1?: number;
16
+ _x?: number;
17
+ _x0?: number;
18
+ _x1?: number;
19
+ _y?: number;
20
+ _y0?: number;
21
+ _y1?: number;
22
+ _voronoiX?: number;
23
+ _voronoiY?: number;
24
+ };
4
25
  /**
5
26
  * Creates an object composed of the inverted keys and values of object.
6
27
  * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
@@ -14,32 +35,83 @@ export declare function invert(original: Record<string, string | number>): {};
14
35
  * @returns {Object} new object with same properties as originalObject
15
36
  */
16
37
  export declare function omit<T, Keys extends keyof T>(originalObject: T, ks?: Array<Keys>): Omit<T, Keys>;
17
- export declare function getPoint(datum: any): any;
18
- export declare function scalePoint(props: any, datum: any): {
19
- x: any;
20
- x0: any;
21
- y: any;
22
- y0: any;
23
- };
24
- export declare function getPadding(props: any, name?: string): {
25
- top: any;
26
- bottom: any;
27
- left: any;
28
- right: any;
38
+ /**
39
+ * Coalesce the x and y values from a data point
40
+ */
41
+ export declare function getPoint(datum: MaybePointData): MaybePointData;
42
+ /**
43
+ * Scale a point based on the origin, direction, and given scale function
44
+ */
45
+ export declare function scalePoint(props: {
46
+ scale: {
47
+ x: (x?: number) => number;
48
+ y: (y?: number) => number;
49
+ };
50
+ polar?: boolean;
51
+ horizontal?: boolean;
52
+ origin?: {
53
+ x: number;
54
+ y: number;
55
+ };
56
+ }, datum: MaybePointData): {
57
+ x: number;
58
+ x0: number;
59
+ y: number;
60
+ y0: number;
29
61
  };
30
- export declare function isTooltip(component: any): boolean;
62
+ /**
63
+ * Returns a padding value from a number or partial padding values
64
+ */
65
+ export declare function getPadding(padding?: number | Partial<ElementPadding>): ElementPadding;
66
+ /**
67
+ * Returns true if the component is defined as a tooltip
68
+ */
69
+ export declare function isTooltip(component?: {
70
+ type?: {
71
+ role?: string;
72
+ };
73
+ }): boolean;
31
74
  export declare function getDefaultStyles(props: any, role: any): any;
32
75
  export declare function getStyles(style: any, defaultStyles: any): any;
33
- export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, CallbackArgs>, props: CallbackArgs): TValue;
76
+ /**
77
+ * Returns the value of a prop or accessor function with the given props
78
+ */
79
+ export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, Record<string, any>>, props: Record<string, any>): TValue;
34
80
  export declare function evaluateStyle(style: any, props: any): any;
35
81
  export declare function degreesToRadians(degrees: any): any;
36
82
  export declare function radiansToDegrees(radians: any): any;
37
- export declare function getRadius(props: any): number;
38
- export declare function getPolarOrigin(props: any): {
83
+ /**
84
+ * Get the maximum radius that will fit in the container
85
+ */
86
+ export declare function getRadius(options: {
87
+ height: number;
88
+ width: number;
89
+ padding: ElementPadding;
90
+ }): number;
91
+ /**
92
+ * Returns the origin for a polar chart within the padded area
93
+ */
94
+ export declare function getPolarOrigin(props: {
95
+ height: number;
96
+ width: number;
97
+ padding: ElementPadding;
98
+ }): {
39
99
  x: number;
40
100
  y: number;
41
101
  };
42
- export declare function getRange(props: any, axis: any): any;
102
+ /**
103
+ * Determine the range of an axis based on the given props
104
+ */
105
+ export declare function getRange(props: {
106
+ range?: [number, number];
107
+ polar?: boolean;
108
+ innerRadius?: number;
109
+ startAngle?: number;
110
+ endAngle?: number;
111
+ height: number;
112
+ width: number;
113
+ padding: number | Partial<ElementPadding>;
114
+ }, axis: "x" | "y"): any;
43
115
  /**
44
116
  * Checks if `value` is `null` or `undefined`.
45
117
  * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
@@ -93,5 +165,8 @@ export declare function reduceChildren<TChildren extends React.ReactNode, TItem,
93
165
  * @returns {Boolean} returns true if the props object contains `horizontal: true` of if any
94
166
  * children or nested children are horizontal
95
167
  */
96
- export declare function isHorizontal(props: any): any;
168
+ export declare function isHorizontal(props: {
169
+ horizontal?: boolean;
170
+ children?: React.ReactNode;
171
+ }): any;
97
172
  //# sourceMappingURL=helpers.d.ts.map
@@ -1,30 +1,34 @@
1
- import _pick from "lodash/pick";
2
- import _property from "lodash/property";
3
- import _defaults from "lodash/defaults";
4
- /* eslint-disable no-use-before-define */
5
1
  import React, { isValidElement } from "react";
6
- // Private Functions
7
-
8
- function getCartesianRange(props, axis) {
9
- // determine how to lay the axis and what direction positive and negative are
10
- const vertical = axis !== "x";
11
- const padding = getPadding(props);
2
+ import defaults from "lodash/defaults";
3
+ import property from "lodash/property";
4
+ import pick from "lodash/pick";
5
+ /**
6
+ * Determine the range of a cartesian axis
7
+ */
8
+ function getCartesianRange(options) {
9
+ const vertical = options.axis !== "x";
12
10
  if (vertical) {
13
- return [props.height - padding.bottom, padding.top];
11
+ return [options.height - options.padding.bottom, options.padding.top];
14
12
  }
15
- return [padding.left, props.width - padding.right];
13
+ return [options.padding.left, options.width - options.padding.right];
16
14
  }
17
- function getPolarRange(props, axis) {
18
- if (axis === "x") {
19
- const startAngle = degreesToRadians(props.startAngle || 0);
20
- const endAngle = degreesToRadians(props.endAngle || 360);
15
+
16
+ /**
17
+ * Determine the range of a polar axis in radians
18
+ */
19
+ function getPolarRange(options) {
20
+ if (options.axis === "x") {
21
+ const startAngle = degreesToRadians(options.startAngle || 0);
22
+ const endAngle = degreesToRadians(options.endAngle || 360);
21
23
  return [startAngle, endAngle];
22
24
  }
23
- return [props.innerRadius || 0, getRadius(props)];
25
+ return [options.innerRadius || 0, getRadius({
26
+ height: options.height,
27
+ width: options.width,
28
+ padding: options.padding
29
+ })];
24
30
  }
25
31
 
26
- // Exported Functions
27
-
28
32
  /**
29
33
  * Creates an object composed of the inverted keys and values of object.
30
34
  * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
@@ -61,8 +65,11 @@ export function omit(originalObject, ks) {
61
65
  }
62
66
  return newObject;
63
67
  }
68
+
69
+ /**
70
+ * Coalesce the x and y values from a data point
71
+ */
64
72
  export function getPoint(datum) {
65
- const exists = val => val !== undefined;
66
73
  const {
67
74
  _x,
68
75
  _x1,
@@ -73,16 +80,20 @@ export function getPoint(datum) {
73
80
  _y0,
74
81
  _voronoiY
75
82
  } = datum;
76
- const defaultX = exists(_x1) ? _x1 : _x;
77
- const defaultY = exists(_y1) ? _y1 : _y;
83
+ const defaultX = _x1 ?? _x;
84
+ const defaultY = _y1 ?? _y;
78
85
  const point = {
79
- x: exists(_voronoiX) ? _voronoiX : defaultX,
80
- x0: exists(_x0) ? _x0 : _x,
81
- y: exists(_voronoiY) ? _voronoiY : defaultY,
82
- y0: exists(_y0) ? _y0 : _y
86
+ x: _voronoiX ?? defaultX,
87
+ x0: _x0 ?? _x,
88
+ y: _voronoiY ?? defaultY,
89
+ y0: _y0 ?? _y
83
90
  };
84
- return _defaults({}, point, datum);
91
+ return defaults({}, point, datum);
85
92
  }
93
+
94
+ /**
95
+ * Scale a point based on the origin, direction, and given scale function
96
+ */
86
97
  export function scalePoint(props, datum) {
87
98
  const {
88
99
  scale,
@@ -105,11 +116,11 @@ export function scalePoint(props, datum) {
105
116
  y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
106
117
  };
107
118
  }
108
- export function getPadding(props, name) {
109
- if (name === void 0) {
110
- name = "padding";
111
- }
112
- const padding = props[name];
119
+
120
+ /**
121
+ * Returns a padding value from a number or partial padding values
122
+ */
123
+ export function getPadding(padding) {
113
124
  const paddingVal = typeof padding === "number" ? padding : 0;
114
125
  const paddingObj = typeof padding === "object" ? padding : {};
115
126
  return {
@@ -119,6 +130,10 @@ export function getPadding(props, name) {
119
130
  right: paddingObj.right || paddingVal
120
131
  };
121
132
  }
133
+
134
+ /**
135
+ * Returns true if the component is defined as a tooltip
136
+ */
122
137
  export function isTooltip(component) {
123
138
  const labelRole = component && component.type && component.type.role;
124
139
  return labelRole === "tooltip";
@@ -133,8 +148,8 @@ export function getDefaultStyles(props, role) {
133
148
  return defaultStyles;
134
149
  }
135
150
  const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
136
- const labelStyle = _defaults({}, tooltipStyle, defaultStyles.labels);
137
- return _defaults({}, {
151
+ const labelStyle = defaults({}, tooltipStyle, defaultStyles.labels);
152
+ return defaults({}, {
138
153
  labels: labelStyle
139
154
  }, defaultStyles);
140
155
  }
@@ -142,7 +157,7 @@ export function getStyles(style, defaultStyles) {
142
157
  const width = "100%";
143
158
  const height = "100%";
144
159
  if (!style) {
145
- return _defaults({
160
+ return defaults({
146
161
  parent: {
147
162
  height,
148
163
  width
@@ -158,14 +173,18 @@ export function getStyles(style, defaultStyles) {
158
173
  const defaultLabels = defaultStyles && defaultStyles.labels || {};
159
174
  const defaultData = defaultStyles && defaultStyles.data || {};
160
175
  return {
161
- parent: _defaults({}, parent, defaultParent, {
176
+ parent: defaults({}, parent, defaultParent, {
162
177
  width,
163
178
  height
164
179
  }),
165
- labels: _defaults({}, labels, defaultLabels),
166
- data: _defaults({}, data, defaultData)
180
+ labels: defaults({}, labels, defaultLabels),
181
+ data: defaults({}, data, defaultData)
167
182
  };
168
183
  }
184
+
185
+ /**
186
+ * Returns the value of a prop or accessor function with the given props
187
+ */
169
188
  export function evaluateProp(prop, props) {
170
189
  return isFunction(prop) ? prop(props) : prop;
171
190
  }
@@ -187,19 +206,28 @@ export function degreesToRadians(degrees) {
187
206
  export function radiansToDegrees(radians) {
188
207
  return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
189
208
  }
190
- export function getRadius(props) {
209
+
210
+ /**
211
+ * Get the maximum radius that will fit in the container
212
+ */
213
+ export function getRadius(options) {
214
+ const {
215
+ width,
216
+ height,
217
+ padding
218
+ } = options;
191
219
  const {
192
220
  left,
193
221
  right,
194
222
  top,
195
223
  bottom
196
- } = getPadding(props);
197
- const {
198
- width,
199
- height
200
- } = props;
224
+ } = padding;
201
225
  return Math.min(width - left - right, height - top - bottom) / 2;
202
226
  }
227
+
228
+ /**
229
+ * Returns the origin for a polar chart within the padded area
230
+ */
203
231
  export function getPolarOrigin(props) {
204
232
  const {
205
233
  width,
@@ -210,7 +238,7 @@ export function getPolarOrigin(props) {
210
238
  bottom,
211
239
  left,
212
240
  right
213
- } = getPadding(props);
241
+ } = getPadding(props.padding);
214
242
  const radius = Math.min(width - left - right, height - top - bottom) / 2;
215
243
  const offsetWidth = width / 2 + left - right;
216
244
  const offsetHeight = height / 2 + top - bottom;
@@ -219,13 +247,30 @@ export function getPolarOrigin(props) {
219
247
  y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
220
248
  };
221
249
  }
250
+
251
+ /**
252
+ * Determine the range of an axis based on the given props
253
+ */
222
254
  export function getRange(props, axis) {
223
255
  if (props.range && props.range[axis]) {
224
256
  return props.range[axis];
225
257
  } else if (props.range && Array.isArray(props.range)) {
226
258
  return props.range;
227
259
  }
228
- return props.polar ? getPolarRange(props, axis) : getCartesianRange(props, axis);
260
+ return props.polar ? getPolarRange({
261
+ axis,
262
+ innerRadius: props.innerRadius,
263
+ startAngle: props.startAngle,
264
+ endAngle: props.endAngle,
265
+ height: props.height,
266
+ width: props.width,
267
+ padding: getPadding(props.padding)
268
+ }) : getCartesianRange({
269
+ axis,
270
+ height: props.height,
271
+ width: props.width,
272
+ padding: getPadding(props.padding)
273
+ });
229
274
  }
230
275
 
231
276
  /**
@@ -257,7 +302,7 @@ export function createAccessor(key) {
257
302
  return x => x;
258
303
  }
259
304
  // otherwise, assume it is an array index, property key or path (_.property handles all three)
260
- return _property(key);
305
+ return property(key);
261
306
  }
262
307
  export function modifyProps(props, fallbackProps, role) {
263
308
  const theme = props.theme && props.theme[role] ? props.theme[role] : {};
@@ -266,7 +311,7 @@ export function modifyProps(props, fallbackProps, role) {
266
311
  const defaultObject = horizontal === undefined ? {} : {
267
312
  horizontal
268
313
  };
269
- return _defaults(defaultObject, props, themeProps, fallbackProps);
314
+ return defaults(defaultObject, props, themeProps, fallbackProps);
270
315
  }
271
316
 
272
317
  /**
@@ -353,9 +398,9 @@ initialMemo, combine) {
353
398
  const childRole = child.type && child.type.role;
354
399
  const childName = child.props.name || `${childRole}-${names[index]}`;
355
400
  if (child.props && child.props.children) {
356
- const childProps = Object.assign({}, child.props, _pick(parentProps, sharedProps));
401
+ const childProps = Object.assign({}, child.props, pick(parentProps, sharedProps));
357
402
  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));
403
+ const nestedChildProps = Object.assign({}, c.props, pick(childProps, sharedProps));
359
404
  return /*#__PURE__*/React.cloneElement(c, nestedChildProps);
360
405
  });
361
406
  const childNames = nestedChildren.map((c, i) => `${childName}-${i}`);
@@ -1,5 +1,5 @@
1
- declare type AnyObject = Record<string, any>;
2
- export declare type AnimationState = {
1
+ type AnyObject = Record<string, any>;
2
+ export type AnimationState = {
3
3
  nodesShouldLoad?: boolean;
4
4
  nodesDoneLoad?: boolean;
5
5
  animating?: boolean;
@@ -1,5 +1,5 @@
1
- import _defaults from "lodash/defaults";
2
1
  import React from "react";
2
+ import defaults from "lodash/defaults";
3
3
  import * as Collection from "../collection";
4
4
  import * as Transitions from "../transitions";
5
5
  const INITIAL_STATE = {
@@ -29,7 +29,7 @@ export const useAnimationState = function (initialState) {
29
29
  const getFilteredState = () => {
30
30
  let childrenTransitions = state && state.childrenTransitions;
31
31
  childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
32
- return _defaults({
32
+ return defaults({
33
33
  childrenTransitions
34
34
  }, state);
35
35
  };
@@ -40,7 +40,7 @@ export const useAnimationState = function (initialState) {
40
40
  const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
41
41
  getTransitions = childComponent => getTransitionProps(childComponent, index);
42
42
  }
43
- return _defaults({
43
+ return defaults({
44
44
  getTransitions,
45
45
  parentState
46
46
  }, props.animate, child.props.animate);
@@ -54,7 +54,7 @@ export const useAnimationState = function (initialState) {
54
54
  if (props.animate.parentState) {
55
55
  const nodesWillExit = props.animate.parentState.nodesWillExit;
56
56
  const oldProps = nodesWillExit ? props : null;
57
- const newState = _defaults({
57
+ const newState = defaults({
58
58
  oldProps,
59
59
  nextProps
60
60
  }, props.animate.parentState);
@@ -1,4 +1,5 @@
1
- export declare function getText(props: any, datum: Record<string, any> | undefined, index: any): any;
1
+ import { VictoryLabelProps } from "../victory-label/victory-label";
2
+ export declare function getText(props: any, datum: VictoryLabelProps["datum"], index: any): any;
2
3
  export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle";
3
4
  export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle";
4
5
  export declare function getPolarAngle(props: any, baseAngle?: any): number;
@@ -16,8 +17,8 @@ export declare function getProps(props: any, index: any): {
16
17
  text: any;
17
18
  textAnchor: any;
18
19
  verticalAnchor: any;
19
- x: any;
20
- y: any;
20
+ x: number;
21
+ y: number;
21
22
  dx: number | undefined;
22
23
  dy: number | undefined;
23
24
  width: any;
@@ -1,6 +1,6 @@
1
- import _defaults from "lodash/defaults";
2
- /* eslint-disable no-use-before-define */
3
1
  import * as Helpers from "./helpers";
2
+ import defaults from "lodash/defaults";
3
+
4
4
  // Private Functions
5
5
 
6
6
  function getVerticalAnchor(props, datum) {
@@ -228,5 +228,5 @@ export function getProps(props, index) {
228
228
  return labelProps;
229
229
  }
230
230
  const tooltipTheme = theme && theme.tooltip || {};
231
- return _defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
231
+ return defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
232
232
  }
@@ -1,5 +1,5 @@
1
1
  import * as d3Shape from "victory-vendor/d3-shape";
2
- export declare type CurveName = "basis" | "cardinal" | "bumpX" | "bumpY" | "bundle" | "catmullRom" | "linear" | "monotoneX" | "monotoneY" | "step" | "stepAfter" | "stepBefore" | "natural";
2
+ export type CurveName = "basis" | "cardinal" | "bumpX" | "bumpY" | "bundle" | "catmullRom" | "linear" | "monotoneX" | "monotoneY" | "step" | "stepAfter" | "stepBefore" | "natural";
3
3
  export declare const getInterpolationFunction: (props: any) => any;
4
4
  export declare const getLineFunction: (props: any) => d3Shape.LineRadial<[number, number]> | d3Shape.Line<[number, number]>;
5
5
  //# sourceMappingURL=line-helpers.d.ts.map
@@ -1,8 +1,9 @@
1
- /* global console */
1
+ /* global console process */
2
2
  /* eslint-disable no-console */
3
3
 
4
- // TODO: Use "warning" npm module like React is switching to.
5
4
  export function warn(message) {
5
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
+ // @ts-ignore - Webpack DefinePlugin will replace process.env.NODE_ENV
6
7
  if (process.env.NODE_ENV !== "production") {
7
8
  if (console && console.warn) {
8
9
  console.warn(message);
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- declare type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
1
+ import React from "react";
2
+ type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
3
3
  /**
4
4
  * Used to merge multiple React refs into a single callback ref.
5
5
  *
@@ -1,5 +1,4 @@
1
- import _isPlainObject from "lodash/isPlainObject";
2
- /* eslint-disable no-use-before-define */
1
+ import isPlainObject from "lodash/isPlainObject";
3
2
  import * as Helpers from "./helpers";
4
3
  import * as Collection from "./collection";
5
4
  import * as d3Scale from "victory-vendor/d3-scale";
@@ -52,7 +51,7 @@ function getScaleTypeFromData(props, axis) {
52
51
  }
53
52
  const accessor = Helpers.createAccessor(props[axis]);
54
53
  const axisData = props.data.map(datum => {
55
- const processedData = _isPlainObject(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
54
+ const processedData = isPlainObject(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
56
55
  return processedData !== undefined ? processedData : datum[axis];
57
56
  });
58
57
  return Collection.containsDates(axisData) ? "time" : "linear";
@@ -9,15 +9,15 @@ export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "sc
9
9
  };
10
10
  export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
11
11
  export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
12
- export declare type SVGCoordinateType = {
12
+ export type SVGCoordinateType = {
13
13
  x: number;
14
14
  y: number;
15
15
  };
16
- export declare type SVGCoordinateBounds = {
16
+ export type SVGCoordinateBounds = {
17
17
  x: readonly [number, number];
18
18
  y: readonly [number, number];
19
19
  };
20
- declare type ComputedCommonProps = {
20
+ type ComputedCommonProps = {
21
21
  scale: ScaleXYPropType;
22
22
  x1: number;
23
23
  x2: number;
@@ -1,6 +1,8 @@
1
- import _memoize from "lodash/memoize";
2
- import _defaults from "lodash/defaults"; // http://www.pearsonified.com/2012/01/characters-per-line.php
1
+ // http://www.pearsonified.com/2012/01/characters-per-line.php
3
2
  /* eslint-disable no-magic-numbers */
3
+ import defaults from "lodash/defaults";
4
+ import memoize from "lodash/memoize";
5
+
4
6
  // Based on measuring specific character widths
5
7
  // as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
6
8
  // For new fonts: pull gist, open index.html locally, add font files (if not generic), enter font name in `font-family` input
@@ -179,7 +181,7 @@ export const convertLengthToPixels = (length, fontSize) => {
179
181
  };
180
182
  const _prepareParams = (inputStyle, index) => {
181
183
  const lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
182
- const style = _defaults({}, lineStyle, defaultStyle);
184
+ const style = defaults({}, lineStyle, defaultStyle);
183
185
  return Object.assign({}, style, {
184
186
  fontFamily: style.fontFamily,
185
187
  letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
@@ -227,7 +229,7 @@ const _approximateDimensionsInternal = (text, style) => {
227
229
  height: heightWithRotate * coefficients.heightOverlapCoef
228
230
  };
229
231
  };
230
- const _getMeasurementContainer = _memoize(() => {
232
+ const _getMeasurementContainer = memoize(() => {
231
233
  const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
232
234
  element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
233
235
  element.setAttribute("width", "300");
@@ -248,7 +250,7 @@ const styleToKeyComponent = style => {
248
250
  }
249
251
  return `${style.angle}:${style.fontFamily}:${style.fontSize}:${style.letterSpacing}:${style.lineHeight}`;
250
252
  };
251
- const _measureDimensionsInternal = _memoize((text, style) => {
253
+ const _measureDimensionsInternal = memoize((text, style) => {
252
254
  let containerElement = _getMeasurementContainer();
253
255
  if (!containerElement.isConnected) {
254
256
  _getMeasurementContainer.cache.clear?.();
@@ -1,4 +1,4 @@
1
- declare type TimerCallback = (elapsed: number, duration: number) => void;
1
+ type TimerCallback = (elapsed: number, duration: number) => void;
2
2
  export default class Timer {
3
3
  private shouldAnimate;
4
4
  private readonly subscribers;
@@ -21,7 +21,7 @@ export declare function getInitialTransitionState(oldChildren: any, nextChildren
21
21
  childrenTransitions: any;
22
22
  nodesShouldEnter: boolean;
23
23
  };
24
- declare type TransitionProps = {
24
+ type TransitionProps = {
25
25
  data: any;
26
26
  animate?: AnimatePropTypeInterface;
27
27
  clipWidth?: number;