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
@@ -27,37 +27,40 @@ exports.radiansToDegrees = radiansToDegrees;
27
27
  exports.range = range;
28
28
  exports.reduceChildren = reduceChildren;
29
29
  exports.scalePoint = scalePoint;
30
- var _pick2 = _interopRequireDefault(require("lodash/pick"));
31
- var _property2 = _interopRequireDefault(require("lodash/property"));
32
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
33
30
  var _react = _interopRequireWildcard(require("react"));
31
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
32
+ var _property = _interopRequireDefault(require("lodash/property"));
33
+ var _pick = _interopRequireDefault(require("lodash/pick"));
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
35
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
35
36
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
- /* eslint-disable no-use-before-define */
38
-
39
- // Private Functions
40
-
41
- function getCartesianRange(props, axis) {
42
- // determine how to lay the axis and what direction positive and negative are
43
- const vertical = axis !== "x";
44
- const padding = getPadding(props);
37
+ /**
38
+ * Determine the range of a cartesian axis
39
+ */
40
+ function getCartesianRange(options) {
41
+ const vertical = options.axis !== "x";
45
42
  if (vertical) {
46
- return [props.height - padding.bottom, padding.top];
43
+ return [options.height - options.padding.bottom, options.padding.top];
47
44
  }
48
- return [padding.left, props.width - padding.right];
45
+ return [options.padding.left, options.width - options.padding.right];
49
46
  }
50
- function getPolarRange(props, axis) {
51
- if (axis === "x") {
52
- const startAngle = degreesToRadians(props.startAngle || 0);
53
- const endAngle = degreesToRadians(props.endAngle || 360);
47
+
48
+ /**
49
+ * Determine the range of a polar axis in radians
50
+ */
51
+ function getPolarRange(options) {
52
+ if (options.axis === "x") {
53
+ const startAngle = degreesToRadians(options.startAngle || 0);
54
+ const endAngle = degreesToRadians(options.endAngle || 360);
54
55
  return [startAngle, endAngle];
55
56
  }
56
- return [props.innerRadius || 0, getRadius(props)];
57
+ return [options.innerRadius || 0, getRadius({
58
+ height: options.height,
59
+ width: options.width,
60
+ padding: options.padding
61
+ })];
57
62
  }
58
63
 
59
- // Exported Functions
60
-
61
64
  /**
62
65
  * Creates an object composed of the inverted keys and values of object.
63
66
  * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
@@ -94,8 +97,11 @@ function omit(originalObject, ks) {
94
97
  }
95
98
  return newObject;
96
99
  }
100
+
101
+ /**
102
+ * Coalesce the x and y values from a data point
103
+ */
97
104
  function getPoint(datum) {
98
- const exists = val => val !== undefined;
99
105
  const {
100
106
  _x,
101
107
  _x1,
@@ -106,16 +112,20 @@ function getPoint(datum) {
106
112
  _y0,
107
113
  _voronoiY
108
114
  } = datum;
109
- const defaultX = exists(_x1) ? _x1 : _x;
110
- const defaultY = exists(_y1) ? _y1 : _y;
115
+ const defaultX = _x1 ?? _x;
116
+ const defaultY = _y1 ?? _y;
111
117
  const point = {
112
- x: exists(_voronoiX) ? _voronoiX : defaultX,
113
- x0: exists(_x0) ? _x0 : _x,
114
- y: exists(_voronoiY) ? _voronoiY : defaultY,
115
- y0: exists(_y0) ? _y0 : _y
118
+ x: _voronoiX ?? defaultX,
119
+ x0: _x0 ?? _x,
120
+ y: _voronoiY ?? defaultY,
121
+ y0: _y0 ?? _y
116
122
  };
117
- return (0, _defaults2.default)({}, point, datum);
123
+ return (0, _defaults.default)({}, point, datum);
118
124
  }
125
+
126
+ /**
127
+ * Scale a point based on the origin, direction, and given scale function
128
+ */
119
129
  function scalePoint(props, datum) {
120
130
  const {
121
131
  scale,
@@ -138,11 +148,11 @@ function scalePoint(props, datum) {
138
148
  y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
139
149
  };
140
150
  }
141
- function getPadding(props, name) {
142
- if (name === void 0) {
143
- name = "padding";
144
- }
145
- const padding = props[name];
151
+
152
+ /**
153
+ * Returns a padding value from a number or partial padding values
154
+ */
155
+ function getPadding(padding) {
146
156
  const paddingVal = typeof padding === "number" ? padding : 0;
147
157
  const paddingObj = typeof padding === "object" ? padding : {};
148
158
  return {
@@ -152,6 +162,10 @@ function getPadding(props, name) {
152
162
  right: paddingObj.right || paddingVal
153
163
  };
154
164
  }
165
+
166
+ /**
167
+ * Returns true if the component is defined as a tooltip
168
+ */
155
169
  function isTooltip(component) {
156
170
  const labelRole = component && component.type && component.type.role;
157
171
  return labelRole === "tooltip";
@@ -166,8 +180,8 @@ function getDefaultStyles(props, role) {
166
180
  return defaultStyles;
167
181
  }
168
182
  const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
169
- const labelStyle = (0, _defaults2.default)({}, tooltipStyle, defaultStyles.labels);
170
- return (0, _defaults2.default)({}, {
183
+ const labelStyle = (0, _defaults.default)({}, tooltipStyle, defaultStyles.labels);
184
+ return (0, _defaults.default)({}, {
171
185
  labels: labelStyle
172
186
  }, defaultStyles);
173
187
  }
@@ -175,7 +189,7 @@ function getStyles(style, defaultStyles) {
175
189
  const width = "100%";
176
190
  const height = "100%";
177
191
  if (!style) {
178
- return (0, _defaults2.default)({
192
+ return (0, _defaults.default)({
179
193
  parent: {
180
194
  height,
181
195
  width
@@ -191,14 +205,18 @@ function getStyles(style, defaultStyles) {
191
205
  const defaultLabels = defaultStyles && defaultStyles.labels || {};
192
206
  const defaultData = defaultStyles && defaultStyles.data || {};
193
207
  return {
194
- parent: (0, _defaults2.default)({}, parent, defaultParent, {
208
+ parent: (0, _defaults.default)({}, parent, defaultParent, {
195
209
  width,
196
210
  height
197
211
  }),
198
- labels: (0, _defaults2.default)({}, labels, defaultLabels),
199
- data: (0, _defaults2.default)({}, data, defaultData)
212
+ labels: (0, _defaults.default)({}, labels, defaultLabels),
213
+ data: (0, _defaults.default)({}, data, defaultData)
200
214
  };
201
215
  }
216
+
217
+ /**
218
+ * Returns the value of a prop or accessor function with the given props
219
+ */
202
220
  function evaluateProp(prop, props) {
203
221
  return isFunction(prop) ? prop(props) : prop;
204
222
  }
@@ -220,19 +238,28 @@ function degreesToRadians(degrees) {
220
238
  function radiansToDegrees(radians) {
221
239
  return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
222
240
  }
223
- function getRadius(props) {
241
+
242
+ /**
243
+ * Get the maximum radius that will fit in the container
244
+ */
245
+ function getRadius(options) {
246
+ const {
247
+ width,
248
+ height,
249
+ padding
250
+ } = options;
224
251
  const {
225
252
  left,
226
253
  right,
227
254
  top,
228
255
  bottom
229
- } = getPadding(props);
230
- const {
231
- width,
232
- height
233
- } = props;
256
+ } = padding;
234
257
  return Math.min(width - left - right, height - top - bottom) / 2;
235
258
  }
259
+
260
+ /**
261
+ * Returns the origin for a polar chart within the padded area
262
+ */
236
263
  function getPolarOrigin(props) {
237
264
  const {
238
265
  width,
@@ -243,7 +270,7 @@ function getPolarOrigin(props) {
243
270
  bottom,
244
271
  left,
245
272
  right
246
- } = getPadding(props);
273
+ } = getPadding(props.padding);
247
274
  const radius = Math.min(width - left - right, height - top - bottom) / 2;
248
275
  const offsetWidth = width / 2 + left - right;
249
276
  const offsetHeight = height / 2 + top - bottom;
@@ -252,13 +279,30 @@ function getPolarOrigin(props) {
252
279
  y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
253
280
  };
254
281
  }
282
+
283
+ /**
284
+ * Determine the range of an axis based on the given props
285
+ */
255
286
  function getRange(props, axis) {
256
287
  if (props.range && props.range[axis]) {
257
288
  return props.range[axis];
258
289
  } else if (props.range && Array.isArray(props.range)) {
259
290
  return props.range;
260
291
  }
261
- return props.polar ? getPolarRange(props, axis) : getCartesianRange(props, axis);
292
+ return props.polar ? getPolarRange({
293
+ axis,
294
+ innerRadius: props.innerRadius,
295
+ startAngle: props.startAngle,
296
+ endAngle: props.endAngle,
297
+ height: props.height,
298
+ width: props.width,
299
+ padding: getPadding(props.padding)
300
+ }) : getCartesianRange({
301
+ axis,
302
+ height: props.height,
303
+ width: props.width,
304
+ padding: getPadding(props.padding)
305
+ });
262
306
  }
263
307
 
264
308
  /**
@@ -290,7 +334,7 @@ function createAccessor(key) {
290
334
  return x => x;
291
335
  }
292
336
  // otherwise, assume it is an array index, property key or path (_.property handles all three)
293
- return (0, _property2.default)(key);
337
+ return (0, _property.default)(key);
294
338
  }
295
339
  function modifyProps(props, fallbackProps, role) {
296
340
  const theme = props.theme && props.theme[role] ? props.theme[role] : {};
@@ -299,7 +343,7 @@ function modifyProps(props, fallbackProps, role) {
299
343
  const defaultObject = horizontal === undefined ? {} : {
300
344
  horizontal
301
345
  };
302
- return (0, _defaults2.default)(defaultObject, props, themeProps, fallbackProps);
346
+ return (0, _defaults.default)(defaultObject, props, themeProps, fallbackProps);
303
347
  }
304
348
 
305
349
  /**
@@ -386,9 +430,9 @@ initialMemo, combine) {
386
430
  const childRole = child.type && child.type.role;
387
431
  const childName = child.props.name || `${childRole}-${names[index]}`;
388
432
  if (child.props && child.props.children) {
389
- const childProps = Object.assign({}, child.props, (0, _pick2.default)(parentProps, sharedProps));
433
+ const childProps = Object.assign({}, child.props, (0, _pick.default)(parentProps, sharedProps));
390
434
  const nestedChildren = child.type && child.type.role === "stack" && isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : _react.default.Children.toArray(child.props.children).map(c => {
391
- const nestedChildProps = Object.assign({}, c.props, (0, _pick2.default)(childProps, sharedProps));
435
+ const nestedChildProps = Object.assign({}, c.props, (0, _pick.default)(childProps, sharedProps));
392
436
  return /*#__PURE__*/_react.default.cloneElement(c, nestedChildProps);
393
437
  });
394
438
  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;
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useAnimationState = void 0;
7
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
8
7
  var _react = _interopRequireDefault(require("react"));
8
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
9
9
  var Collection = _interopRequireWildcard(require("../collection"));
10
10
  var Transitions = _interopRequireWildcard(require("../transitions"));
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -38,7 +38,7 @@ const useAnimationState = function (initialState) {
38
38
  const getFilteredState = () => {
39
39
  let childrenTransitions = state && state.childrenTransitions;
40
40
  childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
41
- return (0, _defaults2.default)({
41
+ return (0, _defaults.default)({
42
42
  childrenTransitions
43
43
  }, state);
44
44
  };
@@ -49,7 +49,7 @@ const useAnimationState = function (initialState) {
49
49
  const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
50
50
  getTransitions = childComponent => getTransitionProps(childComponent, index);
51
51
  }
52
- return (0, _defaults2.default)({
52
+ return (0, _defaults.default)({
53
53
  getTransitions,
54
54
  parentState
55
55
  }, props.animate, child.props.animate);
@@ -63,7 +63,7 @@ const useAnimationState = function (initialState) {
63
63
  if (props.animate.parentState) {
64
64
  const nodesWillExit = props.animate.parentState.nodesWillExit;
65
65
  const oldProps = nodesWillExit ? props : null;
66
- const newState = (0, _defaults2.default)({
66
+ const newState = (0, _defaults.default)({
67
67
  oldProps,
68
68
  nextProps
69
69
  }, 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;
@@ -9,13 +9,11 @@ exports.getPolarTextAnchor = getPolarTextAnchor;
9
9
  exports.getPolarVerticalAnchor = getPolarVerticalAnchor;
10
10
  exports.getProps = getProps;
11
11
  exports.getText = getText;
12
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
13
12
  var Helpers = _interopRequireWildcard(require("./helpers"));
13
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
- /* eslint-disable no-use-before-define */
18
-
19
17
  // Private Functions
20
18
 
21
19
  function getVerticalAnchor(props, datum) {
@@ -243,5 +241,5 @@ function getProps(props, index) {
243
241
  return labelProps;
244
242
  }
245
243
  const tooltipTheme = theme && theme.tooltip || {};
246
- return (0, _defaults2.default)({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
244
+ return (0, _defaults.default)({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
247
245
  }
@@ -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
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.warn = warn;
7
- /* global console */
7
+ /* global console process */
8
8
  /* eslint-disable no-console */
9
9
 
10
- // TODO: Use "warning" npm module like React is switching to.
11
10
  function warn(message) {
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore - Webpack DefinePlugin will replace process.env.NODE_ENV
12
13
  if (process.env.NODE_ENV !== "production") {
13
14
  if (console && console.warn) {
14
15
  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
  *
@@ -10,15 +10,13 @@ exports.getScaleFromProps = getScaleFromProps;
10
10
  exports.getScaleType = getScaleType;
11
11
  exports.getType = getType;
12
12
  exports.validScale = validScale;
13
- var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
13
+ var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
14
14
  var Helpers = _interopRequireWildcard(require("./helpers"));
15
15
  var Collection = _interopRequireWildcard(require("./collection"));
16
16
  var d3Scale = _interopRequireWildcard(require("victory-vendor/d3-scale"));
17
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- /* eslint-disable no-use-before-define */
21
-
22
20
  const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
23
21
  // Private Functions
24
22
 
@@ -68,7 +66,7 @@ function getScaleTypeFromData(props, axis) {
68
66
  }
69
67
  const accessor = Helpers.createAccessor(props[axis]);
70
68
  const axisData = props.data.map(datum => {
71
- const processedData = (0, _isPlainObject2.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
69
+ const processedData = (0, _isPlainObject.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
72
70
  return processedData !== undefined ? processedData : datum[axis];
73
71
  });
74
72
  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;
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.convertLengthToPixels = exports.approximateTextSize = exports._approximateTextSizeInternal = void 0;
7
- var _memoize2 = _interopRequireDefault(require("lodash/memoize"));
8
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
7
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
8
+ var _memoize = _interopRequireDefault(require("lodash/memoize"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  // http://www.pearsonified.com/2012/01/characters-per-line.php
11
11
  /* eslint-disable no-magic-numbers */
@@ -189,7 +189,7 @@ const convertLengthToPixels = (length, fontSize) => {
189
189
  exports.convertLengthToPixels = convertLengthToPixels;
190
190
  const _prepareParams = (inputStyle, index) => {
191
191
  const lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
192
- const style = (0, _defaults2.default)({}, lineStyle, defaultStyle);
192
+ const style = (0, _defaults.default)({}, lineStyle, defaultStyle);
193
193
  return Object.assign({}, style, {
194
194
  fontFamily: style.fontFamily,
195
195
  letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
@@ -237,7 +237,7 @@ const _approximateDimensionsInternal = (text, style) => {
237
237
  height: heightWithRotate * coefficients.heightOverlapCoef
238
238
  };
239
239
  };
240
- const _getMeasurementContainer = (0, _memoize2.default)(() => {
240
+ const _getMeasurementContainer = (0, _memoize.default)(() => {
241
241
  const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
242
242
  element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
243
243
  element.setAttribute("width", "300");
@@ -258,7 +258,7 @@ const styleToKeyComponent = style => {
258
258
  }
259
259
  return `${style.angle}:${style.fontFamily}:${style.fontSize}:${style.letterSpacing}:${style.lineHeight}`;
260
260
  };
261
- const _measureDimensionsInternal = (0, _memoize2.default)((text, style) => {
261
+ const _measureDimensionsInternal = (0, _memoize.default)((text, style) => {
262
262
  let containerElement = _getMeasurementContainer();
263
263
  if (!containerElement.isConnected) {
264
264
  _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;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getInitialTransitionState = getInitialTransitionState;
7
7
  exports.getTransitionPropsFactory = getTransitionPropsFactory;
8
- var _identity2 = _interopRequireDefault(require("lodash/identity"));
9
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
10
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _defaults = _interopRequireDefault(require("lodash/defaults"));
10
+ var _identity = _interopRequireDefault(require("lodash/identity"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  function getDatumKey(datum, idx) {
13
13
  return (datum.key || idx).toString();
@@ -116,7 +116,7 @@ function getInitialTransitionState(oldChildren, nextChildren) {
116
116
  };
117
117
  }
118
118
  function getInitialChildProps(animate, data) {
119
- const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity2.default;
119
+ const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : _identity.default;
120
120
  return {
121
121
  data: data.map((datum, idx) => Object.assign({}, datum, after(datum, idx, data)))
122
122
  };
@@ -133,7 +133,7 @@ function getChildBeforeLoad(animate, child, data, cb) {
133
133
  data
134
134
  };
135
135
  }
136
- const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity2.default;
136
+ const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity.default;
137
137
  // If nodes need to exit, transform them with the provided onLoad.before function.
138
138
  const newData = data.map((datum, idx) => {
139
139
  return Object.assign({}, datum, before(datum, idx, data));
@@ -144,8 +144,6 @@ function getChildBeforeLoad(animate, child, data, cb) {
144
144
  clipWidth: 0
145
145
  };
146
146
  }
147
-
148
- // eslint-disable-next-line max-params
149
147
  function getChildOnLoad(animate, data, cb) {
150
148
  const newAnimate = Object.assign({}, animate, {
151
149
  onEnd: cb
@@ -157,7 +155,7 @@ function getChildOnLoad(animate, data, cb) {
157
155
  data
158
156
  };
159
157
  }
160
- const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity2.default;
158
+ const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity.default;
161
159
  // If nodes need to exit, transform them with the provided onLoad.after function.
162
160
  newData = data.map((datum, idx) => {
163
161
  return Object.assign({}, datum, after(datum, idx, data));
@@ -168,7 +166,7 @@ function getChildOnLoad(animate, data, cb) {
168
166
  };
169
167
  }
170
168
 
171
- // eslint-disable-next-line max-params, max-len
169
+ // eslint-disable-next-line max-params
172
170
  function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
173
171
  // Whether or not _this_ child has exiting nodes, we want the exit-
174
172
  // transition for all children to have the same duration, delay, etc.
@@ -179,7 +177,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
179
177
  // After the exit transition occurs, trigger the animations for
180
178
  // nodes that are neither exiting nor entering.
181
179
  animate.onEnd = cb;
182
- const before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity2.default;
180
+ const before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity.default;
183
181
  // If nodes need to exit, transform them with the provided onExit.before function.
184
182
  newData = data.map((datum, idx) => {
185
183
  const key = (datum.key || idx).toString();
@@ -192,7 +190,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
192
190
  };
193
191
  }
194
192
 
195
- // eslint-disable-next-line max-params,max-len
193
+ // eslint-disable-next-line max-params
196
194
  function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
197
195
  let newAnimate = animate;
198
196
  let newData = data;
@@ -202,7 +200,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
202
200
  newAnimate = Object.assign({}, animate, {
203
201
  onEnd: cb
204
202
  });
205
- const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity2.default;
203
+ const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity.default;
206
204
  // We want the entering nodes to be included in the transition target
207
205
  // domain. However, we may not want these nodes to be displayed initially,
208
206
  // so perform the `onEnter.before` transformation on each node.
@@ -217,7 +215,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
217
215
  };
218
216
  }
219
217
 
220
- // eslint-disable-next-line max-params, max-len
218
+ // eslint-disable-next-line max-params
221
219
  function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
222
220
  // Whether or not _this_ child has entering nodes, we want the entering-
223
221
  // transition for all children to have the same duration, delay, etc.
@@ -229,7 +227,7 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
229
227
  // domain should encompass the nodes that will now enter. So perform
230
228
  // the `onEnter.after` transformation on each node.
231
229
  newAnimate.onEnd = cb;
232
- const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity2.default;
230
+ const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity.default;
233
231
  newData = data.map((datum, idx) => {
234
232
  const key = getDatumKey(datum, idx);
235
233
  return enteringNodes[key] ? Object.assign({}, datum, after(datum, idx, data)) : datum;
@@ -324,15 +322,13 @@ function getTransitionPropsFactory(props, state, setState) {
324
322
  }
325
323
  return {};
326
324
  };
327
-
328
- // eslint-disable-next-line max-statements, complexity, max-len
329
325
  return function getTransitionProps(child, index) {
330
326
  const data = getChildData(child) || [];
331
- const animate = (0, _defaults2.default)({}, props.animate, child.props.animate);
327
+ const animate = (0, _defaults.default)({}, props.animate, child.props.animate);
332
328
  const defaultTransitions = child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
333
- animate.onExit = (0, _defaults2.default)({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
334
- animate.onEnter = (0, _defaults2.default)({}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter);
335
- animate.onLoad = (0, _defaults2.default)({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
329
+ animate.onExit = (0, _defaults.default)({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
330
+ animate.onEnter = (0, _defaults.default)({}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter);
331
+ animate.onLoad = (0, _defaults.default)({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
336
332
  const childTransitions = childrenTransitions[index] || childrenTransitions[0];
337
333
  if (!nodesDoneLoad) {
338
334
  // should do onLoad animation
@@ -2,7 +2,6 @@ import { ForAxes, AxisType, Tuple, Datum, DatumValue } from "../types/prop-types
2
2
  export declare function hasValueForAxis<T = unknown>(value: unknown | ForAxes<T>, axis: AxisType): value is ForAxes<T>;
3
3
  export declare function isTuple<T = unknown>(value: unknown): value is Tuple<T>;
4
4
  export declare function getValueForAxis<T = unknown>(value: T | ForAxes<T> | undefined, axis: AxisType): T | undefined;
5
- export declare function isFunction<T = Function>(func?: unknown): func is T;
6
5
  export declare function isDate(value: unknown): value is Date;
7
6
  export declare function isKeyValueObject(datum: Datum): datum is {
8
7
  [key: string]: DatumValue;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getValueForAxis = getValueForAxis;
7
7
  exports.hasValueForAxis = hasValueForAxis;
8
8
  exports.isDate = isDate;
9
- exports.isFunction = isFunction;
10
9
  exports.isKeyValueObject = isKeyValueObject;
11
10
  exports.isTuple = isTuple;
12
11
  function hasValueForAxis(value, axis) {
@@ -24,11 +23,6 @@ function getValueForAxis(value, axis) {
24
23
  }
25
24
  return value;
26
25
  }
27
-
28
- // eslint-disable-next-line @typescript-eslint/ban-types
29
- function isFunction(func) {
30
- return typeof func === "function";
31
- }
32
26
  function isDate(value) {
33
27
  return value instanceof Date;
34
28
  }