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
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.approximateTextSize = exports._approximateTextSizeInternal = exports.convertLengthToPixels = void 0;
6
+ exports.convertLengthToPixels = exports.approximateTextSize = exports._approximateTextSizeInternal = void 0;
7
7
 
8
8
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
9
9
 
@@ -11,13 +11,17 @@ var _assign2 = _interopRequireDefault(require("lodash/assign"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
  // Based on measuring specific character widths
23
27
  // as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
@@ -126,10 +130,10 @@ var fonts = {
126
130
  Verdana: {
127
131
  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],
128
132
  avg: 0.6171875000000003
129
- } //https://developer.mozilla.org/en/docs/Web/CSS/length
130
- // Absolute sizes in pixels for obsolete measurement units.
133
+ }
134
+ }; //https://developer.mozilla.org/en/docs/Web/CSS/length
135
+ // Absolute sizes in pixels for obsolete measurement units.
131
136
 
132
- };
133
137
  var absoluteMeasurementUnitsToPixels = {
134
138
  mm: 3.8,
135
139
  sm: 38,
@@ -15,7 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
  * The React context object consumers may use to access or override the global
16
16
  * timer.
17
17
  */
18
- var TimerContext = _react.default.createContext({
18
+ var TimerContext = /*#__PURE__*/_react.default.createContext({
19
19
  transitionTimer: new _timer.default(),
20
20
  animationTimer: new _timer.default()
21
21
  });
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _d3Timer = require("d3-timer");
8
+ var _d3Timer = require("victory-vendor/d3-timer");
9
9
 
10
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
11
 
12
12
  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); } }
13
13
 
14
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
15
 
16
- var Timer =
17
- /*#__PURE__*/
18
- function () {
16
+ var Timer = /*#__PURE__*/function () {
19
17
  function Timer() {
20
18
  _classCallCheck(this, Timer);
21
19
 
@@ -5,15 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getSafeUserProps = void 0;
7
7
 
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
9
 
10
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
10
+ 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."); }
11
11
 
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; }
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
+
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; }
15
+
16
+ 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
17
 
14
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
19
 
16
- 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; }
20
+ 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; }
21
+
22
+ 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; }
17
23
 
18
24
  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; }
19
25
 
@@ -68,6 +74,21 @@ var testIfSafeProp = function (key) {
68
74
  if (doesPropStartWith(key) || isExactMatch(key)) return true;
69
75
  return false;
70
76
  };
