victory-core 36.3.2 → 36.4.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 (95) hide show
  1. package/dist/victory-core.js +14175 -14191
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/victory-accessible-group/victory-accessible-group.js +38 -40
  4. package/es/victory-animation/util.js +1 -1
  5. package/es/victory-animation/victory-animation.js +46 -48
  6. package/es/victory-clip-container/victory-clip-container.js +71 -73
  7. package/es/victory-container/victory-container.js +82 -92
  8. package/es/victory-label/victory-label.js +29 -24
  9. package/es/victory-portal/portal-context.js +1 -1
  10. package/es/victory-portal/portal.js +28 -26
  11. package/es/victory-portal/victory-portal.js +31 -41
  12. package/es/victory-primitives/arc.js +6 -4
  13. package/es/victory-primitives/background.js +8 -6
  14. package/es/victory-primitives/border.js +6 -4
  15. package/es/victory-primitives/circle.js +8 -4
  16. package/es/victory-primitives/clip-path.js +1 -1
  17. package/es/victory-primitives/line-segment.js +6 -4
  18. package/es/victory-primitives/line.js +8 -4
  19. package/es/victory-primitives/path.js +7 -3
  20. package/es/victory-primitives/point.js +6 -4
  21. package/es/victory-primitives/rect.js +8 -4
  22. package/es/victory-primitives/text.js +7 -3
  23. package/es/victory-primitives/tspan.js +1 -1
  24. package/es/victory-primitives/whisker.js +9 -7
  25. package/es/victory-transition/victory-transition.js +30 -32
  26. package/es/victory-util/add-events.js +326 -317
  27. package/es/victory-util/axis.js +12 -5
  28. package/es/victory-util/collection.js +8 -4
  29. package/es/victory-util/data.js +9 -5
  30. package/es/victory-util/domain.js +8 -4
  31. package/es/victory-util/events.js +8 -4
  32. package/es/victory-util/helpers.js +1 -1
  33. package/es/victory-util/hooks/use-animation-state.js +11 -5
  34. package/es/victory-util/line-helpers.js +1 -1
  35. package/es/victory-util/scale.js +19 -19
  36. package/es/victory-util/textsize.js +11 -7
  37. package/es/victory-util/timer-context.js +1 -1
  38. package/es/victory-util/timer.js +3 -5
  39. package/es/victory-util/user-props.js +31 -4
  40. package/es/victory-util/wrapper.js +18 -12
  41. package/lib/index.js +68 -58
  42. package/lib/victory-accessible-group/victory-accessible-group.js +38 -40
  43. package/lib/victory-animation/util.js +2 -2
  44. package/lib/victory-animation/victory-animation.js +49 -49
  45. package/lib/victory-clip-container/victory-clip-container.js +74 -74
  46. package/lib/victory-container/victory-container.js +85 -93
  47. package/lib/victory-label/victory-label.js +35 -27
  48. package/lib/victory-portal/portal-context.js +1 -1
  49. package/lib/victory-portal/portal.js +31 -27
  50. package/lib/victory-portal/victory-portal.js +34 -42
  51. package/lib/victory-primitives/arc.js +9 -5
  52. package/lib/victory-primitives/background.js +11 -7
  53. package/lib/victory-primitives/border.js +9 -5
  54. package/lib/victory-primitives/circle.js +8 -4
  55. package/lib/victory-primitives/clip-path.js +1 -1
  56. package/lib/victory-primitives/line-segment.js +9 -5
  57. package/lib/victory-primitives/line.js +8 -4
  58. package/lib/victory-primitives/path.js +7 -3
  59. package/lib/victory-primitives/point.js +9 -5
  60. package/lib/victory-primitives/rect.js +8 -4
  61. package/lib/victory-primitives/text.js +7 -3
  62. package/lib/victory-primitives/tspan.js +1 -1
  63. package/lib/victory-primitives/whisker.js +12 -8
  64. package/lib/victory-transition/victory-transition.js +33 -33
  65. package/lib/victory-util/add-events.js +325 -313
  66. package/lib/victory-util/axis.js +20 -11
  67. package/lib/victory-util/collection.js +11 -7
  68. package/lib/victory-util/common-props.js +4 -2
  69. package/lib/victory-util/data.js +13 -7
  70. package/lib/victory-util/default-transitions.js +1 -1
  71. package/lib/victory-util/domain.js +11 -5
  72. package/lib/victory-util/events.js +17 -11
  73. package/lib/victory-util/helpers.js +14 -14
  74. package/lib/victory-util/hooks/index.js +4 -4
  75. package/lib/victory-util/hooks/use-animation-state.js +14 -6
  76. package/lib/victory-util/immutable.js +3 -3
  77. package/lib/victory-util/label-helpers.js +6 -4
  78. package/lib/victory-util/line-helpers.js +4 -2
  79. package/lib/victory-util/prop-types.js +5 -3
  80. package/lib/victory-util/scale.js +24 -21
  81. package/lib/victory-util/selection.js +6 -4
  82. package/lib/victory-util/textsize.js +12 -8
  83. package/lib/victory-util/timer-context.js +1 -1
  84. package/lib/victory-util/timer.js +3 -5
  85. package/lib/victory-util/user-props.js +31 -4
  86. package/lib/victory-util/wrapper.js +31 -23
  87. package/package.json +4 -11
  88. package/src/victory-animation/util.js +1 -1
  89. package/src/victory-animation/victory-animation.js +1 -1
  90. package/src/victory-label/victory-label.js +6 -6
  91. package/src/victory-util/axis.js +3 -0
  92. package/src/victory-util/line-helpers.js +1 -1
  93. package/src/victory-util/scale.js +18 -9
  94. package/src/victory-util/timer.js +1 -1
  95. package/src/victory-util/user-props.js +18 -1
