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
@@ -14,15 +14,15 @@ exports.getStringsFromAxes = getStringsFromAxes;
14
14
  exports.getStringsFromCategories = getStringsFromCategories;
15
15
  exports.getStringsFromData = getStringsFromData;
16
16
  exports.isDataComponent = isDataComponent;
17
- var _omitBy2 = _interopRequireDefault(require("lodash/omitBy"));
18
- var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
19
- var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
20
- var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
21
- var _orderBy2 = _interopRequireDefault(require("lodash/orderBy"));
22
- var _property2 = _interopRequireDefault(require("lodash/property"));
23
- var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
24
- var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
25
17
  var _react = _interopRequireDefault(require("react"));
18
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
19
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
20
+ var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
21
+ var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
22
+ var _omitBy = _interopRequireDefault(require("lodash/omitBy"));
23
+ var _orderBy = _interopRequireDefault(require("lodash/orderBy"));
24
+ var _property = _interopRequireDefault(require("lodash/property"));
25
+ var _uniq = _interopRequireDefault(require("lodash/uniq"));
26
26
  var Helpers = _interopRequireWildcard(require("./helpers"));
27
27
  var Collection = _interopRequireWildcard(require("./collection"));
28
28
  var Scale = _interopRequireWildcard(require("./scale"));
@@ -30,8 +30,6 @@ var Immutable = _interopRequireWildcard(require("./immutable"));
30
30
  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); }
31
31
  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; }
32
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
- /* eslint-disable no-use-before-define */
34
-
35
33
  // Private Functions
36
34
 