77
+ /**
78
+ * Gets the value from props if a function value is provided
79
+ * @param {any} value: maybe function value
80
+ * @param {Object} props: props object
81
+ * @returns {any} newValue
82
+ */
83
+
84
+
85
+ var getValue = function (value, props) {
86
+ if (typeof value === "function") {
87
+ return value(props);
88
+ }
89
+
90
+ return value;
91
+ };
71
92
  /**
72
93
  * getSafeUserProps - function that takes in a props object and removes any
73
94
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -86,6 +107,12 @@ var getSafeUserProps = function (props) {
86
107
  key = _ref2[0];
87
108
 
88
109
  return testIfSafeProp(key);
110
+ }).map(function (_ref3) {
111
+ var _ref4 = _slicedToArray(_ref3, 2),
112
+ key = _ref4[0],
113
+ value = _ref4[1];
114
+
115
+ return [key, getValue(value, props)];
89
116
  }));
90
117
  };
91
118
 
@@ -4,22 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addBinsToParentPropsIfHistogram = addBinsToParentPropsIfHistogram;
7
- exports.getDataFromChildren = getDataFromChildren;
7
+ exports.getAllEvents = getAllEvents;
8
+ exports.getCategories = getCategories;
9
+ exports.getCategoryAndAxisStringsFromChildren = getCategoryAndAxisStringsFromChildren;
10
+ exports.getChildStyle = getChildStyle;
11
+ exports.getColor = getColor;
8
12
  exports.getData = getData;
9
- exports.getWidth = getWidth;
13
+ exports.getDataFromChildren = getDataFromChildren;
10
14
  exports.getDefaultDomainPadding = getDefaultDomainPadding;
11
- exports.getDomainFromChildren = getDomainFromChildren;
12
15
  exports.getDomain = getDomain;
16
+ exports.getDomainFromChildren = getDomainFromChildren;
13
17
  exports.getScale = getScale;
14
- exports.getAllEvents = getAllEvents;
15
- exports.getColor = getColor;
16
- exports.getStyle = getStyle;
17
- exports.getChildStyle = getChildStyle;
18
18
  exports.getStringsFromCategories = getStringsFromCategories;
19
- exports.getStringsFromData = getStringsFromData;
20
- exports.getCategoryAndAxisStringsFromChildren = getCategoryAndAxisStringsFromChildren;
21
19
  exports.getStringsFromChildren = getStringsFromChildren;
22
- exports.getCategories = getCategories;
20
+ exports.getStringsFromData = getStringsFromData;
21
+ exports.getStyle = getStyle;
22
+ exports.getWidth = getWidth;
23
23
 
24
24
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
25
25
 
@@ -59,19 +59,27 @@ var Scale = _interopRequireWildcard(require("./scale"));
59
59
 
60
60
  var Log = _interopRequireWildcard(require("./log"));
61
61
 
62
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
62
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
63
+
64
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
63
65
 
64
66
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65
67
 
66
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
68
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
69
+
70
+ 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."); }
71
+
72
+ 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); }
73
+
74
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
67
75
 
68
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
76
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
69
77
 
70
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
78
+ 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; }
71
79
 
72
- 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; } }
80
+ 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; }
73
81
 
74
- 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; }
82
+ 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; }
75
83
 
76
84
  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; }
77
85
 
@@ -121,7 +129,7 @@ function addBinsToParentPropsIfHistogram(_ref) {
121
129
  }, []);
122
130
  }
123
131
 
124
- return _objectSpread({}, parentProps, {
132
+ return _objectSpread(_objectSpread({}, parentProps), {}, {
125
133
  bins: childBins
126
134
  });
127
135
  }
@@ -157,7 +165,7 @@ function getDataFromChildren(props, childComponents) {
157
165
  if (!Data.isDataComponent(child)) {
158
166
  return null;
159
167
  } else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
160
- child = parent ? _react.default.cloneElement(child, parent.props) : child;
168
+ child = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child;
161
169
  childData = child.type.getData(childProps);
162
170
  } else {
163
171
  childData = Data.getData(childProps);
@@ -309,8 +317,8 @@ function getDomain(props, axis, childComponents) {
309
317
  var dataset = (props.data || props.y) && Data.getData(props);
310
318
  var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
311
319
  var childDomain = getDomainFromChildren(props, axis, childComponents);
312
- var min = minDomain || Collection.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
313
- var max = maxDomain || Collection.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
320
+ var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
321
+ var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
314
322
  domain = Domain.getDomainFromMinMax(min, max);
315
323
  }
316
324
 
@@ -470,7 +478,7 @@ function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
470
478
  var axisComponent = Axis.getAxisComponent(childComponents, axis);
471
479
  var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
472
480
  var categoryStrings = categories || getStringsFromCategories(childComponents, axis);
473
- return (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));
481
+ return (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(categoryStrings), _toConsumableArray(axisStrings))));
474
482
  }
475
483
 
476
484
  function getStringsFromChildren(props, childComponents) {
@@ -479,8 +487,8 @@ function getStringsFromChildren(props, childComponents) {
479
487
  var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
480
488
  var dataStrings = getStringsFromData(childComponents);
481
489
  return {
482
- x: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
483
- y: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
490
+ x: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))),
491
+ y: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y))))
484
492
  };
485
493
  }
486
494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-core",
3
- "version": "36.3.2",
3
+ "version": "36.4.0",
4
4
  "description": "Victory Core",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -19,17 +19,10 @@
19
19
  "author": "Formidable",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "d3-ease": "^1.0.0",
23
- "d3-interpolate": "^1.1.1",
24
- "d3-scale": "^1.0.0",
25
- "d3-shape": "^1.2.0",
26
- "d3-timer": "^1.0.0",
27
22
  "lodash": "^4.17.21",
28
23
  "prop-types": "^15.5.8",
29
- "react-fast-compare": "^2.0.0"
30
- },
31
- "resolutions": {
32
- "d3-interpolate/d3-color": "^3.0.0"
24
+ "react-fast-compare": "^2.0.0",
25
+ "victory-vendor": "^36.4.0"
33
26
  },
34
27
  "peerDependencies": {
35
28
  "react": "^16.6.0 || ^17.0.0"
@@ -38,5 +31,5 @@
38
31
  "version": "yarn run nps build-libs && nps build-dists"
39
32
  },
40
33
  "sideEffects": false,
41
- "gitHead": "18895d1290245732d14332bbbda10336032c9aab"
34
+ "gitHead": "2e05481eeb34f9801a90023a131a21aa7deff082"
42
35
  }
@@ -1,4 +1,4 @@
1
- import { interpolate } from "d3-interpolate";
1
+ import { interpolate } from "victory-vendor/d3-interpolate";
2
2
  import { isPlainObject, orderBy } from "lodash";
3
3
 
4
4
  export const isInterpolatable = function (obj) {
@@ -1,7 +1,7 @@
1
1
  /*global setTimeout:false */
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import * as d3Ease from "d3-ease";
4
+ import * as d3Ease from "victory-vendor/d3-ease";
5
5
  import { victoryInterpolator } from "./util";
6
6
  import TimerContext from "../victory-util/timer-context";
7
7
  import isEqual from "react-fast-compare";