@@ -11,13 +11,17 @@ import _identity from "lodash/identity";
11
11
  import _defaults from "lodash/defaults";
12
12
  import _assign from "lodash/assign";
13
13
 
14
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
14
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
15
 
16
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
16
+ 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."); }
17
17
 
18
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
18
+ 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); }
19
19
 
20
- 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; } }
20
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
+
22
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
+
24
+ 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; }
21
25
 
22
26
  /* eslint-disable func-style */
23
27
  import React from "react";
@@ -251,7 +255,10 @@ export function getTickFormat(props, scale) {
251
255
  var stringMap = props.stringMap && props.stringMap[axis];
252
256
 
253
257
  if (!tickFormat) {
254
- var defaultTickFormat = getDefaultTickFormat(props);
258
+ var defaultTickFormat = getDefaultTickFormat(props); // If there is no user-provided tick format, we use d3's tickFormat function
259
+ // by default. This changed the default formatting for some scale types when
260
+ // we upgraded to d3-scale@4..
261
+
255
262
  var scaleTickFormat = scale.tickFormat && _isFunction(scale.tickFormat) ? scale.tickFormat() : function (x) {
256
263
  return x;
257
264
  };
@@ -1,10 +1,14 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
2
 
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
3
+ 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."); }
4
4
 
5
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
5
+ 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); }
6
6
 
7
- 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; } }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ 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; }
8
12
 
9
13
  /* eslint-disable func-style */
10
14
 
@@ -12,13 +12,17 @@ import _range from "lodash/range";
12
12
  import _uniq from "lodash/uniq";
13
13
  import _assign from "lodash/assign";
14
14
 
15
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
15
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
16
 
17
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
17
+ 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."); }
18
18
 
19
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
19
+ 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); }
20
20
 
21
- 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; } }
21
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
22
+
23
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
+
25
+ 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; }
22
26
 
23
27
  /* eslint-disable func-style */
24
28
 
