victory-core 36.9.2 → 37.0.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 (110) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/victory-core.js +4371 -5749
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-accessible-group/victory-accessible-group.js +9 -15
  5. package/es/victory-animation/util.js +28 -47
  6. package/es/victory-animation/victory-animation.js +51 -67
  7. package/es/victory-clip-container/victory-clip-container.js +153 -229
  8. package/es/victory-container/victory-container.js +157 -216
  9. package/es/victory-label/victory-label.js +246 -323
  10. package/es/victory-portal/portal-context.js +1 -2
  11. package/es/victory-portal/portal.js +30 -76
  12. package/es/victory-portal/victory-portal.js +47 -104
  13. package/es/victory-primitives/arc.js +44 -47
  14. package/es/victory-primitives/background.js +14 -17
  15. package/es/victory-primitives/border.js +20 -24
  16. package/es/victory-primitives/circle.js +13 -27
  17. package/es/victory-primitives/clip-path.js +3 -7
  18. package/es/victory-primitives/line-segment.js +20 -24
  19. package/es/victory-primitives/line.js +13 -27
  20. package/es/victory-primitives/path.js +13 -27
  21. package/es/victory-primitives/point.js +36 -40
  22. package/es/victory-primitives/rect.js +13 -27
  23. package/es/victory-primitives/text.js +15 -28
  24. package/es/victory-primitives/tspan.js +13 -26
  25. package/es/victory-primitives/whisker.js +43 -47
  26. package/es/victory-theme/grayscale.js +22 -22
  27. package/es/victory-theme/material.js +46 -46
  28. package/es/victory-theme/victory-theme.js +3 -3
  29. package/es/victory-transition/victory-transition.js +126 -206
  30. package/es/victory-util/add-events.js +263 -374
  31. package/es/victory-util/axis.js +126 -222
  32. package/es/victory-util/collection.js +13 -41
  33. package/es/victory-util/data.js +159 -214
  34. package/es/victory-util/default-transitions.js +33 -51
  35. package/es/victory-util/domain.js +122 -171
  36. package/es/victory-util/events.js +168 -258
  37. package/es/victory-util/helpers.js +153 -178
  38. package/es/victory-util/hooks/use-animation-state.js +61 -99
  39. package/es/victory-util/hooks/use-previous-props.js +2 -2
  40. package/es/victory-util/immutable.js +6 -8
  41. package/es/victory-util/label-helpers.js +128 -130
  42. package/es/victory-util/line-helpers.js +29 -41
  43. package/es/victory-util/log.js +1 -1
  44. package/es/victory-util/point-path-helpers.js +89 -49
  45. package/es/victory-util/scale.js +24 -42
  46. package/es/victory-util/selection.js +39 -40
  47. package/es/victory-util/style.js +8 -13
  48. package/es/victory-util/textsize.js +80 -154
  49. package/es/victory-util/timer-context.js +2 -2
  50. package/es/victory-util/timer.js +40 -76
  51. package/es/victory-util/transitions.js +110 -150
  52. package/es/victory-util/type-helpers.js +2 -3
  53. package/es/victory-util/user-props.js +24 -49
  54. package/es/victory-util/wrapper.js +184 -247
  55. package/lib/index.js +0 -30
  56. package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
  57. package/lib/victory-animation/util.js +28 -63
  58. package/lib/victory-animation/victory-animation.js +54 -83
  59. package/lib/victory-clip-container/victory-clip-container.js +156 -243
  60. package/lib/victory-container/victory-container.js +160 -232
  61. package/lib/victory-label/victory-label.js +248 -344
  62. package/lib/victory-portal/portal-context.js +1 -6
  63. package/lib/victory-portal/portal.js +31 -81
  64. package/lib/victory-portal/victory-portal.js +50 -116
  65. package/lib/victory-primitives/arc.js +48 -57
  66. package/lib/victory-primitives/background.js +16 -28
  67. package/lib/victory-primitives/border.js +22 -34
  68. package/lib/victory-primitives/circle.js +16 -36
  69. package/lib/victory-primitives/clip-path.js +3 -11
  70. package/lib/victory-primitives/index.js +0 -28
  71. package/lib/victory-primitives/line-segment.js +22 -34
  72. package/lib/victory-primitives/line.js +16 -36
  73. package/lib/victory-primitives/path.js +16 -36
  74. package/lib/victory-primitives/point.js +38 -52
  75. package/lib/victory-primitives/rect.js +16 -36
  76. package/lib/victory-primitives/text.js +15 -33
  77. package/lib/victory-primitives/tspan.js +13 -31
  78. package/lib/victory-primitives/whisker.js +45 -57
  79. package/lib/victory-theme/grayscale.js +23 -24
  80. package/lib/victory-theme/material.js +47 -48
  81. package/lib/victory-theme/victory-theme.js +2 -7
  82. package/lib/victory-transition/victory-transition.js +129 -224
  83. package/lib/victory-util/add-events.js +263 -380
  84. package/lib/victory-util/axis.js +128 -241
  85. package/lib/victory-util/collection.js +13 -50
  86. package/lib/victory-util/data.js +160 -239
  87. package/lib/victory-util/default-transitions.js +33 -54
  88. package/lib/victory-util/domain.js +123 -193
  89. package/lib/victory-util/events.js +167 -274
  90. package/lib/victory-util/helpers.js +156 -207
  91. package/lib/victory-util/hooks/index.js +0 -2
  92. package/lib/victory-util/hooks/use-animation-state.js +63 -113
  93. package/lib/victory-util/hooks/use-previous-props.js +2 -7
  94. package/lib/victory-util/immutable.js +6 -18
  95. package/lib/victory-util/index.js +2 -51
  96. package/lib/victory-util/label-helpers.js +130 -141
  97. package/lib/victory-util/line-helpers.js +31 -49
  98. package/lib/victory-util/log.js +1 -2
  99. package/lib/victory-util/point-path-helpers.js +91 -63
  100. package/lib/victory-util/scale.js +26 -57
  101. package/lib/victory-util/selection.js +41 -49
  102. package/lib/victory-util/style.js +8 -16
  103. package/lib/victory-util/textsize.js +80 -157
  104. package/lib/victory-util/timer-context.js +2 -8
  105. package/lib/victory-util/timer.js +40 -76
  106. package/lib/victory-util/transitions.js +110 -152
  107. package/lib/victory-util/type-helpers.js +2 -9
  108. package/lib/victory-util/user-props.js +25 -59
  109. package/lib/victory-util/wrapper.js +186 -281
  110. package/package.json +2 -2