37
35
  function parseDatum(datum) {
@@ -47,7 +45,7 @@ function getLength(data) {
47
45
 
48
46
  // Returns generated data for a given axis based on domain and sample from props
49
47
  function generateDataArray(props, axis) {
50
- const propsDomain = (0, _isPlainObject2.default)(props.domain) ? props.domain[axis] : props.domain;
48
+ const propsDomain = (0, _isPlainObject.default)(props.domain) ? props.domain[axis] : props.domain;
51
49
  const domain = propsDomain || Scale.getBaseScale(props, axis).domain();
52
50
  const samples = props.samples || 1;
53
51
  const domainMax = Math.max(...domain);
@@ -72,7 +70,7 @@ function sortData(dataset, sortKey, sortOrder) {
72
70
  formattedSortKey = `_${sortKey}`;
73
71
  }
74
72
  const order = sortOrder === "ascending" ? "asc" : "desc";
75
- return (0, _orderBy2.default)(dataset, formattedSortKey, order);
73
+ return (0, _orderBy.default)(dataset, formattedSortKey, order);
76
74
  }
77
75
 
78
76
  // This method will remove data points that break certain scales. (log scale only)
@@ -116,7 +114,7 @@ function getEventKey(key) {
116
114
  return () => undefined;
117
115
  }
118
116
  // otherwise, assume it is an array index, property key or path (_.property handles all three)
119
- return (0, _property2.default)(key);
117
+ return (0, _property.default)(key);
120
118
  }
121
119
 
122
120
  // Returns data with an eventKey prop added to each datum
@@ -151,8 +149,6 @@ function formatDataFromDomain(dataset, domain, defaultBaseline) {
151
149
  const isUnderMinY = underMin(minDomainY);
152
150
  const isOverMaxX = overMax(maxDomainX);
153
151
  const isOverMaxY = overMax(maxDomainY);
154
-
155
- // eslint-disable-next-line complexity
156
152
  return dataset.map(datum => {
157
153
  let {
158
154
  _x,
@@ -177,12 +173,12 @@ function formatDataFromDomain(dataset, domain, defaultBaseline) {
177
173
  if (isUnderMinY(baseline) && !isUnderMinY(value)) _y0 = minDomainY;
178
174
  // baseline and value with only baseline above max, set baseline to maxDomainY
179
175
  if (isOverMaxY(baseline) && !isOverMaxY(value)) _y0 = maxDomainY;
180
- return Object.assign({}, datum, (0, _omitBy2.default)({
176
+ return Object.assign({}, datum, (0, _omitBy.default)({
181
177
  _x,
182
178
  _y,
183
179
  _y0,
184
180
  _y1
185
- }, _isUndefined2.default));
181
+ }, _isUndefined.default));
186
182
  });
187
183
  }
188
184
 
@@ -196,7 +192,7 @@ function createStringMap(props, axis) {
196
192
  const stringsFromAxes = getStringsFromAxes(props, axis);
197
193
  const stringsFromCategories = getStringsFromCategories(props, axis);
198
194
  const stringsFromData = getStringsFromData(props, axis);
199
- const allStrings = (0, _uniq2.default)([...stringsFromAxes, ...stringsFromCategories, ...stringsFromData]);
195
+ const allStrings = (0, _uniq.default)([...stringsFromAxes, ...stringsFromCategories, ...stringsFromData]);
200
196
  return allStrings.length === 0 ? null : allStrings.reduce((memo, string, index) => {
201
197
  memo[string] = index + 1;
202
198
  return memo;
@@ -252,7 +248,7 @@ function formatData(dataset, props, expectedKeys) {
252
248
  memo[type] = createAccessor(type);
253
249
  return memo;
254
250
  }, {});
255
- const preformattedData = (0, _isEqual2.default)(expectedKeys, defaultKeys) && props.x === "_x" && props.y === "_y" && props.y0 === "_y0";
251
+ const preformattedData = (0, _isEqual.default)(expectedKeys, defaultKeys) && props.x === "_x" && props.y === "_y" && props.y0 === "_y0";
256
252
  let stringMap;
257
253
  if (preformattedData === false) {
258
254
  // stringMap is not required if the data is preformatted
@@ -263,7 +259,6 @@ function formatData(dataset, props, expectedKeys) {
263
259
  };
264
260
  }
265
261
  const data = preformattedData ? dataset : dataset.reduce((dataArr, datum, index) => {
266
- // eslint-disable-line complexity
267
262
  const parsedDatum = parseDatum(datum);
268
263
  const fallbackValues = {
269
264
  x: index,
@@ -283,7 +278,7 @@ function formatData(dataset, props, expectedKeys) {
283
278
  return memo;
284
279
  }, {});
285
280
  const formattedDatum = Object.assign({}, processedValues, parsedDatum);
286
- if (!(0, _isEmpty2.default)(formattedDatum)) {
281
+ if (!(0, _isEmpty.default)(formattedDatum)) {
287
282
  dataArr.push(formattedDatum);
288
283
  }
289
284
  return dataArr;
@@ -15,10 +15,10 @@ exports.getMaxFromProps = getMaxFromProps;
15
15
  exports.getMinFromProps = getMinFromProps;
16
16
  exports.getSymmetricDomain = getSymmetricDomain;
17
17
  exports.isDomainComponent = isDomainComponent;
18
- var _isDate2 = _interopRequireDefault(require("lodash/isDate"));
19
- var _sortedUniq2 = _interopRequireDefault(require("lodash/sortedUniq"));
20
- var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
21
18
  var _react = _interopRequireDefault(require("react"));
19
+ var _isDate = _interopRequireDefault(require("lodash/isDate"));
20
+ var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
21
+ var _sortedUniq = _interopRequireDefault(require("lodash/sortedUniq"));
22
22
  var Data = _interopRequireWildcard(require("./data"));
23
23
  var Scale = _interopRequireWildcard(require("./scale"));
24
24
  var Helpers = _interopRequireWildcard(require("./helpers"));
@@ -26,8 +26,6 @@ var Collection = _interopRequireWildcard(require("./collection"));
26
26
  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); }
27
27
  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; }
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
- /* eslint-disable no-use-before-define */
30
-
31
29
  // Private Methods
32
30
 
33
31
  function cleanDomain(domain, props, axis) {
@@ -53,7 +51,7 @@ function getDomainPadding(props, axis) {
53
51
  right: padding
54
52
  };
55
53
  };
56
- return (0, _isPlainObject2.default)(props.domainPadding) ? formatPadding(props.domainPadding[axis]) : formatPadding(props.domainPadding);
54
+ return (0, _isPlainObject.default)(props.domainPadding) ? formatPadding(props.domainPadding[axis]) : formatPadding(props.domainPadding);
57
55
  }
58
56
  function getFlatData(dataset, axis) {
59
57
  const axisKey = `_${axis}`;
@@ -77,8 +75,6 @@ function getExtremeFromData(dataset, axis, type) {
77
75
  }, initialValue);
78
76
  return containsDate ? new Date(result) : result;
79
77
  }
80
-
81
- // eslint-disable-next-line max-statements
82
78
  function padDomain(domain, props, axis) {
83
79
  if (!props.domainPadding) {
84
80
  return domain;
@@ -104,10 +100,10 @@ function padDomain(domain, props, axis) {
104
100
  min: min.valueOf() - simplePadding.left,
105
101
  max: max.valueOf() + simplePadding.right
106
102
  };
107
- const singleQuadrantDomainPadding = (0, _isPlainObject2.default)(props.singleQuadrantDomainPadding) ? props.singleQuadrantDomainPadding[axis] : props.singleQuadrantDomainPadding;
108
- const addsQuadrants = min >= 0 && paddedDomain.min <= 0 || max <= 0 && paddedDomain.max >= 0;
103
+ const singleQuadrantDomainPadding = (0, _isPlainObject.default)(props.singleQuadrantDomainPadding) ? props.singleQuadrantDomainPadding[axis] : props.singleQuadrantDomainPadding;
104
+ const addsQuadrants = min.valueOf() >= 0 && paddedDomain.min <= 0 || max.valueOf() <= 0 && paddedDomain.max >= 0;
109
105
  const adjust = (val, type) => {
110
- const coerce = type === "min" && min >= 0 && val <= 0 || type === "max" && max <= 0 && val >= 0;
106
+ const coerce = type === "min" && min.valueOf() >= 0 && val <= 0 || type === "max" && max.valueOf() <= 0 && val >= 0;
111
107
  return coerce ? 0 : val;
112
108
  };
113
109
  if (addsQuadrants && singleQuadrantDomainPadding !== false) {
@@ -276,7 +272,7 @@ function getDomainFromMinMax(min, max) {
276
272
  function getDomainFromProps(props, axis) {
277
273
  const minDomain = getMinFromProps(props, axis);
278
274
  const maxDomain = getMaxFromProps(props, axis);
279
- if ((0, _isPlainObject2.default)(props.domain) && props.domain[axis]) {
275
+ if ((0, _isPlainObject.default)(props.domain) && props.domain[axis]) {
280
276
  return props.domain[axis];
281
277
  } else if (Array.isArray(props.domain)) {
282
278
  return props.domain;
@@ -327,10 +323,10 @@ function getDomainWithZero(props, axis) {
327
323
  * @returns {Number|Date|undefined} the maxDomain based on props
328
324
  */
329
325
  function getMaxFromProps(props, axis) {
330
- if ((0, _isPlainObject2.default)(props.maxDomain) && props.maxDomain[axis] !== undefined) {
326
+ if ((0, _isPlainObject.default)(props.maxDomain) && props.maxDomain[axis] !== undefined) {
331
327
  return props.maxDomain[axis];
332
328
  }
333
- return typeof props.maxDomain === "number" || (0, _isDate2.default)(props.maxDomain) ? props.maxDomain : undefined;
329
+ return typeof props.maxDomain === "number" || (0, _isDate.default)(props.maxDomain) ? props.maxDomain : undefined;
334
330
  }
335
331
 
336
332
  /**
@@ -340,10 +336,10 @@ function getMaxFromProps(props, axis) {
340
336
  * @returns {Number|Date|undefined} the minDomain based on props
341
337
  */
342
338
  function getMinFromProps(props, axis) {
343
- if ((0, _isPlainObject2.default)(props.minDomain) && props.minDomain[axis] !== undefined) {
339
+ if ((0, _isPlainObject.default)(props.minDomain) && props.minDomain[axis] !== undefined) {
344
340
  return props.minDomain[axis];
345
341
  }
346
- return typeof props.minDomain === "number" || (0, _isDate2.default)(props.minDomain) ? props.minDomain : undefined;
342
+ return typeof props.minDomain === "number" || (0, _isDate.default)(props.minDomain) ? props.minDomain : undefined;
347
343
  }
348
344
 
349
345
  /**
@@ -354,7 +350,7 @@ function getMinFromProps(props, axis) {
354
350
  * @returns {Array} the symmetric domain
355
351
  */
356
352
  function getSymmetricDomain(domain, values) {
357
- const processedData = (0, _sortedUniq2.default)(values.sort((a, b) => a - b));
353
+ const processedData = (0, _sortedUniq.default)(values.sort((a, b) => a - b));
358
354
  const step = processedData[1] - processedData[0];
359
355
  return [domain[0], domain[1] + step];
360
356
  }
@@ -1,17 +1,17 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import type { EventMixinCalculatedValues } from "./add-events";
3
- declare type ComponentEventKey = string | number;
3
+ type ComponentEventKey = string | number;
4
4
  export interface ComponentEvent {
5
5
  target?: "parent" | string;
6
6
  eventKey?: ComponentEventKey | ComponentEventKey[];
7
7
  eventHandlers: ComponentEventHandlers;
8
8
  }
9
- export declare type ComponentEventName = string;
9
+ export type ComponentEventName = string;
10
10
  export interface ComponentEventHandlers {
11
11
  [k: ComponentEventName]: ComponentEventHandler;
12
12
  }
13
- export declare type ComponentEventHandler = (evt: React.SyntheticEvent, childProps: unknown, eventKey: ComponentEventKey, eventName: ComponentEventName) => UpdatedProps;
14
- export declare type UpdatedProps = any;
13
+ export type ComponentEventHandler = (evt: React.SyntheticEvent, childProps: unknown, eventKey: ComponentEventKey, eventName: ComponentEventName) => UpdatedProps;
14
+ export type UpdatedProps = any;
15
15
  interface ComponentWithEvents extends EventMixinCalculatedValues {
16
16
  state: any;
17
17
  setState: any;
@@ -15,14 +15,12 @@ exports.getGlobalEvents = void 0;
15
15
  exports.getPartialEvents = getPartialEvents;
16
16
  exports.getScopedEvents = getScopedEvents;
17
17
  exports.omitGlobalEvents = void 0;
18
- var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
19
- var _omitBy2 = _interopRequireDefault(require("lodash/omitBy"));
20
- var _pickBy2 = _interopRequireDefault(require("lodash/pickBy"));
21
- var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
18
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
19
+ var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
20
+ var _omitBy = _interopRequireDefault(require("lodash/omitBy"));
21
+ var _uniq = _interopRequireDefault(require("lodash/uniq"));
22
22
  var _helpers = require("./helpers");
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- /* eslint-disable no-use-before-define */
25
-
26
24
  const GLOBAL_EVENT_REGEX = /^onGlobal(.*)$/;
27
25
 
28
26
  // Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
@@ -69,11 +67,10 @@ getScopedEvents) {
69
67
  */
70
68
  const getAllEvents = () => {
71
69
  // Mandatory usage: `getEvents.bind(this)`
72
- /* eslint-disable no-invalid-this */
70
+
73
71
  if (Array.isArray(this.componentEvents)) {
74
72
  return Array.isArray(props.events) ? this.componentEvents.concat(...props.events) : this.componentEvents;
75
73
  }
76
- /* eslint-enable no-invalid-this */
77
74
  return props.events;
78
75
  };
79
76
  const allEvents = getAllEvents();
@@ -93,12 +90,12 @@ getScopedEvents) {
93
90
  */
94
91
  // eslint-disable-next-line max-params
95
92
  function getScopedEvents(events, namespace, childType, baseProps) {
96
- if ((0, _isEmpty2.default)(events)) {
93
+ if ((0, _isEmpty.default)(events)) {
97
94
  return {};
98
95
  }
99
96
 
100
97
  // Mandatory usage: `getScopedEvents.bind(this)`
101
- // eslint-disable-next-line no-invalid-this
98
+
102
99
  const newBaseProps = baseProps || this.baseProps;
103
100
  // returns the original base props or base state of a given target element
104
101
  const getTargetProps = (identifier, type) => {
@@ -107,7 +104,6 @@ function getScopedEvents(events, namespace, childType, baseProps) {
107
104
  target,
108
105
  key
109
106
  } = identifier;
110
- // eslint-disable-next-line no-invalid-this
111
107
  const baseType = type === "props" ? newBaseProps : this.state || {};
112
108
  const base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
113
109
  return key === "parent" ? base.parent : base[key] && base[key][target];
@@ -134,7 +130,6 @@ function getScopedEvents(events, namespace, childType, baseProps) {
134
130
 
135
131
  // returns the state object with mutated props applied for a single key
136
132
  const getMutationObject = (key, childName) => {
137
- // eslint-disable-next-line no-invalid-this
138
133
  const baseState = this.state || {};
139
134
  if (!(0, _helpers.isFunction)(eventReturn.mutation)) {
140
135
  return baseState;
@@ -207,11 +202,9 @@ function getScopedEvents(events, namespace, childType, baseProps) {
207
202
  // into a state mutation, and calls setState
208
203
  // eslint-disable-next-line max-params
209
204
  const onEvent = (evt, childProps, eventKey, eventName) => {
210
- // eslint-disable-next-line no-invalid-this
211
205
  const eventReturn = events[eventName](evt, childProps, eventKey, this);
212
- if (!(0, _isEmpty2.default)(eventReturn)) {
206
+ if (!(0, _isEmpty.default)(eventReturn)) {
213
207
  const callbacks = compileCallbacks(eventReturn);
214
- // eslint-disable-next-line no-invalid-this
215
208
  this.setState(parseEventReturn(eventReturn, eventKey), callbacks);
216
209
  }
217
210
  };
@@ -241,7 +234,7 @@ function getPartialEvents(events, eventKey, childProps) {
241
234
  // eslint-disable-next-line max-params
242
235
  function getEventState(eventKey, namespace, childType) {
243
236
  // Mandatory usage: `getEventState.bind(this)`
244
- // eslint-disable-next-line no-invalid-this
237
+
245
238
  const state = this.state || {};
246
239
  if (!childType) {
247
240
  return eventKey === "parent" ? state[eventKey] && state[eventKey][namespace] || state[eventKey] : state[eventKey] && state[eventKey][namespace];
@@ -271,7 +264,7 @@ function getExternalMutationsWithChildren(mutations, baseProps, baseState, child
271
264
  const childState = baseState[childName];
272
265
  const mutation = getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
273
266
  memo[childName] = mutation ? mutation : childState;
274
- return (0, _pickBy2.default)(memo, v => !(0, _isEmpty2.default)(v));
267
+ return (0, _pickBy.default)(memo, v => !(0, _isEmpty.default)(v));
275
268
  }, {});
276
269
  }
277
270
 
@@ -307,7 +300,7 @@ function getExternalMutations(mutations, baseProps, baseState, childName) {
307
300
  } else {
308
301
  // use keys from both state and props so that elements not intially included in baseProps
309
302
  // will be used. (i.e. labels)
310
- const targets = (0, _uniq2.default)(Object.keys(keyProps).concat(Object.keys(keyState)));
303
+ const targets = (0, _uniq.default)(Object.keys(keyProps).concat(Object.keys(keyState)));
311
304
  memo[eventKey] = targets.reduce((m, target) => {
312
305
  const identifier = {
313
306
  eventKey,
@@ -316,10 +309,10 @@ function getExternalMutations(mutations, baseProps, baseState, childName) {
316
309
  };
317
310
  const mutation = getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
318
311
  m[target] = mutation !== undefined ? Object.assign({}, keyState[target], mutation) : keyState[target];
319
- return (0, _pickBy2.default)(m, v => !(0, _isEmpty2.default)(v));
312
+ return (0, _pickBy.default)(m, v => !(0, _isEmpty.default)(v));
320
313
  }, {});
321
314
  }
322
- return (0, _pickBy2.default)(memo, v => !(0, _isEmpty2.default)(v));
315
+ return (0, _pickBy.default)(memo, v => !(0, _isEmpty.default)(v));
323
316
  }, {});
324
317
  }
325
318
 
@@ -351,11 +344,11 @@ function getExternalMutation(mutations, baseProps, baseState, identifier) {
351
344
  }
352
345
  // find any mutation objects that match the target
353
346
  const targetMutations = scopedMutations.filter(m => filterMutations(m, "target"));
354
- if ((0, _isEmpty2.default)(targetMutations)) {
347
+ if ((0, _isEmpty.default)(targetMutations)) {
355
348
  return undefined;
356
349
  }
357
350
  const keyMutations = targetMutations.filter(m => filterMutations(m, "eventKey"));
358
- if ((0, _isEmpty2.default)(keyMutations)) {
351
+ if ((0, _isEmpty.default)(keyMutations)) {
359
352
  return undefined;
360
353
  }
361
354
  return keyMutations.reduce((memo, curr) => {
@@ -381,9 +374,9 @@ function getGlobalEventNameFromKey(key) {
381
374
  const match = key.match(GLOBAL_EVENT_REGEX);
382
375
  return match && match[1] && match[1].toLowerCase();
383
376
  }
384
- const getGlobalEvents = events => (0, _pickBy2.default)(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
377
+ const getGlobalEvents = events => (0, _pickBy.default)(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
385
378
  exports.getGlobalEvents = getGlobalEvents;
386
- const omitGlobalEvents = events => (0, _omitBy2.default)(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
379
+ const omitGlobalEvents = events => (0, _omitBy.default)(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
387
380
  exports.omitGlobalEvents = omitGlobalEvents;
388
381
  const emulateReactEvent = event => Object.assign(event, {
389
382
  nativeEvent: event
@@ -1,6 +1,27 @@
1
1
  import React from "react";
2
- import { CallbackArgs } from "../types/callbacks";
3
2
  import { ValueOrAccessor } from "../types/prop-types";
3
+ export type ElementPadding = {
4
+ top: number;
5
+ bottom: number;
6
+ left: number;
7
+ right: number;
8
+ };
9
+ export type MaybePointData = {
10
+ x?: number;
11
+ x0?: number;
12
+ x1?: number;
13
+ y?: number;
14
+ y0?: number;
15
+ y1?: number;
16
+ _x?: number;
17
+ _x0?: number;
18
+ _x1?: number;
19
+ _y?: number;
20
+ _y0?: number;
21
+ _y1?: number;
22
+ _voronoiX?: number;
23
+ _voronoiY?: number;
24
+ };
4
25
  /**
5
26
  * Creates an object composed of the inverted keys and values of object.
6
27
  * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
@@ -14,32 +35,83 @@ export declare function invert(original: Record<string, string | number>): {};
14
35
  * @returns {Object} new object with same properties as originalObject
15
36
  */
16
37
  export declare function omit<T, Keys extends keyof T>(originalObject: T, ks?: Array<Keys>): Omit<T, Keys>;
17
- export declare function getPoint(datum: any): any;
18
- export declare function scalePoint(props: any, datum: any): {
19
- x: any;
20
- x0: any;
21
- y: any;
22
- y0: any;
23
- };
24
- export declare function getPadding(props: any, name?: string): {
25
- top: any;
26
- bottom: any;
27
- left: any;
28
- right: any;
38
+ /**
39
+ * Coalesce the x and y values from a data point
40
+ */
41
+ export declare function getPoint(datum: MaybePointData): MaybePointData;
42
+ /**
43
+ * Scale a point based on the origin, direction, and given scale function
44
+ */
45
+ export declare function scalePoint(props: {
46
+ scale: {
47
+ x: (x?: number) => number;
48
+ y: (y?: number) => number;
49
+ };
50
+ polar?: boolean;
51
+ horizontal?: boolean;
52
+ origin?: {
53
+ x: number;
54
+ y: number;
55
+ };
56
+ }, datum: MaybePointData): {
57
+ x: number;
58
+ x0: number;
59
+ y: number;
60
+ y0: number;
29
61
  };
30
- export declare function isTooltip(component: any): boolean;
62
+ /**
63
+ * Returns a padding value from a number or partial padding values
64
+ */
65
+ export declare function getPadding(padding?: number | Partial<ElementPadding>): ElementPadding;
66
+ /**
67
+ * Returns true if the component is defined as a tooltip
68
+ */
69
+ export declare function isTooltip(component?: {
70
+ type?: {
71
+ role?: string;
72
+ };
73
+ }): boolean;
31
74
  export declare function getDefaultStyles(props: any, role: any): any;
32
75
  export declare function getStyles(style: any, defaultStyles: any): any;
33
- export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, CallbackArgs>, props: CallbackArgs): TValue;
76
+ /**
77
+ * Returns the value of a prop or accessor function with the given props
78
+ */
79
+ export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, Record<string, any>>, props: Record<string, any>): TValue;
34
80
  export declare function evaluateStyle(style: any, props: any): any;
35
81
  export declare function degreesToRadians(degrees: any): any;
36
82
  export declare function radiansToDegrees(radians: any): any;
37
- export declare function getRadius(props: any): number;
38
- export declare function getPolarOrigin(props: any): {
83
+ /**
84
+ * Get the maximum radius that will fit in the container
85
+ */
86
+ export declare function getRadius(options: {
87
+ height: number;
88
+ width: number;
89
+ padding: ElementPadding;
90
+ }): number;
91
+ /**
92
+ * Returns the origin for a polar chart within the padded area
93
+ */
94
+ export declare function getPolarOrigin(props: {
95
+ height: number;
96
+ width: number;
97
+ padding: ElementPadding;
98
+ }): {
39
99
  x: number;
40
100
  y: number;
41
101
  };
42
- export declare function getRange(props: any, axis: any): any;
102
+ /**
103
+ * Determine the range of an axis based on the given props
104
+ */
105
+ export declare function getRange(props: {
106
+ range?: [number, number];
107
+ polar?: boolean;
108
+ innerRadius?: number;
109
+ startAngle?: number;
110
+ endAngle?: number;
111
+ height: number;
112
+ width: number;
113
+ padding: number | Partial<ElementPadding>;
114
+ }, axis: "x" | "y"): any;
43
115
  /**
44
116
  * Checks if `value` is `null` or `undefined`.
45
117
  * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
@@ -93,5 +165,8 @@ export declare function reduceChildren<TChildren extends React.ReactNode, TItem,
93
165
  * @returns {Boolean} returns true if the props object contains `horizontal: true` of if any
94
166
  * children or nested children are horizontal
95
167
  */
96
- export declare function isHorizontal(props: any): any;
168
+ export declare function isHorizontal(props: {
169
+ horizontal?: boolean;
170
+ children?: React.ReactNode;
171
+ }): any;
97
172
  //# sourceMappingURL=helpers.d.ts.map