@@ -212,7 +216,7 @@ export function createStringMap(props, axis) {
212
216
  var stringsFromCategories = getStringsFromCategories(props, axis);
213
217
  var stringsFromData = getStringsFromData(props, axis);
214
218
 
215
- var allStrings = _uniq(_toConsumableArray(stringsFromAxes).concat(_toConsumableArray(stringsFromCategories), _toConsumableArray(stringsFromData)));
219
+ var allStrings = _uniq([].concat(_toConsumableArray(stringsFromAxes), _toConsumableArray(stringsFromCategories), _toConsumableArray(stringsFromData)));
216
220
 
217
221
  return allStrings.length === 0 ? null : allStrings.reduce(function (memo, string, index) {
218
222
  memo[string] = index + 1;
@@ -5,13 +5,17 @@ import _sortedUniq from "lodash/sortedUniq";
5
5
  import _isPlainObject from "lodash/isPlainObject";
6
6
  import _flatten from "lodash/flatten";
7
7
 
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
9
 
10
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
10
+ 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."); }
11
11
 
12
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
12
+ 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); }
13
13
 
14
- 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; } }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+
18
+ 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; }
15
19
 
16
20
  /* eslint-disable func-style */
17
21
 
@@ -10,13 +10,17 @@ import _assign from "lodash/assign";
10
10
 
11
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
12
 
13
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
13
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
14
 
15
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
15
+ 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."); }
16
16
 
17
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
17
+ 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); }
18
18
 
19
- 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; } }
19
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
20
+
21
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
+
23
+ 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; }
20
24
 
21
25
  var GLOBAL_EVENT_REGEX = /^onGlobal(.*)$/;
22
26
  /* Returns all own and shared events that should be attached to a single target element,
@@ -295,7 +295,7 @@ export function reduceChildren(children, iteratee) {
295
295
  var nestedChildren = child.type && child.type.role === "stack" && _isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : React.Children.toArray(child.props.children).map(function (c) {
296
296
  var nestedChildProps = _assign({}, c.props, _pick(childProps, sharedProps));
297
297
 
298
- return React.cloneElement(c, nestedChildProps);
298
+ return /*#__PURE__*/React.cloneElement(c, nestedChildProps);
299
299
  });
300
300
 
301
301
  var _childNames = nestedChildren.map(function (c, i) {
@@ -1,15 +1,21 @@
1
1
  import _some from "lodash/some";
2
2
  import _defaults from "lodash/defaults";
3
3
 
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
7
 
6
8
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
9
 
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+
14
+ 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); }
9
15
 
10
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
16
+ 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; }
11
17
 
12
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
13
19
 
14
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
21
 