@@ -5,43 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.assert = assert;
7
7
  exports.withSafeUserProps = exports.getSafeUserProps = void 0;
8
-
9
8
  var React = _interopRequireWildcard(require("react"));
10
-
11
9
  var _helpers = require("./helpers");
12
-
13
- 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); }
14
-
15
- 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; }
16
-
17
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
-
19
- 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."); }
20
-
21
- 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); }
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; }
24
-
25
- 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; }
26
-
27
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
-
29
- 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; }
30
-
31
- 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; }
32
-
33
- 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; }
34
-
10
+ 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); }
11
+ 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; }
35
12
  /*
36
13
  USER_PROPS_SAFELIST is to contain any string deemed safe for user props.
37
14
  The startsWidth array will contain the start of any accepted user-prop that
38
15
  starts with these characters.
39
16
  The exactMatch will contain a list of exact prop names that are accepted.
40
17
  */
41
- var USER_PROPS_SAFELIST = {
18
+ const USER_PROPS_SAFELIST = {
42
19
  startsWith: ["data-", "aria-"],
43
20
  exactMatch: []
44
- }; // Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
21
+ };
22
+
23
+ // Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
45
24
 
46
25
  // `data-${string}` | `aria-${string}`;
47
26
 
@@ -53,14 +32,15 @@ var USER_PROPS_SAFELIST = {
53
32
  * @returns {Boolean}: returns true if the key starts with an option or false if
54
33
  * otherwise
55
34
  */
56
- var doesPropStartWith = function (key) {
57
- var startsWith = false;
58
- USER_PROPS_SAFELIST.startsWith.forEach(function (starterString) {
59
- var regex = new RegExp("\\b(".concat(starterString, ")(\\w|-)+"), "g");
35
+ const doesPropStartWith = key => {
36
+ let startsWith = false;
37
+ USER_PROPS_SAFELIST.startsWith.forEach(starterString => {
38
+ const regex = new RegExp(`\\b(${starterString})(\\w|-)+`, "g");
60
39
  if (regex.test(key)) startsWith = true;
61
40
  });
62
41
  return startsWith;
63
42
  };
43
+
64
44
  /**
65
45
  * isExactMatch: checks to see if the given key matches any of the 'exactMatch'
66
46
  * items in the whitelist
@@ -69,34 +49,29 @@ var doesPropStartWith = function (key) {
69
49
  * @returns {Boolean}: return true if whitelist contains that key, otherwise
70
50
  * returns false.
71
51
  */
52
+ const isExactMatch = key => USER_PROPS_SAFELIST.exactMatch.includes(key);
72
53
 
73
-
74
- var isExactMatch = function (key) {
75
- return USER_PROPS_SAFELIST.exactMatch.includes(key);
76
- };
77
54
  /**
78
55
  * testIfSafeProp: tests prop's key against both startsWith and exactMatch values
79
56
  * @param {String} key: prop key to be tested against the whitelist
80
57
  * @returns {Boolean}: returns true if found in whitelist, otherwise returns false
81
58
  */
82
-
83
-
84
- var testIfSafeProp = function (key) {
59
+ const testIfSafeProp = key => {
85
60
  if (doesPropStartWith(key) || isExactMatch(key)) return true;
86
61
  return false;
87
62
  };
63
+
88
64
  /**
89
65
  * Asserts that value is not null or undefined, throwing an error if it is.
90
66
  * @param value The value to assert
91
67
  * @param message The error message to throw
92
68
  */
93
-
94
-
95
69
  function assert(value, message) {
96
70
  if (value === undefined || value === null) {
97
71
  throw new Error(message);
98
72
  }
99
73
  }
74
+
100
75
  /**
101
76
  * getSafeUserProps - function that takes in a props object and removes any
102
77
  * key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
@@ -105,24 +80,19 @@ function assert(value, message) {
105
80
  * @param {Object} props: props to be filtered against USER_PROPS_SAFELIST
106
81
  * @returns {Object}: object containing remaining acceptable props
107
82
  */
108
-
109
-
110
- var getSafeUserProps = function (props) {
111
- var propsToFilter = _objectSpread({}, props);
112
-
113
- return Object.fromEntries(Object.entries(propsToFilter).filter(function (_ref) {
114
- var _ref2 = _slicedToArray(_ref, 1),
115
- key = _ref2[0];
116
-
83
+ const getSafeUserProps = props => {
84
+ const propsToFilter = {
85
+ ...props
86
+ };
87
+ return Object.fromEntries(Object.entries(propsToFilter).filter(_ref => {
88
+ let [key] = _ref;
117
89
  return testIfSafeProp(key);
118
- }).map(function (_ref3) {
119
- var _ref4 = _slicedToArray(_ref3, 2),
120
- key = _ref4[0],
121
- value = _ref4[1];
122
-
90
+ }).map(_ref2 => {
91
+ let [key, value] = _ref2;
123
92
  return [key, (0, _helpers.evaluateProp)(value, props)];
124
93
  }));
125
94
  };
95
+
126
96
  /**
127
97
  * Wraps a component and adds safe user props
128
98
  *
@@ -130,12 +100,8 @@ var getSafeUserProps = function (props) {
130
100
  * @param {Object} props: props to be filtered
131
101
  * @returns {ReactElement} modified component
132
102
  */
133
-
134
-
135
103
  exports.getSafeUserProps = getSafeUserProps;
136
-
137
- var withSafeUserProps = function (component, props) {
104
+ const withSafeUserProps = (component, props) => {
138
105
  return /*#__PURE__*/React.cloneElement(component, getSafeUserProps(props));
139
106
  };
140
-
141
107
  exports.withSafeUserProps = withSafeUserProps;