@@ -1,17 +1,17 @@
1
1
  /*eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
2
- import React from "react";
2
+ import { assign, defaults, isEmpty } from "lodash";
3
3
  import PropTypes from "prop-types";
4
+ import React from "react";
4
5
  import VictoryPortal from "../victory-portal/victory-portal";
5
6
  import Rect from "../victory-primitives/rect";
6
- import * as CustomPropTypes from "../victory-util/prop-types";
7
+ import Text from "../victory-primitives/text";
8
+ import TSpan from "../victory-primitives/tspan";
7
9
  import * as Helpers from "../victory-util/helpers";
8
10
  import * as LabelHelpers from "../victory-util/label-helpers";
9
- import * as Style from "../victory-util/style";
10
11
  import * as Log from "../victory-util/log";
12
+ import * as CustomPropTypes from "../victory-util/prop-types";
13
+ import * as Style from "../victory-util/style";
11
14
  import * as TextSize from "../victory-util/textsize";
12
- import TSpan from "../victory-primitives/tspan";
13
- import Text from "../victory-primitives/text";
14
- import { assign, defaults, isEmpty } from "lodash";
15
15
 
16
16
  const defaultStyles = {
17
17
  fill: "#252525",
@@ -239,6 +239,9 @@ export function getTickFormat(props, scale) {
239
239
  const stringMap = props.stringMap && props.stringMap[axis];
240
240
  if (!tickFormat) {
241
241
  const defaultTickFormat = getDefaultTickFormat(props);
242
+ // If there is no user-provided tick format, we use d3's tickFormat function
243
+ // by default. This changed the default formatting for some scale types when
244
+ // we upgraded to d3-scale@4..
242
245
  const scaleTickFormat =
243
246
  scale.tickFormat && isFunction(scale.tickFormat)
244
247
  ? scale.tickFormat()
@@ -1,4 +1,4 @@
1
- import * as d3Shape from "d3-shape";
1
+ import * as d3Shape from "victory-vendor/d3-shape";
2
2
 
3
3
  const defined = (d) => {
4
4
  const y = d._y1 !== undefined ? d._y1 : d._y;
@@ -3,7 +3,7 @@
3
3
  import { includes, isFunction, isPlainObject } from "lodash";
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
 
8
8
  const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
9
9
 
@@ -110,19 +110,28 @@ export function getScaleType(props, axis) {
110
110
  );
111
111
  }
112
112
 
113
+ // Ordered type inference off of function fields.
114
+ // **Note**: Brittle because reliant on d3 internals.
115
+ const DUCK_TYPES = [
116
+ { name: "quantile", method: "quantiles" },
117
+ { name: "log", 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
+ ];
126
+
113
127
  export function getType(scale) {
114
128
  if (typeof scale === "string") {
115
129
  return scale;
116
130
  }
117
- const duckTypes = [
118
- { name: "log", method: "base" },
119
- { name: "ordinal", method: "unknown" },
120
- { name: "pow-sqrt", method: "exponent" },
121
- { name: "quantile", method: "quantiles" },
122
- { name: "quantize-threshold", method: "invertExtent" }
123
- ];
124
- const scaleType = duckTypes.filter((type) => {
131
+
132
+ const scaleType = DUCK_TYPES.filter((type) => {
125
133
  return scale[type.method] !== undefined;
126
134
  })[0];
135
+
127
136
  return scaleType ? scaleType.name : undefined;
128
137
  }
@@ -1,4 +1,4 @@
1
- import { timer, now } from "d3-timer";
1
+ import { timer, now } from "victory-vendor/d3-timer";
2
2
 
3
3
  export default class Timer {
4
4
  constructor() {
@@ -48,6 +48,19 @@ const testIfSafeProp = (key) => {
48
48
  return false;
49
49
  };
50
50
 
51
+ /**
52
+ * Gets the value from props if a function value is provided
53
+ * @param {any} value: maybe function value
54
+ * @param {Object} props: props object
55
+ * @returns {any} newValue
56
+ */
57
+ const getValue = (value, props) => {
58
+ if (typeof value === "function") {
59
+ return value(props);
60
+ }
61
+ return value;
62
+ };
63
+
51
64
  /**
52
65
  * getSafeUserProps - function that takes in a props object and removes any
53
66
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -59,6 +72,10 @@ const testIfSafeProp = (key) => {
59
72
  export const getSafeUserProps = (props) => {
60
73
  const propsToFilter = { ...props };
61
74
  return Object.fromEntries(
62
- Object.entries(propsToFilter).filter(([key]) => testIfSafeProp(key))
75
+ Object.entries(propsToFilter)
76
+ .filter(([key]) => testIfSafeProp(key))
77
+ .map(([key, value]) => {
78
+ return [key, getValue(value, props)];
79
+ })
63
80
  );
64
81
  };