@@ -32,7 +38,7 @@ export var useAnimationState = function () {
32
38
 
33
39
  var setState = React.useCallback(function (newState) {
34
40
  _setState(function (oldState) {
35
- return _objectSpread({}, oldState, newState);
41
+ return _objectSpread(_objectSpread({}, oldState), newState);
36
42
  });
37
43
  }, [_setState]); // This is a copy of Wrapper.getAnimationProps
38
44
 
@@ -1,4 +1,4 @@
1
- import * as d3Shape from "d3-shape";
1
+ import * as d3Shape from "victory-vendor/d3-shape";
2
2
 
3
3
  var defined = function (d) {
4
4
  var y = d._y1 !== undefined ? d._y1 : d._y;
@@ -3,7 +3,7 @@ import _isFunction from "lodash/isFunction";
3
3
  import _includes from "lodash/includes";
4
4
  import * as Helpers from "./helpers";
5
5
  import * as Collection from "./collection";
6
- import * as d3Scale from "d3-scale";
6
+ import * as d3Scale from "victory-vendor/d3-scale";
7
7
  var supportedScaleStrings = ["linear", "time", "log", "sqrt"]; // Private Functions
8
8
 
9
9
  function toNewName(scale) {
@@ -106,29 +106,29 @@ export function getScaleFromProps(props, axis) {
106
106
  export function getScaleType(props, axis) {
107
107
  // if the scale was not given in props, it will be set to linear or time depending on data
108
108
  return getScaleTypeFromProps(props, axis) || getScaleTypeFromData(props, axis);
109
- }
109
+ } // Ordered type inference off of function fields.
110
+ // **Note**: Brittle because reliant on d3 internals.
111
+
112
+ var DUCK_TYPES = [{
113
+ name: "quantile",
114
+ method: "quantiles"
115
+ }, {
116
+ name: "log",
117
+ method: "base"
118
+ } // TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
119
+ // do we need a different approach? (Multiple keys? Stringifying functions?)
120
+ // https://github.com/FormidableLabs/victory/issues/2214
121
+ // Below are matches that don't seem to otherwise occur in Victory code base.
122
+ // { name: "ordinal", method: "unknown" },
123
+ // { name: "pow-sqrt", method: "exponent" },
124
+ // { name: "quantize-threshold", method: "invertExtent" }
125
+ ];
110
126
  export function getType(scale) {
111
127
  if (typeof scale === "string") {
112
128
  return scale;
113
129
  }
114
130
 
115
- var duckTypes = [{
116
- name: "log",
117
- method: "base"
118
- }, {
119
- name: "ordinal",
120
- method: "unknown"
121
- }, {
122
- name: "pow-sqrt",
123
- method: "exponent"
124
- }, {
125
- name: "quantile",
126
- method: "quantiles"
127
- }, {
128
- name: "quantize-threshold",
129
- method: "invertExtent"
130
- }];
131
- var scaleType = duckTypes.filter(function (type) {
131
+ var scaleType = DUCK_TYPES.filter(function (type) {
132
132
  return scale[type.method] !== undefined;
133
133
  })[0];
134
134
  return scaleType ? scaleType.name : undefined;
@@ -1,13 +1,17 @@
1
1
  import _defaults from "lodash/defaults";
2
2
  import _assign from "lodash/assign";
3
3
 
4
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
6
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
6
+ 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."); }
7
7
 
8
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
8
+ 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); }
9
9
 
10
- 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; } }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+
14
+ 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; }
11
15
 
12
16
  // Based on measuring specific character widths
13
17
  // as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
@@ -116,10 +120,10 @@ var fonts = {
116
120
  Verdana: {
117
121
  widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875],
118
122
  avg: 0.6171875000000003
119
- } //https://developer.mozilla.org/en/docs/Web/CSS/length
120
- // Absolute sizes in pixels for obsolete measurement units.
123
+ }
124
+ }; //https://developer.mozilla.org/en/docs/Web/CSS/length
125
+ // Absolute sizes in pixels for obsolete measurement units.
121
126
 
122
- };
123
127
  var absoluteMeasurementUnitsToPixels = {
124
128
  mm: 3.8,
125
129
  sm: 38,
@@ -5,7 +5,7 @@ import Timer from "./timer";
5
5
  * timer.
6
6
  */
7
7
 
8
- var TimerContext = React.createContext({
8
+ var TimerContext = /*#__PURE__*/React.createContext({
9
9
  transitionTimer: new Timer(),
10
10
  animationTimer: new Timer()
11
11
  });
@@ -2,13 +2,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
2
2
 
3
3
  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); } }
4
4
 
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
6
 
7
- import { timer, now } from "d3-timer";
7
+ import { timer, now } from "victory-vendor/d3-timer";
8
8
 
9
- var Timer =
10
- /*#__PURE__*/
11
- function () {
9
+ var Timer = /*#__PURE__*/function () {
12
10
  function Timer() {
13
11
  _classCallCheck(this, Timer);
14
12
 
@@ -1,12 +1,18 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
2
 
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
 
5
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
5
+ 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); }
6
+
7
+ 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; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
6
10
 
7
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
12
 
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
16
 
11
17
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
18
 
@@ -61,6 +67,21 @@ var testIfSafeProp = function (key) {
61
67
  if (doesPropStartWith(key) || isExactMatch(key)) return true;
62
68
  return false;
63
69
  };
70
+ /**
71
+ * Gets the value from props if a function value is provided
72
+ * @param {any} value: maybe function value
73
+ * @param {Object} props: props object
74
+ * @returns {any} newValue
75
+ */
76
+
77
+
78
+ var getValue = function (value, props) {
79
+ if (typeof value === "function") {
80
+ return value(props);
81
+ }
82
+
83
+ return value;
84
+ };
64
85
  /**
65
86
  * getSafeUserProps - function that takes in a props object and removes any
66
87
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -79,5 +100,11 @@ export var getSafeUserProps = function (props) {
79
100
  key = _ref2[0];
80
101
 
81
102
  return testIfSafeProp(key);
103
+ }).map(function (_ref3) {
104
+ var _ref4 = _slicedToArray(_ref3, 2),
105
+ key = _ref4[0],
106
+ value = _ref4[1];
107
+
108
+ return [key, getValue(value, props)];
82
109
  }));
83
110
  };
@@ -8,15 +8,21 @@ import _flatten from "lodash/flatten";
8
8
  import _defaults from "lodash/defaults";
9
9
  import _assign from "lodash/assign";
10
10
 
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
12
 
13
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
13
+ 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."); }
14
14
 
15
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
15
+ 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); }
16
16
 
17
- 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; } }
17
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
18
 
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
19
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
+
21
+ 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; }
22
+
23
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
+
25
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
26
 
21
27
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
28
 
@@ -76,7 +82,7 @@ export function addBinsToParentPropsIfHistogram(_ref) {
76
82
  }, []);
77
83
  }
78
84
 
79
- return _objectSpread({}, parentProps, {
85
+ return _objectSpread(_objectSpread({}, parentProps), {}, {
80
86
  bins: childBins
81
87
  });
82
88
  }
@@ -112,7 +118,7 @@ export function getDataFromChildren(props, childComponents) {
112
118
  if (!Data.isDataComponent(child)) {
113
119
  return null;
114
120
  } else if (child.type && _isFunction(child.type.getData)) {
115
- child = parent ? React.cloneElement(child, parent.props) : child;
121
+ child = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child;
116
122
  childData = child.type.getData(childProps);
117
123
  } else {
118
124
  childData = Data.getData(childProps);
@@ -259,8 +265,8 @@ export function getDomain(props, axis, childComponents) {
259
265
  var dataset = (props.data || props.y) && Data.getData(props);
260
266
  var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
261
267
  var childDomain = getDomainFromChildren(props, axis, childComponents);
262
- var min = minDomain || Collection.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
263
- var max = maxDomain || Collection.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
268
+ var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
269
+ var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
264
270
  domain = Domain.getDomainFromMinMax(min, max);
265
271
  }
266
272
 
@@ -417,7 +423,7 @@ export function getCategoryAndAxisStringsFromChildren(props, axis, childComponen
417
423
  var axisComponent = Axis.getAxisComponent(childComponents, axis);
418
424
  var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
419
425
  var categoryStrings = categories || getStringsFromCategories(childComponents, axis);
420
- return _uniq(_flatten(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));
426
+ return _uniq(_flatten([].concat(_toConsumableArray(categoryStrings), _toConsumableArray(axisStrings))));
421
427
  }
422
428
  export function getStringsFromChildren(props, childComponents) {
423
429
  childComponents = childComponents || React.Children.toArray(props.children);
@@ -425,8 +431,8 @@ export function getStringsFromChildren(props, childComponents) {
425
431
  var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
426
432
  var dataStrings = getStringsFromData(childComponents);
427
433
  return {
428
- x: _uniq(_flatten(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
429
- y: _uniq(_flatten(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
434
+ x: _uniq(_flatten([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))),
435
+ y: _uniq(_flatten([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y))))
430
436
  };
431
437
  }
432
438
  export function getCategories(props, childComponents, allStrings) {